diff --git a/ansi.md b/ansi.md new file mode 100644 index 000000000..8672270fe --- /dev/null +++ b/ansi.md @@ -0,0 +1,26 @@ +# Ansi codes + +Format + + \033[#m + +Where: + + 0 clear + 1 bold + 4 underline + 5 blink + + 30-37 fg color + 40-47 bg color + +Colors + + 0 black + 1 red + 2 green + 3 yellow + 4 blue + 5 magenta + 6 cyan + 7 white diff --git a/brew.md b/brew.md index b152cc82e..0ed7ba063 100644 --- a/brew.md +++ b/brew.md @@ -1,6 +1,21 @@ title: Brew --- +### Commands + + brew unlink git + brew link git + + brew list # List all installed + + brew list --versions git # See what versions of `git` you have + brew info git # List versions, caveats, etc + brew cleanup git # Remove old versions + brew edit git # Edit this formula + brew home git # Open homepage + +### Stuff + Nice Homebrew packages: * `tig` - Git "GUI" for the console diff --git a/c_preprocessor.md b/c_preprocessor.md new file mode 100644 index 000000000..3c0a4f191 --- /dev/null +++ b/c_preprocessor.md @@ -0,0 +1,45 @@ +### Compiling + + $ cpp -P file > outfile + +### Includes + + #include "file" + +### Defines + + #define FOO + #define FOO "hello" + + #undef FOO + +### If + + #ifdef DEBUG + console.log('hi'); + #elif defined VERBOSE + ... + #else + ... + #endif + +### Error + + #if VERSION == 2.0 + #error Unsupported + #warning Not really supported + #endif + +### Macro + + #define DEG(x) ((x) * 57.29) + +### Token concat + + #define DST(name) name##_s name##_t + DST(object); #=> "object_s object_t;" + +### file and line + + #define LOG(msg) console.log(__FILE__, __LINE__, msg) + #=> console.log("file.txt", 3, "hey") diff --git a/chai.md b/chai.md index 80b639bde..249149a5c 100644 --- a/chai.md +++ b/chai.md @@ -52,20 +52,25 @@ title: Chai ### Expectations - .equal(expected) - .eql // deepequal - .deep.equal(expected) - .be.a('string') - .include(val) - .be.ok(val) - .be.true - .be.false - .be.null - .be.undefined - .exist - .be.empty - .be.arguments - expect(10).above(5) + expect(object) + .equal(expected) + .eql // deepequal + .deep.equal(expected) + .be.a('string') + .include(val) + + .be.ok(val) + .be.true + .be.false + + .be.null + .be.undefined + .be.empty + .be.arguments + .be.function + + .exist + expect(10).above(5) ### References diff --git a/commanderjs.md b/commanderjs.md new file mode 100644 index 000000000..d2e5cb113 --- /dev/null +++ b/commanderjs.md @@ -0,0 +1,32 @@ +# Commander.js + +### Initialize + + var cli = require('commander'); + +### Options + + cli + .version(require('../package').version) + .usage('[options] ') + .option('-w, --words ', 'generate words') + .option('-i, --interval ', 'interval [1000]', 1000) + .option('-s, --symbols', 'include symbols') + .parse(process.argv); + +### Help + + .on('--help', function() { + console.log(''); + }) + +### Commands + + cli.outputHelp(); + cli.args == ["hello"]; + +### Other useful things + + process.exit(0); + + diff --git a/cron.md b/cron.md index 86bdaa1b0..c8dcc883e 100644 --- a/cron.md +++ b/cron.md @@ -24,3 +24,16 @@ title: Cron */15 * * * * every 15 mins 0 */2 * * * every 2 hours 0 0 0 * 0 every sunday midnight + + @reboot every reboot + +### crontab + + # Adding tasks easily + echo "@reboot echo hi" | crontab + + # Open in editor + crontab -e + + # List tasks + crontab -l [-u user] diff --git a/freenode.md b/freenode.md new file mode 100644 index 000000000..60a939fc4 --- /dev/null +++ b/freenode.md @@ -0,0 +1,10 @@ +# irc.freenode.net + + /msg nickserv identify [nick] + /msg nickserv info + +### Add a nick + + /nick newnick + /msg nickserv identify + /msg nickserv group diff --git a/javascript-arrays.md b/javascript-arrays.md new file mode 100644 index 000000000..423e6c640 --- /dev/null +++ b/javascript-arrays.md @@ -0,0 +1,30 @@ +# JavaScript arrays + + array = [a,b,c,d,e] + + array[1] //=> b + array.indexOf(b) //=> 1 + +### Subsets + + array.slice(1) //=> [b,c,d,e] + array.slice(1,2) //=> [b] + + re = array.splice(1) // re = [b,c,d,e] array == [a] + re = array.splice(1,2) // re = [b,c] array == [a,d,e] + +### Adding items + + array.push(Z) // array == [a,b,c,d,e,Z] + array.unshift(Z) // array == [Z,a,b,c,d,e] + + array.concat([F,G]) //=> [a,b,c,d,e,F,G] + +### Taking items + + array.pop() //=> e array == [a,b,c,d] + array.shift() //=> a array == [b,c,d,e] + + + + diff --git a/javascript.md b/javascript-workers.md similarity index 100% rename from javascript.md rename to javascript-workers.md diff --git a/jekyll.md b/jekyll.md new file mode 100644 index 000000000..6e182e9ff --- /dev/null +++ b/jekyll.md @@ -0,0 +1,133 @@ +--- +title: Jekyll +--- + +### Installation + + $ gem install jekyll + +### Directories + + _config.yml + + _drafts/ + + _includes/ + header.html + footer.html + + _layouts/ + default.html + + _posts/ + 2013-09-02-hello.md + + _site/ + ... + +Frontmatter +----------- + + --- + layout: post + title: Hello + --- + +### Other frontmatter stuff + + permalink: '/hello' + published: false + category: apple + categories: ['html', 'css'] + tags: ['html', 'css'] + +### Reference + + * [Front-matter](http://jekyllrb.com/docs/frontmatter/) + +Configuration +------------- + + source: . + destination: _site + exclude: [dir, file, ...] + include: ['.htaccess'] + +### Reference + + * [Configuration](http://jekyllrb.com/docs/configuration/) + +Variables +--------- + + {{ site }} - from config.yml + {{ page }} - from frontmatter, and page-specific info + {{ content }} - html content (use in layouts) + {{ paginator }} - ... + +### Site + + {{ site.time }} - current time + {{ site.pages }} - list of pages + {{ site.posts }} - list of posts + {{ site.related_posts }} - list + {{ site.categories.CATEGORY }} - list + {{ site.tags.TAG }} - list + +### Page + + {{ page.content }} - un-rendered content + {{ page.title }} + {{ page.excerpt }} - un-rendered excerpt + {{ page.url }} + {{ page.date }} + {{ page.id }} + {{ page.categories }} + {{ page.tags }} + {{ page.path }} + +### Paginator + + {{ paginator.per_page }} + {{ paginator.posts }} + ... + +Sample code +----------- + +### Loops + + {% for post in site.posts %} + +

