mirror of
https://github.com/onkelbeh/cheatsheets.git
synced 2025-06-15 14:47:53 +02:00
Lots of updates.
This commit is contained in:
parent
dff114cb07
commit
fe1d99347c
8
bash.md
8
bash.md
@ -33,6 +33,14 @@ title: Bash
|
||||
echo $i
|
||||
end
|
||||
|
||||
### Reading input
|
||||
|
||||
echo -n "Proceed? [y/n]: "
|
||||
read ans
|
||||
echo $ans
|
||||
|
||||
read -n 1 ans # Just one character
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
|
30
css.md
Normal file
30
css.md
Normal file
@ -0,0 +1,30 @@
|
||||
title: CSS
|
||||
---
|
||||
|
||||
Webkit extensions
|
||||
-----------------
|
||||
|
||||
### Font smoothing
|
||||
|
||||
/* maxvoltar.com/archive/-webkit-font-smoothing */
|
||||
html { -webkit-font-smoothing: antialiased; }
|
||||
|
||||
### Heading kerning pairs and ligature
|
||||
|
||||
h1, h2, h3 { text-rendering: optimizeLegibility; }
|
||||
|
||||
### Native-like iOS scrolling
|
||||
|
||||
-webkit-overflow-scrolling: touch;
|
||||
overflow-y: auto;
|
||||
|
||||
### Gradient text
|
||||
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#333));
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
|
||||
### Text stroke
|
||||
|
||||
/* http://www.webkit.org/blog/85/introducing-text-stroke/ */
|
||||
-webkit-text-stroke: 3px black;
|
24
fitness.md
24
fitness.md
@ -20,3 +20,27 @@ http://www.bodybuilding.com/fun/mike1.htm
|
||||
* 5 x 100% (work set)
|
||||
|
||||
http://corw.in/warmup/
|
||||
|
||||
### Bench
|
||||
|
||||
Jennifer Thompson video: http://www.youtube.com/watch?v=34XRmd3a8_0
|
||||
|
||||
### Metabolism
|
||||
|
||||
* At rest, 33% of the body's energy comes from carbohydrates, or glycogen,
|
||||
stored within the muscles and liver. 66% comes from fat.
|
||||
|
||||
* During aerobic work, 50-60% of the energy comes from fats
|
||||
|
||||
* Primarily carbohydrates are used during the first several minutes of exercise
|
||||
|
||||
* For an average fit person, it takes 20 to 30 minutes of continuous aerobic
|
||||
activity to burn 50% fat and 50% carbohydrate
|
||||
|
||||
* There is approximately a 7 fold increase of fat mobilization after 1 hour of
|
||||
exercise
|
||||
|
||||
* Low intense exercise (<30% VO2 max) relies primarily on fat whereas high
|
||||
intense exercise (>70% VO2 max) primarily utilized carbohydrate.
|
||||
|
||||
http://www.exrx.net/Nutrition/Substrates.html
|
||||
|
26
homebrew.md
Normal file
26
homebrew.md
Normal file
@ -0,0 +1,26 @@
|
||||
class Tweetx < Formula
|
||||
homepage 'http://code.google.com/p/tweetx/'
|
||||
url 'http://tweetx.googlecode.com/files/tweetx-0.1.tar.gz'
|
||||
version '0.1'
|
||||
sha1 'e676f895ac5df1574f6fd4086ee57b9bf8d71e20'
|
||||
|
||||
head 'https://github.com/b4winckler/macvim.git', :branch => 'master'
|
||||
|
||||
def options
|
||||
[
|
||||
["--custom-icons", "Try to generate custom document icons."],
|
||||
]
|
||||
end
|
||||
|
||||
depends_on 'cscope' if ARGV.include? '--with-cscope'
|
||||
|
||||
def install
|
||||
system "./configure",
|
||||
"--prefix=#{prefix}",
|
||||
"--libdir=#{lib}"
|
||||
system "make install"
|
||||
|
||||
man1.install 'manpage.1'
|
||||
bin.install "foo"
|
||||
end
|
||||
end
|
6
ios.md
6
ios.md
@ -2,9 +2,13 @@ Multiple Exchange accounts:
|
||||
|
||||
scp root@iphone.local:/private/var/mobile/Library/Preferences/com.apple.accountsettings.plist .
|
||||
|
||||
Winterboard themes:
|
||||
|
||||
/Library/Themes
|
||||
|
||||
Copy photos:
|
||||
|
||||
scp -r root@iphone.local:/User/Media/DCIM/100APPLE ./photos
|
||||
rsync -v -r root@iphone.local:/User/Media/DCIM/100APPLE ./photos
|
||||
|
||||
Ringtone conversion using ffmpeg:
|
||||
|
||||
|
133
jasmine.md
Normal file
133
jasmine.md
Normal file
@ -0,0 +1,133 @@
|
||||
title: Jasmine
|
||||
---
|
||||
|
||||
[Jasmine](http://pivotal.github.com/jasmine/).
|
||||
|
||||
describe("A suite", function() {
|
||||
it("contains spec with an expectation", function() {
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
### Expectations
|
||||
|
||||
expect(true).toBe(true)
|
||||
expect(true).not.toBe(true)
|
||||
|
||||
expect(a).toEqual(bar)
|
||||
|
||||
expect(message).toMatch(/bar/)
|
||||
expect(message).toMatch('bar')
|
||||
|
||||
expect(a.foo).toBeDefined()
|
||||
expect(a.foo).toBeUndefined()
|
||||
expect(a.foo).toBeNull()
|
||||
|
||||
expect(a.foo).toBeTruthy()
|
||||
expect(a.foo).toBeFalsy()
|
||||
|
||||
expect(message).toContain('hello')
|
||||
|
||||
expect(pi).toBeGreaterThan(3)
|
||||
expect(pi).toBeLessThan(4)
|
||||
expect(pi).toBeCloseTo(3.1415, 0.1)
|
||||
|
||||
expect(func).toThrow()
|
||||
|
||||
### Blocks
|
||||
|
||||
beforeEach(function() { ... });
|
||||
afterEach(function() { ... });
|
||||
|
||||
### Pending
|
||||
|
||||
xit("this is a pending test", function() { ... })
|
||||
xdescribe("this is a pending block", function() { ... })
|
||||
|
||||
### Spies
|
||||
|
||||
spyOn(foo, 'setBar')
|
||||
spyOn(foo, 'setBar').andReturn(123)
|
||||
spyOn(foo, 'getBar').andCallFake(function() { return 1001; })
|
||||
foo.setBar(123)
|
||||
|
||||
expect(foo.setBar).toHaveBeenCalled()
|
||||
expect(foo.setBar).toHaveBeenCalledWith(123)
|
||||
expect(foo.setBar.calls.length).toEqual(2)
|
||||
expect(foo.setBar.calls[0].args[0]).toEqual(123)
|
||||
|
||||
### Creating spies
|
||||
|
||||
stub = jasmine.createSpy('stub')
|
||||
stub("hello")
|
||||
|
||||
expect(whatAmI.identity).toEqual("stub")
|
||||
expect(whatAmI).toHaveBeenCalled()
|
||||
|
||||
### Async
|
||||
|
||||
it("should run async", function() {
|
||||
var flag = false, value = 0;
|
||||
|
||||
runs(function() {
|
||||
setTimeout(function() { flag = true; }, 500);
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
value++;
|
||||
return flag;
|
||||
}, "increment", 750);
|
||||
|
||||
runs(function() {
|
||||
expect(value).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
### HTML runner
|
||||
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
jasmineEnv.updateInterval = 250;
|
||||
|
||||
var htmlReporter = new jasmine.HtmlReporter();
|
||||
jasmineEnv.addReporter(htmlReporter);
|
||||
|
||||
$(function() { jasmineEnv.execute(); });
|
||||
|
||||
Jasmine jQuery
|
||||
==============
|
||||
|
||||
[Jasmin jQuery](https://github.com/velesin/jasmine-jquery).
|
||||
|
||||
expect($('#id')).toBe('div')
|
||||
expect($('input[type=checkbox]')).toBeChecked()
|
||||
expect($('input[type=checkbox]')).toBeDisabled()
|
||||
expect($('input[type=checkbox]')).toBeFocused()
|
||||
expect($('#menu ul')).toBeEmpty()
|
||||
|
||||
expect($('#toolbar')).toBeHidden()
|
||||
expect($('#toolbar')).toBeVisible()
|
||||
|
||||
expect($('#popup')).toHaveCss({ margin: "10px" })
|
||||
expect($('option')).toBeSelected()
|
||||
|
||||
expect($('.foo')).toExist()
|
||||
|
||||
expect($('a')).toHaveAttr('rel')
|
||||
expect($('a')).toHaveAttr('rel', 'nofollow')
|
||||
|
||||
expect($('a')).toHaveClass('rel')
|
||||
expect($('a')).toHaveId('home')
|
||||
|
||||
expect($('a')).toHaveHtml('<span></span>')
|
||||
expect($('a')).toContainHtml('<span></span>')
|
||||
expect($('a')).toHaveText('hi')
|
||||
|
||||
expect($form).toHandle('submit') // event
|
||||
expect($form).toHandleWith('submit', onSumbit)
|
||||
|
||||
### Event spies
|
||||
|
||||
spyOnEvent($('#some_element'), 'click');
|
||||
$('#some_element').click();
|
||||
expect('click').toHaveBeenPreventedOn($('#some_element'));
|
||||
expect('click').toHaveBeenTriggeredOn($('#some_element'));
|
297
lua.md
Normal file
297
lua.md
Normal file
@ -0,0 +1,297 @@
|
||||
title: Lua
|
||||
|
||||
## Comments
|
||||
|
||||
-- comment
|
||||
--[[ Multiline
|
||||
comment ]]
|
||||
|
||||
## Invoking functions
|
||||
|
||||
print()
|
||||
print("Hi")
|
||||
|
||||
-- You can omit parentheses if the argument is one string or table literal
|
||||
print "Hello World" <--> print("Hello World")
|
||||
dofile 'a.lua' <--> dofile ('a.lua')
|
||||
print [[a multi-line <--> print([[a multi-line
|
||||
message]] message]])
|
||||
f{x=10, y=20} <--> f({x=10, y=20})
|
||||
type{} <--> type({})
|
||||
|
||||
## Tables / arrays
|
||||
|
||||
t = {}
|
||||
t = { a = 1, b = 2 }
|
||||
t.a = function() ... end
|
||||
|
||||
t = { ["hello"] = 200 }
|
||||
t.hello
|
||||
|
||||
-- Remember, arrays are also tables
|
||||
array = { "a", "b", "c", "d" }
|
||||
print(array[2]) -- "b" (zero-indexed)
|
||||
print(#array) -- 4 (length)
|
||||
|
||||
## Loops
|
||||
|
||||
while condition do
|
||||
end
|
||||
|
||||
for i = 1,5 do
|
||||
end
|
||||
|
||||
for i = start,finish,delta do
|
||||
end
|
||||
|
||||
for k,v in pairs(tab) do
|
||||
end
|
||||
|
||||
repeat
|
||||
until condition
|
||||
|
||||
-- Breaking out:
|
||||
while x do
|
||||
if condition then break end
|
||||
end
|
||||
|
||||
## Conditionals
|
||||
|
||||
if condition then
|
||||
print("yes")
|
||||
elsif condition then
|
||||
print("maybe")
|
||||
else
|
||||
print("no")
|
||||
end
|
||||
|
||||
## Variables
|
||||
|
||||
local x = 2
|
||||
two, four = 2, 4
|
||||
|
||||
## Functions
|
||||
|
||||
function myFunction()
|
||||
return 1
|
||||
end
|
||||
|
||||
function myFunctionWithArgs(a, b)
|
||||
-- ...
|
||||
end
|
||||
|
||||
myFunction()
|
||||
|
||||
anonymousFunctions(function()
|
||||
-- ...
|
||||
end)
|
||||
|
||||
-- Not exported in the module
|
||||
local function myPrivateFunction()
|
||||
end
|
||||
|
||||
-- Splats
|
||||
function doAction(action, ...)
|
||||
print("Doing '"..action.."' to", ...)
|
||||
--> print("Doing 'write' to", "Shirley", "Abed")
|
||||
end
|
||||
|
||||
doAction('write', "Shirley", "Abed")
|
||||
|
||||
## Lookups
|
||||
|
||||
mytable = { x = 2, y = function() .. end }
|
||||
|
||||
-- The same:
|
||||
mytable.x
|
||||
mytable['x']
|
||||
|
||||
-- Syntactic sugar, these are equivalent:
|
||||
mytable.y(mytable)
|
||||
mytable:y()
|
||||
|
||||
mytable.y(mytable, a, b)
|
||||
mytable:y(a, b)
|
||||
|
||||
function X:y(z) .. end
|
||||
function X.y(self, z) .. end
|
||||
|
||||
## Metatables
|
||||
|
||||
|
||||
mt = {}
|
||||
|
||||
-- A metatable is simply a table with functions in it.
|
||||
mt.__tostring = function() return "lol" end
|
||||
mt.__add = function(b) ... end -- a + b
|
||||
mt.__mul = function(b) ... end -- a * b
|
||||
mt.__index = function(k) ... end -- Lookups (a[k] or a.k)
|
||||
mt.__newindex = function(k, v) ... end -- Setters (a[k] = v)
|
||||
|
||||
-- Metatables allow you to override behavior of another table.
|
||||
mytable = {}
|
||||
setmetatable(mytable, mt)
|
||||
|
||||
print(myobject)
|
||||
|
||||
## Classes
|
||||
|
||||
Account = {}
|
||||
|
||||
function Account:new(balance)
|
||||
local t = setmetatable({}, { __index = Account })
|
||||
|
||||
-- Your constructor stuff
|
||||
t.balance = (balance or 0)
|
||||
return t
|
||||
end
|
||||
|
||||
function Account:withdraw(amount)
|
||||
print("Withdrawing "..amount.."...")
|
||||
self.balance = self.balance - amount
|
||||
self:report()
|
||||
end
|
||||
|
||||
function Account:report()
|
||||
print("Your current balance is: "..self.balance)
|
||||
end
|
||||
|
||||
a = Account:new(9000)
|
||||
a:withdraw(200) -- method call
|
||||
|
||||
## Constants
|
||||
|
||||
nil
|
||||
false
|
||||
true
|
||||
|
||||
## Operators (and their metatable names)
|
||||
|
||||
-- Relational (binary)
|
||||
-- __eq __lt __gt __le __ge
|
||||
== < > <= >=
|
||||
~= -- Not equal, just like !=
|
||||
|
||||
-- Arithmetic (binary)
|
||||
-- __add __sub __muv __div __mod __pow
|
||||
+ - * / % ^
|
||||
|
||||
-- Arithmetic (unary)
|
||||
-- __unm (unary minus)
|
||||
-
|
||||
|
||||
-- Logic (and/or)
|
||||
nil and 10 --> 10
|
||||
false and nil --> false
|
||||
10 and 20 --> 20
|
||||
|
||||
|
||||
-- Length
|
||||
-- __len(array)
|
||||
#array
|
||||
|
||||
|
||||
-- Indexing
|
||||
-- __index(table, key)
|
||||
t[key]
|
||||
t.key
|
||||
|
||||
-- __newindex(table, key, value)
|
||||
t[key]=value
|
||||
|
||||
-- String concat
|
||||
-- __concat(left, right)
|
||||
"hello, "..name
|
||||
|
||||
-- Call
|
||||
-- __call(func, ...)
|
||||
|
||||
|
||||
## API: Global functions [(ref)](http://lua.gts-stolberg.de/en/Basis.php)
|
||||
|
||||
dofile("hello.lua")
|
||||
loadfile("hello.lua")
|
||||
|
||||
assert(x) -- x or (raise an error)
|
||||
assert(x, "failed")
|
||||
|
||||
type(var) -- "nil" | "number" | "string" | "boolean" | "table" | "function" | "thread" | "userdata"
|
||||
|
||||
-- Does /not/ invoke meta methods (__index and __newindex)
|
||||
rawset(t, index, value) -- Like t[index] = value
|
||||
rawget(t, index) -- Like t[index]
|
||||
|
||||
_G -- Global context
|
||||
setfenv(1, {}) -- 1: current function, 2: caller, and so on -- {}: the new _G
|
||||
|
||||
pairs(t) -- iterable list of {key, value}
|
||||
ipairs(t) -- iterable list of {index, value}
|
||||
|
||||
tonumber("34")
|
||||
tonumber("8f", 16)
|
||||
|
||||
## API: Strings
|
||||
|
||||
'string'..'concatenation'
|
||||
|
||||
s = "Hello"
|
||||
s:upper()
|
||||
s:lower()
|
||||
s:len() -- Just like #s
|
||||
|
||||
s:find()
|
||||
s:gfind()
|
||||
|
||||
s:match()
|
||||
s:gmatch()
|
||||
|
||||
s:sub()
|
||||
s:gsub()
|
||||
|
||||
s:rep()
|
||||
s:char()
|
||||
s:dump()
|
||||
s:reverse()
|
||||
s:byte()
|
||||
s:format()
|
||||
|
||||
## API: Tables
|
||||
|
||||
table.foreach(t, function(row) ... end)
|
||||
table.setn
|
||||
table.insert(t, 21) -- append (--> t[#t+1] = 21)
|
||||
table.insert(t, 4, 99)
|
||||
table.getn
|
||||
table.concat
|
||||
table.sort
|
||||
table.remove(t, 4)
|
||||
|
||||
## API: Math [(ref)](http://lua-users.org/wiki/MathLibraryTutorial)
|
||||
|
||||
math.abs math.acos math.asin math.atan math.atan2
|
||||
math.ceil math.cos math.cosh math.deg math.exp
|
||||
math.floor math.fmod math.frexp math.ldexp math.log
|
||||
math.log10 math.max math.min math.modf math.pow
|
||||
math.rad math.random math.randomseed math.sin math.sinh
|
||||
math.sqrt math.tan math.tanh
|
||||
|
||||
math.sqrt(144)
|
||||
math
|
||||
|
||||
## API: Misc
|
||||
|
||||
io.output(io.open("file.txt", "w"))
|
||||
io.write(x)
|
||||
io.close()
|
||||
|
||||
for line in io.lines("file.txt")
|
||||
|
||||
file = assert(io.open("file.txt", "r"))
|
||||
file:read()
|
||||
file:lines()
|
||||
file:close()
|
||||
|
||||
## Reference
|
||||
|
||||
http://www.lua.org/pil/13.html
|
||||
http://lua-users.org/wiki/ObjectOrientedProgramming
|
@ -62,10 +62,7 @@ title: Middleman
|
||||
# Build-specific configuration
|
||||
|
||||
configure :build do
|
||||
# For example, change the Compass output style for deployment
|
||||
activate :minify_css
|
||||
|
||||
# Minify Javascript on build
|
||||
activate :minify_javascript
|
||||
|
||||
# Enable cache buster
|
||||
|
20
ncftp.md
Normal file
20
ncftp.md
Normal file
@ -0,0 +1,20 @@
|
||||
Bookmarking
|
||||
|
||||
$ ncftp
|
||||
$ open -u username ftp.host.com
|
||||
$ bookmark bookmarkname
|
||||
|
||||
Mass download
|
||||
|
||||
$ ncftpget -R bookmarkname /www/ .
|
||||
|
||||
Mass upload
|
||||
|
||||
$ ncftpget -R bookmarkname /www/ .
|
||||
|
||||
$ ncftpget -R bookmarkname /www/ .
|
||||
|
||||
Upload just the changed files
|
||||
|
||||
$ git show --pretty="format:" --name-only HEAD~1
|
||||
$ ncftpget -R -C log bookmarkname /www/ .
|
17
ruby.md
Normal file
17
ruby.md
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
* `$!` - latest error message
|
||||
* `$@` - location of error
|
||||
* `$_` - string last read by gets
|
||||
* `$.` - line number last read by interpreter
|
||||
* `$&` - string last matched by regexp
|
||||
* `$~` - the last regexp match, as an array of subexpressions
|
||||
* `$n` - the nth subexpression in the last match (same as $~[n])
|
||||
* `$=` - case-insensitivity flag
|
||||
* `$/` - input record separator
|
||||
* `$\` - output record separator
|
||||
* `$0` - the name of the ruby script file
|
||||
* `$*` (or `ARGV`) - the command line arguments
|
||||
* `$$` - interpreter's process ID
|
||||
* `$?` - exit status of last executed child process
|
||||
* `$-i` `$-l` `$-p` `$-v` - Command line switches
|
||||
* `$-v` (or `$VERBOSE`) - verbose mode
|
18
rubygems.md
Normal file
18
rubygems.md
Normal file
@ -0,0 +1,18 @@
|
||||
title: Rubygems
|
||||
----
|
||||
|
||||
gem build *.gemspec # Build a gem
|
||||
gem install *.gem # Install locally
|
||||
gem push *.gem # Upload to rubygems.org
|
||||
gem yank foogem -v 0.0.1 # Take it back
|
||||
gem owner -a rico@ricostacruz.com
|
||||
|
||||
gem list # List local gems
|
||||
gem which rake # Point to where lib/rake.rb is
|
||||
gem search -r rails # [remote] Search for gems
|
||||
|
||||
# https://github.com/fnando/gem-open
|
||||
gem open foogem
|
||||
GEM_EDITOR="vim" gem open foogem
|
||||
|
||||
cd $(basename `gem which rake`) # Go to a gem's path
|
35
sass.md
Normal file
35
sass.md
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
### Sprites
|
||||
|
||||
|
||||
// Sprite sets (applies to icon/*.png)
|
||||
$icon-spacing: 0
|
||||
$icon-dimensions: true
|
||||
$icon-repeat: no-repeat
|
||||
$icon-position: 0
|
||||
|
||||
// Individual (applies to icon/mail.png)
|
||||
$icon-mail-spacing: 0
|
||||
|
||||
@import 'icon/*.png'
|
||||
@include all-icon-sprites
|
||||
|
||||
// Usage
|
||||
.image1
|
||||
@extend .icon-mail
|
||||
|
||||
.image2
|
||||
@extend .icon-refresh;
|
||||
|
||||
// ### Advanced control
|
||||
// The sprite map is available as $icon-sprites. You can then use
|
||||
// `sprite()` on it.
|
||||
|
||||
.image3
|
||||
background: sprite($icon-sprites, refresh)
|
||||
//background: url(...) 0 -16px;
|
||||
|
||||
.image3-with-offset
|
||||
background: sprite($icon-sprites, refresh, -2px, -9px)
|
||||
//background: url(...) -2px -19px;
|
||||
|
12
vim.md
12
vim.md
@ -1,9 +1,17 @@
|
||||
title: vim
|
||||
----
|
||||
|
||||
. - repeat last command
|
||||
]p - paste under the current indentation level
|
||||
. - repeat last command
|
||||
]p - paste under the current indentation level
|
||||
`. - Go to last edit
|
||||
C-o - Go back to previous location (C-i forward)
|
||||
C-t - Go back to last tag
|
||||
|
||||
Command line
|
||||
------------
|
||||
|
||||
<C-r><C-w> - insert current word into the command line
|
||||
<C-r>" - paste from " register
|
||||
|
||||
Motions
|
||||
-------
|
||||
|
Loading…
x
Reference in New Issue
Block a user