{{ post.title }} — {{ post.date | date_to_string }}

+
+ {{ post.content }} + {% endfor %} + +### Dates + + {{ page.date | date: "%b %d, %Y" }} + +### If + + {% if page.image.feature %} + {% else %} + {% endif %} + +### Includes + + {% include header.html %} + +Integration +----------- + +### Bundler + + # _plugins/bundler.rb + require "bunder/setup" + Bundler.require :default + +### Compass + + https://gist.github.com/parkr/2874934 + https://github.com/matthodan/jekyll-asset-pipeline diff --git a/micronutrients.md b/micronutrients.md new file mode 100644 index 000000000..f1554bd68 --- /dev/null +++ b/micronutrients.md @@ -0,0 +1,104 @@ +24 classical micronutrients +--------------------------- + +### Vitamin D + + * Sources: sunlight, fish/eggs + * Dosage: 2000iu daily (10,000iu max) + * Major benefits: test boost + * Fat-soluble + * Best taken with meals or a source of fat + +### Zinc + + * Sources: meat, egg, legumes + * Major benefits: test boost, immune boost + * Doesn't go well with [Iron](#iron) + * Dosage: 5-10mg daily + +### Magnesium + + * Sources: grains, nuts, leafy vegetables + * Dosage: 200-450mg daily + * Major benefits: lower blood glucose + +### Selenium + + * Sources: + * Major benefits: anti-oxidant, anti-cancer + * Dosage: 200-300ug daily + +### Vitamin E + + * Sources: Nuts, needs, veg oils, leafy veggies + * Major benefits: anti-oxidant, skin + * Dosage: 15mg daily (RDA) + * Fat-soluble + +### Vitamin C + + * Sources: fruits (esp citrus), leafy veggies + * Dosage: 75mg daily (females), 90mg (males) + * Major benefits: anti-oxidant + +### Vitamin K + + * Sources: beans (legumes), green tea, veggies (mostly leafy), egg yolk, + chicken thigh + * Major benefits: bone health + * Fat-soluble + +### Vitamin B12 + +### Vitamin B6 + +### Thiamin (Vitamin B1) + +### Riboflavin (Vitamin B2) + +### Potassium + +### Omega 3 + +### Calcium + + * Sources: dairy + * Dosage: 1000mg daily for adults + * Major benefits: bone mass/strength + +### Iodine + + * Sources: dairy (yogurt, milk, eggs) + * Major benefits: thyroid gland regulation + +### Vitamin A + + * Sources: meat, poultry, fish, fruits, leafy veggies, orange veggies +(squash/carrots) + * Dosage: 10,000iu for adults + * Major benefits: vision, immune boost, reproduction + * Fat-soluble + +### Iron + + * Sources: soybeans, nuts/beans/lentils, beef, whole grains + * Major benefits: oxygen transport, energy metabolism + +References +---------- + +* Examine: + [K](http://examine.com/supplements/Vitamin+K/) + [C](http://examine.com/supplements/Vitamin+C/) + [Sel](http://examine.com/supplements/Selenium/) + [D](http://examine.com/supplements/Vitamin+D/) + [Zinc](http://examine.com/supplements/Zinc/) + [Mg](http://examine.com/supplements/Magnesium/) +* Nih.gov: + [E](http://ods.od.nih.gov/factsheets/VitaminE-HealthProfessional/) + [Ca](http://ods.od.nih.gov/factsheets/calcium.asp) + [A](http://ods.od.nih.gov/factsheets/Vitam-HealthProfessional/) +* Whfoods.com: + [I](http://www.whfoods.com/genpage.php?tname=nutrient&dbid=69) + [Fe](http://www.whfoods.com/genpage.php?tname=nutrient&dbid=70) + diff --git a/nodejs.md b/nodejs.md index d54a2a977..2d334e204 100644 --- a/nodejs.md +++ b/nodejs.md @@ -126,3 +126,16 @@ title: NodeJS api info.version process.stdout.write(util.inspect(objekt, false, Infinity, true) + '\n'); + +## Spawn + + var spawn = require('child_process').spawn; + var proc = spawn(bin, argv, { stdio: 'inherit' }); + proc.on('error', function(err) { + if (err.code == "ENOENT") { "does not exist" } + if (err.code == "EACCES") { "not executable" } + }); + proc.on('exit', function(code) { ... }); + + // also { stdio: [process.stdin, process.stderr, process.stdout] } + diff --git a/sinon.md b/sinon.md index d93980068..2293100e0 100644 --- a/sinon.md +++ b/sinon.md @@ -30,6 +30,10 @@ title: Sinon sinon.stub($, 'ajax', function() { return 'x' }); +### Fake date + + sinon.useFakeTimers(+new Date(2011,9,1)); + ### Fake server server = sinon.fakeServer.create(); @@ -47,3 +51,9 @@ title: Sinon xhr = sinon.useFakeXMLHttpRequest(); xhr.restore(); + +### Sandbox + + beforeEach -> global.sinon = require('sinon').sandbox.create() + afterEach -> global.sinon.restore() + diff --git a/spreadsheet.md b/spreadsheet.md new file mode 100644 index 000000000..1c41f3449 --- /dev/null +++ b/spreadsheet.md @@ -0,0 +1,33 @@ +# Spreadsheet macros + +### If + + =IF(test, then, else) + =IF(EQ(A1, "paid"), "true", "false") + +### Comparators + + =EQ(a,b) NE() + =GT() GTE() LT() LTE() + +### Math + + =POW(2, 32) # 2^32 + =SIN() ACOS() etc + =CEILING(n,sig,mode) + =FLOOR(n,sig,mode) + =INT(n) + + =SUM(range) + + =SUMIF(range, criteria, sum_range) + =SUMIF(A1:A5, ">300", B1:B5) # if A# is >300, use B# + +### Core + + =TO_DATE(number) + +### Vlook + + =VLOOKUP(value, range, column_index) + diff --git a/underscore-string.md b/underscore-string.md new file mode 100644 index 000000000..400f94983 --- /dev/null +++ b/underscore-string.md @@ -0,0 +1,84 @@ +# Underscore-string + +### Usage + + // Use it like so: + _.str.trim("hey"); + _s.trim("hey"); + + // Unless you do: + _.mixin(_.string.exports()); + + // So you can: + _.trim("hey"); + _("hey").trim(); + +### Trimming + + _.truncate("Hello world", 4) // => "Hell..." + _.prune("Hello world", 5) // => "Hello..." + + _.trim(" foo ") // => "foo" + _.trim("-foo-", '-') // => "foo" + _.ltrim + _.rtrim + +### Numbers + + _.numberFormat(1000, 2) // => "1,000.00" + +### Caps + + _.capitalize("foo bar") // => "Foo Bar" + _.humanize("hey-there foo") // => "Hey there foo" + _.titleize('My name is hi') // => "My Name Is Hi" + + _.dasherize('MozTransform') // => "-moz-transform" + _.underscored('MozTransform') // => "moz_transform" + _.classify('-moz-transform') // => "MozTransform" + _.camelize('moz_transform') // => "MozTransform" + + _.slugify("hey there") // => "hey-there" + + _.swapCase("hELLO") // => "Hello" + +### Checks + + _.startsWith('image.gif', 'image') // => true + _.endsWith('image.gif', '.gif') // => true + _.isBlank(" ") // => true (also for "\n", "") + +### HTML + + _.escapeHTML("
") + _.unescapeHTML("<div>") + _.stripTags("
hi
") + +### Quote + + _.quote("hi", '"') // => '"hi"' + _.unquote('"hi"') // => "hi" + +### Splits + + _.lines("hi\nthere") // => ["hi","there"] + _.words("hi there you") // => ["hi","there","you"] + +### Sprintf + + _.sprintf("%.1f", 1.17) + +### Pad + + _.pad("1", 8) // => " 1" + _.pad("1", 8, "0") // => "00000001" + _.pad("1", 8, " ", "right") // => "1 " + _.pad("1", 8, " ", "both") // => " 1 " + + _.lpad(..) // same as _.pad(.., 'left') + _.rpad(..) // same as _.pad(.., 'right') + _.lrpad(..) // same as _.pad(.., 'both') + +### References + +* https://github.com/epeli/underscore.string diff --git a/unicode.txt b/unicode.txt index 57bfcf6db..38c7e451d 100644 --- a/unicode.txt +++ b/unicode.txt @@ -17,3 +17,5 @@ ✓ check or tick mark ✓ ❌ cross mark ❌ 💬 speech balloon 💬 + +✈' diff --git a/vim.md b/vim.md index 986efe1cc..1710949e8 100644 --- a/vim.md +++ b/vim.md @@ -85,7 +85,34 @@ Marks `. # Last change `` # Last jump -Calculator ----------- +### Calculator (Insert mode) =128/2 + +### Highlights + + hi Comment + term=bold,underline + gui=bold + ctermfg=4 + guifg=#80a0ff + +### Filetype detection + + augroup filetypedetect + au! BufNewFile,BufRead *.json setf javascript + augroup END + + au Filetype markdown setlocal spell + +### Conceal + + set conceallevel=2 + syn match newLine "
" conceal cchar=} + hi newLine guifg=green + +### Region conceal + + syn region inBold concealends matchgroup=bTag start="" end="" + hi inBold gui=bold + hi bTag guifg=blue