diff --git a/angularjs.md b/angularjs.md index 1e1389818..e41ef7b85 100644 --- a/angularjs.md +++ b/angularjs.md @@ -3,6 +3,7 @@ title: Angular.js category: JavaScript libraries tags: [Archived] archived: This describes an older version of Angular. +layout: 2017/sheet --- ### About diff --git a/ansible.md b/ansible.md index 5a311d1f5..22d143149 100644 --- a/ansible.md +++ b/ansible.md @@ -1,12 +1,18 @@ --- title: Ansible category: Ansible +layout: 2017/sheet --- {% raw %} ## Getting started +### About +{: .-intro} + +- + ### Hosts $ sudo mkdir /etc/ansible @@ -20,7 +26,9 @@ category: Ansible $ ansible-playbook playbook.yml -## Tasks +## Playbook files + +### Tasks - hosts: all user: root @@ -39,7 +47,7 @@ category: Ansible handlers: - include: db.yml user=timmy -## Handlers +### Handlers handlers: - name: start apache2 @@ -51,7 +59,7 @@ category: Ansible notify: - start apache2 -## Vars +### Vars - host: lol vars_files: @@ -63,7 +71,7 @@ category: Ansible file: state=directory path=${project_root}/home/.ssh/ only_if: "$vm == 0" -## Roles +### Roles - host: xxx roles: @@ -91,9 +99,4 @@ category: Ansible vars: local_home: "{{ lookup('env','HOME') }}" -## References - - * [Intro](http://www.ansibleworks.com/docs/intro_configuration.html) - * [Modules](http://www.ansibleworks.com/docs/modules.html) - {% endraw %} diff --git a/arel.md b/arel.md index 2d5b35d19..58e24fcd2 100644 --- a/arel.md +++ b/arel.md @@ -1,8 +1,16 @@ --- title: Arel category: Rails +layout: 2017/sheet --- +### About +{: .-intro} + +Arel is an SQL abstraction library built into Ruby on Rails. + +* + ### Tables ```rb @@ -123,7 +131,3 @@ all_time = photos_with_credits.count this_month = photos_with_credits.where(photos[:created_at].gteq(Date.today.beginning_of_month)) recent_photos = photos_with_credits.where(photos[:created_at].gteq(Date.today.beginning_of_month)).limit(5) ``` - -## Reference - -* diff --git a/cask-index.md b/cask-index.md index bbdc7d4a8..e098b0172 100644 --- a/cask-index.md +++ b/cask-index.md @@ -1,10 +1,11 @@ --- title: Caskroom index +layout: 2017/sheet +tags: [Archived] +archived: This sheet may have outdated information. --- -# Caskroom - #### A diff --git a/circle.md b/circle.md index 0f6cf3661..5c8c557d6 100644 --- a/circle.md +++ b/circle.md @@ -1,9 +1,15 @@ --- title: CircleCI category: Devops +layout: 2017/sheet --- -## circle.yml +### About +{: .-intro} + +- + +### circle.yml * __machine__: adjusting the VM to your preferences and requirements * __checkout__: checking out and cloning your git repo @@ -14,7 +20,7 @@ category: Devops See: -## Sample +### Sample ```yml ## Customize the test machine @@ -91,5 +97,3 @@ notify: # A list of hashes representing hooks. Only the url field is supported. - url: https://someurl.com/hooks/circle ``` - -See: diff --git a/command_line.md b/command_line.md index 36cba170c..b2d829614 100644 --- a/command_line.md +++ b/command_line.md @@ -1,8 +1,12 @@ --- title: Command line stuff +layout: 2017/sheet --- ## List (ls) +{: .-three-column} + +### Usage ls [options] [paths] @@ -18,14 +22,12 @@ title: Command line stuff |--- | `-F` | Add / after directories | | `-G` | Color | -{:.shortcuts} ### Options | `-R` | Recurse | | `-a` | Include hidden (dotfiles) | | `-A` | Include hidden (but not . and ..) | -{:.shortcuts} ### Sorting @@ -39,11 +41,11 @@ title: Command line stuff | `-c` | sort by time status was changed | |--- | `-h` | Human-readable size (3k) | -{:.shortcuts} - -
## Tail +{: .-three-column} + +### Usage tail [-F | -f | -r] [-bN | -cN | -nN] [file ...] @@ -52,7 +54,6 @@ title: Command line stuff | `-f` | follow | | `-F` | follow by filename (accounts for log rotation) | | `-r` | Reverse order | -{:.shortcuts} ### Options @@ -60,11 +61,13 @@ title: Command line stuff | `-cN` | N bytes | | `-nN` | N lines | | `+N` | Start from line N | -{:.shortcuts}
## Sudo +{: .-three-column} + +### Usage ``` sudo [options] @@ -73,7 +76,6 @@ sudo [options] ### Listing | `-l` | List allowed commands | -{:.shortcuts} ### Options @@ -84,17 +86,14 @@ sudo [options] | `-n` | Don't prompt for password | | `-P` | Preserve group vector | | `-S` | Read password from stdin | -{:.shortcuts} ### File descriptors | `-C fd` | Close all open file descriptors | -{:.shortcuts} ### Prompt | `-p prompt` | Custom prompt (-p "%p password:") | -{:.shortcuts} ### Interactive @@ -105,38 +104,33 @@ sudo [options] |---- | `-u user` | run as this user | | `-g group` | run as this group | -{:.shortcuts} ### Timestamp | `-v` | revalidate timestamp for 5 mins | | `-k` | invalidate timestamp | | `-K` | just like -k | -{:.shortcuts} - -
## wc (Word count) +{: .-three-column} + +### wc ``` ... | wc [options] ``` +### Options + | `-c` | Bytes | | `-l` | Lines | | `-m` | Characters (incl multi-byte) | | `-w` | Words | -{:.shortcuts} - -
- -## Search-and-replace in all files - - perl -p -i -e 's/hello/HELLO/g' **/* - -
## Grep +{: .-three-column} + +### Usage ``` grep [options] [pattern] [file ...] @@ -164,9 +158,15 @@ grep [options] [pattern] [file ...] | `-r, -R` | --recursive | | `-v` | --invert-match | | `-i` | --ignore-case | -{:.shortcuts} ### Synonyms egrep => grep -E fgrep => grep -F + +## Other recipes +{: .-three-column} + +### Search-and-replace in all files + + perl -p -i -e 's/hello/HELLO/g' **/* diff --git a/commander.js.md b/commander.js.md index 444dba6f2..bcde24c6a 100644 --- a/commander.js.md +++ b/commander.js.md @@ -1,8 +1,14 @@ --- title: Commander.js category: JavaScript libraries +layout: 2017/sheet --- +### About +{: .-intro} + +- + ### Initialize var cli = require('commander'); diff --git a/devise.md b/devise.md index 59dba0191..f10b6f1d3 100644 --- a/devise.md +++ b/devise.md @@ -1,12 +1,17 @@ --- title: Devise +layout: 2017/sheet --- +### About +{: .-intro} + [Devise](https://github.com/plataformatec/devise) is a flexible authentication gem. -Installation ------------- +- + +### Installation Rails 3: Add the following to your Gemfile @@ -27,8 +32,7 @@ Generate devise for your model $ rails generate devise:views -Helpers -------- +### Helpers user_signed_in? current_user @@ -38,8 +42,7 @@ Helpers edit_user_registration_path (Edit registration) new_user_registration_path (Register new user) -Controller stuff ----------------- +### Controller stuff before_filter :authenticate_user! @@ -123,8 +126,11 @@ Routing Test helpers ------------ +### Test helpers + include Devise::TestHelpers - https://github.com/plataformatec/devise/blob/1094ba65aac1d37713f2cba71f9edad76b5ca274/lib/devise/test_helpers.rb sign_in @user sign_out @user + +See: diff --git a/elixir-metaprogramming.md b/elixir-metaprogramming.md index f588996d8..78e4f6388 100644 --- a/elixir-metaprogramming.md +++ b/elixir-metaprogramming.md @@ -1,9 +1,10 @@ --- title: Elixir metaprogramming category: Elixir +layout: 2017/sheet --- -## Kernel +### Kernel Most of these magic is defined in [Kernel.SpecialForms](http://devdocs.io/elixir/elixir/kernel.specialforms). diff --git a/firefox.md b/firefox.md index ac3b7683c..a8d1bcb98 100644 --- a/firefox.md +++ b/firefox.md @@ -1,5 +1,8 @@ --- title: Firefox +layout: 2017/sheet +tags: [Archived] +archived: This sheet has not been updated with newer Firefox releases. --- ### [Firefox 31](https://www.mozilla.org/en-US/firefox/31.0/releasenotes/) (July 2014) diff --git a/flux.md b/flux.md index b3aaa1349..876ac0125 100644 --- a/flux.md +++ b/flux.md @@ -1,9 +1,19 @@ --- title: Flux architecture category: React +layout: 2017/sheet --- -## Architecture +## About + +### About +{: .-intro} + +Flux is an architecture for building client-side web applications. + +* [In-Depth Overview](https://facebook.github.io/flux/docs/in-depth-overview/) _(facebook.github.io)_ + +### Architecture * __Dispatchers__ receive *actions* that get dispatched to its listeners. diff --git a/git-tricks.md b/git-tricks.md index 6e61058ba..b358fdc3e 100644 --- a/git-tricks.md +++ b/git-tricks.md @@ -1,15 +1,16 @@ --- title: Git tricks category: Git +layout: 2017/sheet --- -## Refs +### Refs HEAD^ # 1 commit before head HEAD^^ # 2 commits before head HEAD~5 # 5 commits before head -## Branches +### Branches # create a new branch git checkout -b $branchname @@ -31,7 +32,7 @@ category: Git # go back to previous branch git checkout - -## Collaboration +### Collaboration # Rebase your changes on top of the remote master git pull --rebase upstream master @@ -43,6 +44,8 @@ category: Git Submodules ---------- +### Submodules + # Import .gitmodules git submodule init @@ -70,6 +73,8 @@ Diff Log options ----------- +### Options + --oneline e11e9f9 Commit message here @@ -131,13 +136,13 @@ Misc git bisect reset # abort -## Searching +### Searching git log --grep="fixes things" # search in commit messages git log -S"window.alert" # search in code git log -G"foo.*" # search in code (regex) -## GPG Signing +### GPG signing git config set user.signingkey # Sets GPG key to use for signing diff --git a/gulp.md b/gulp.md index ad090b30e..890be7046 100644 --- a/gulp.md +++ b/gulp.md @@ -1,8 +1,13 @@ --- title: Gulp category: JavaScript libraries +layout: 2017/sheet +tags: [Archived] +archived: The information on this sheet may possibly be outdated. --- +### Available plugins + * gulp-ruby-sass * gulp-autoprefixer * gulp-minify-css diff --git a/ledger-examples.md b/ledger-examples.md index 25759479b..c7892aecf 100644 --- a/ledger-examples.md +++ b/ledger-examples.md @@ -1,9 +1,10 @@ --- title: Ledger examples category: Ledger +layout: 2017/sheet --- -Inspecting transactions: +### Inspecting transactions # show me expenses for october (--period) ledger r Expenses -p oct @@ -21,7 +22,7 @@ Inspecting transactions: ledger r mastercard -p "january" ledger r mastercard -b 01/25 -e 01/31 -Graphing: +### Graphing # Graph my bank account balance, monthly ledger r Savings -M @@ -32,14 +33,14 @@ Graphing: # ...what's the average per month? ledger r Expenses -M -n --average -Simple: +### Simple # what did I do yesterday? # ..list transactions on this day ledger r -p 01/26 ledger r -p yesterday -Switches: +### Switches # what's everything I got in USD? (--exchange) ledger b Assets -X USD diff --git a/ledger-format.md b/ledger-format.md index b30e91f2c..8ce10bd96 100644 --- a/ledger-format.md +++ b/ledger-format.md @@ -1,8 +1,10 @@ --- title: Ledger format category: Ledger +layout: 2017/sheet --- +### Example ``` 2015/01/01 Pay rent Assets:Savings -$300 @@ -32,6 +34,9 @@ Flags: ``` ## Accounts + +### Accounts + Only relevant with `--strict` or `--pedantic` ``` @@ -47,6 +52,8 @@ account Expenses:Food ## Others +### Others + ``` D $1,000.00 ; set default commodity diff --git a/ledger-periods.md b/ledger-periods.md index 6e0e76c4a..96c470acc 100644 --- a/ledger-periods.md +++ b/ledger-periods.md @@ -1,11 +1,19 @@ --- title: Ledger periods category: Ledger +layout: 2017/sheet --- +### About +{: .-intro} + +- + +### Usage + [INTERVAL] [BEGIN] [END] -Interval: +#### Intervals every day every week @@ -25,17 +33,17 @@ Interval: quarterly yearly -Begin: +#### Begin from since -The end time can be either of: +#### End to until -Spec: +### Spec 2004 2004/10 @@ -47,8 +55,6 @@ Spec: next week last week -Examples: +### Examples $ ledger r -p "since last month" - -See: http://ledger-cli.org/3.0/doc/ledger3.html#Period-Expressions diff --git a/ledger-query.md b/ledger-query.md index 32b52489f..a976a5c21 100644 --- a/ledger-query.md +++ b/ledger-query.md @@ -4,6 +4,10 @@ category: Ledger layout: 2017/sheet --- +### About + +- + ### Query characters | Query | Description | @@ -23,8 +27,3 @@ layout: 2017/sheet ledger r @taco ledger r comment =~ /landline/ ``` - -## References -{: .-one-column} - -- diff --git a/lua.md b/lua.md index ab95424e0..05029f464 100644 --- a/lua.md +++ b/lua.md @@ -1,14 +1,22 @@ --- title: Lua +layout: 2017/sheet --- -## Comments +## Basic examples + +### References + +- +- + +### Comments -- comment --[[ Multiline comment ]] -## Invoking functions +### Invoking functions print() print("Hi") @@ -21,7 +29,7 @@ title: Lua f{x=10, y=20} <--> f({x=10, y=20}) type{} <--> type({}) -## Tables / arrays +### Tables / arrays t = {} t = { a = 1, b = 2 } @@ -35,7 +43,7 @@ title: Lua print(array[2]) -- "b" (one-indexed) print(#array) -- 4 (length) -## Loops +### Loops while condition do end @@ -57,7 +65,7 @@ title: Lua if condition then break end end -## Conditionals +### Conditionals if condition then print("yes") @@ -67,12 +75,12 @@ title: Lua print("no") end -## Variables +### Variables local x = 2 two, four = 2, 4 -## Functions +### Functions function myFunction() return 1 @@ -100,7 +108,7 @@ title: Lua doAction('write', "Shirley", "Abed") -## Lookups +### Lookups mytable = { x = 2, y = function() .. end } @@ -118,8 +126,9 @@ title: Lua function X:y(z) .. end function X.y(self, z) .. end -## Metatables +## More concepts +### Metatables mt = {} @@ -136,7 +145,7 @@ title: Lua print(myobject) -## Classes +### Classes Account = {} @@ -161,7 +170,7 @@ title: Lua a = Account:new(9000) a:withdraw(200) -- method call -## Constants +### Constants nil false @@ -169,6 +178,8 @@ title: Lua ## Operators (and their metatable names) +### Relational + -- Relational (binary) -- __eq __lt __gt __le __ge == < > <= >= @@ -182,12 +193,15 @@ title: Lua -- __unm (unary minus) - +### Logic + -- Logic (and/or) nil and false --> nil false and nil --> false 0 and 20 --> 20 10 and 20 --> 20 +### Tables -- Length -- __len(array) @@ -209,8 +223,9 @@ title: Lua -- Call -- __call(func, ...) +## API -## API: Global functions [(ref)](http://lua.gts-stolberg.de/en/Basis.php) +### API: Global Functions dofile("hello.lua") loadfile("hello.lua") @@ -233,7 +248,7 @@ title: Lua tonumber("34") tonumber("8f", 16) -## API: Strings +### API: Strings 'string'..'concatenation' @@ -258,7 +273,7 @@ title: Lua s:byte() s:format() -## API: Tables +### API: Tables table.foreach(t, function(row) ... end) table.setn @@ -269,7 +284,7 @@ title: Lua table.sort table.remove(t, 4) -## API: Math [(ref)](http://lua-users.org/wiki/MathLibraryTutorial) +### API: Math math.abs math.acos math.asin math.atan math.atan2 math.ceil math.cos math.cosh math.deg math.exp @@ -281,7 +296,7 @@ title: Lua math.sqrt(144) math -## API: Misc +### API: Misc io.output(io.open("file.txt", "w")) io.write(x) @@ -293,8 +308,3 @@ title: Lua file:read() file:lines() file:close() - -## Reference - - https://www.lua.org/pil/13.html - http://lua-users.org/wiki/ObjectOrientedProgramming diff --git a/make-assets.md b/make-assets.md index 0e1ca970d..cc4e2fa34 100644 --- a/make-assets.md +++ b/make-assets.md @@ -1,9 +1,11 @@ --- title: Make for assets -hljs_languages: [makefile] +layout: 2017/sheet +tags: [Archived] +archived: This sheet may be listing practices that are outdated. --- -## Basic compiling +### Basic compiling ```makefile bin := ./node_modules/.bin @@ -14,7 +16,7 @@ build/%.js: src/%.coffee @$(bin)/coffee < $^ > $@ ``` -## Stylus + Autoprefixer +### Stylus + Autoprefixer bin := ./node_modules/.bin stylus := $(bin)/stylus @@ -28,18 +30,18 @@ build/%.js: src/%.coffee %.css: %.styl $(styl_files) @$(stylus) $< | $(autoprefixer) -b "> 1%" > $@ -## Hint +### Hint hint: $(js_files) -## Watching +### Watching watch: @echo "... watching for changes" @while true; do make -s; sleep 1; done -## Browserify +### Browserify js_files := $(shell find web/ -name "*.js") diff --git a/makefile.md b/makefile.md index cb5d8bce7..af3ddcf6c 100644 --- a/makefile.md +++ b/makefile.md @@ -5,7 +5,7 @@ layout: 2017/sheet category: CLI --- -## Var assignment +### Var assignment ```makefile foo = "bar" @@ -19,7 +19,7 @@ foo != echo fooo # exec shell command and assign to foo `=` expressions are only evaluated when they're being used. -## Magic variables +### Magic variables ```makefile out.o: src.c src.h @@ -38,7 +38,7 @@ also: $(@D) # target directory ``` -## Command prefixes +### Command prefixes | Prefix | Description | | ------ | ------------------------------------------- | @@ -54,14 +54,14 @@ build: -include .depend ``` -## Find files +### Find files ```makefile js_files := $(wildcard test/*.js) all_files := $(shell find images -name "*") ``` -## Substitutions +### Substitutions ```makefile file = $(SOURCE:.cpp=.o) # foo.cpp => foo.o @@ -71,7 +71,7 @@ outputs = $(patsubst %.c, %.o, $(wildcard *.c)) assets = $(patsubst images/%, assets/%, $(wildcard images/*)) ``` -## More functions +### More functions ```makefile $(strip $(string_var)) @@ -80,7 +80,7 @@ $(filter %.less, $(files)) $(filter-out %.less, $(files)) ``` -## Building files +### Building files ```makefile %.o: %.c @@ -88,13 +88,13 @@ $(filter-out %.less, $(files)) foo $^ ``` -## Includes +### Includes ```makefile -include foo.make ``` -## Options +### Options ```sh make @@ -104,7 +104,7 @@ make -j, --jobs=N # parallel processing ``` -## Conditionals +### Conditionals ```makefile foo: $(objects) @@ -115,14 +115,14 @@ else endif ``` -## Recursive +### Recursive ```makefile deploy: $(MAKE) deploy2 ``` -## Further reading +### Further reading - [isaacs's Makefile](https://gist.github.com/isaacs/62a2d1825d04437c6f08) - [Your Makefiles are wrong](https://tech.davis-hansson.com/p/make/) diff --git a/mocha-html.md b/mocha-html.md index 79c991585..b1bb6f153 100644 --- a/mocha-html.md +++ b/mocha-html.md @@ -1,10 +1,15 @@ --- title: Mocha HTML category: JavaScript libraries +layout: 2017/sheet --- +### About + This is a mocha template that loads js/css from cdn. +### Template + ```html diff --git a/mocha-tdd.md b/mocha-tdd.md index 11e0a1a4f..09d6fb32b 100644 --- a/mocha-tdd.md +++ b/mocha-tdd.md @@ -1,6 +1,7 @@ --- title: Mocha.js TDD interface category: JavaScript libraries +layout: 2017/sheet --- ### TDD diff --git a/nodejs.md b/nodejs.md index 6124078be..cf96438c5 100644 --- a/nodejs.md +++ b/nodejs.md @@ -4,11 +4,6 @@ category: Node.js layout: 2017/sheet --- -### About -{: .-intro} - -- - ### Globals __filename @@ -34,7 +29,7 @@ layout: 2017/sheet process.stdout.write(util.inspect(objekt, false, Infinity, true) + '\n'); -## Spawn - passthru the in/out +### Spawn - passthru the in/out var spawn = require('child_process').spawn; var proc = spawn(bin, argv, { stdio: 'inherit' }); diff --git a/nopt.md b/nopt.md index 0da5afde4..8147827b6 100644 --- a/nopt.md +++ b/nopt.md @@ -1,8 +1,16 @@ --- title: Nopt category: JavaScript libraries +layout: 2017/sheet --- +### About +{: .-intro} + +- + +### Example + ```js var args = require('nopt')({ foo: [String, null], @@ -46,5 +54,3 @@ if (args.version) { process.exit(0); } ``` - -https://www.npmjs.org/package/nopt diff --git a/parsimmon.md b/parsimmon.md index f2884c013..e4c4ac3c0 100644 --- a/parsimmon.md +++ b/parsimmon.md @@ -1,8 +1,10 @@ --- title: Parsimmon category: JavaScript libraries +layout: 2017/sheet --- +### Basic usage ```js const P = require('parsimmon') @@ -11,7 +13,7 @@ P.regexp(/[a-z]+/) //=> { status: true, value: ['hello'] } ``` -## Atoms +### Atoms ```js P.regexp(/[a-z]+/) @@ -23,7 +25,7 @@ P.optWhitespace P.eof ``` -## Combinators +### Combinators ```js P.seq(a, b, c) // sequence of these @@ -41,13 +43,13 @@ a.atMost(10) a.atLeast(10) ``` -## Formatting +### Formatting ```js P.seq(P.number, P.oneOf('+-*/'), P.number) .map(([left, oper, right]) => ({ oper, left, right })) ``` -## Reference +### Reference - diff --git a/phoenix-ecto@1.2.md b/phoenix-ecto@1.2.md index 19f9f399e..134106c2f 100644 --- a/phoenix-ecto@1.2.md +++ b/phoenix-ecto@1.2.md @@ -2,18 +2,23 @@ title: "Phoenix: Ecto models" category: Elixir deprecated: true +layout: 2017/sheet +tags: [Archived] +archived: This is for Phoenix 1.2 and below. [Phoenix 1.3 has a new API.](./phoenix-ecto@1.3). --- -This is for Phoenix 1.2 and below. [Phoenix 1.3 has a new API.](phoenix-ecto@1.3.html). +### About -## Generating +This is for Phoenix 1.2 and below. [Phoenix 1.3 has a new API.](./phoenix-ecto@1.3). + +### Generating ``` $ mix phoenix.gen.html Profile profiles email:string age:integer $ mix phoenix.gen.html User users email:string hashed_password:string ``` -## Schema +### Schema ```elixir defmodule User do @@ -30,7 +35,7 @@ defmodule User do end ``` -## Changesets +### Changesets ```elixir def changeset(user, params \\ :empty) do diff --git a/postgresql.md b/postgresql.md index d67899e81..0debd9e0a 100644 --- a/postgresql.md +++ b/postgresql.md @@ -1,15 +1,16 @@ --- title: PostgreSQL category: Databases +layout: 2017/sheet --- -Replace anything within `` accordingly - ### Console $ psql #logs in to default database & default user $ sudo -u psql #logs in with a particular user +Replace anything within `` accordingly + ### Commands * Show roles: `\du` diff --git a/projectionist.md b/projectionist.md index db8e61aac..118384e0b 100644 --- a/projectionist.md +++ b/projectionist.md @@ -1,8 +1,10 @@ --- title: Projectionist category: Vim +layout: 2017/sheet --- +### Basic usage ```json /* .projectionist.vim */ @@ -16,7 +18,7 @@ category: Vim } ``` -## Available options +### Available options ```js { @@ -35,7 +37,7 @@ category: Vim } ``` -## Commands +### Commands | Command | Description | |---------|-------------| @@ -53,8 +55,7 @@ category: Vim | `:Lcd` | cd to root using :lcd | |---------|-------------| | `:ProjectDo {cmd}` | run command in root | -{:.shortcuts} -## Reference +### Reference See [vim-projectionist](https://github.com/tpope/vim-projectionist). diff --git a/python.md b/python.md index 8750057b8..fd85dfbe4 100644 --- a/python.md +++ b/python.md @@ -1,6 +1,7 @@ --- title: Python category: Python +layout: 2017/sheet --- ### Tuples (immutable) diff --git a/rails-controllers.md b/rails-controllers.md index 8e00a3a5f..e08056e61 100644 --- a/rails-controllers.md +++ b/rails-controllers.md @@ -1,6 +1,7 @@ --- -title: Controllers +title: Rails controllers category: Rails +layout: 2017/sheet --- ### Common stuff diff --git a/rails-forms.md b/rails-forms.md index 6bda33695..d1f9c9025 100644 --- a/rails-forms.md +++ b/rails-forms.md @@ -1,11 +1,13 @@ --- -title: Form helpers -hljs_languages: [haml] +title: Rails form helpers category: Rails +layout: 2017/sheet --- ## Form builder +### Form builder + ```haml - form_for @post do |f| ``` diff --git a/rails-helpers.md b/rails-helpers.md index 623e22fa1..a56228332 100644 --- a/rails-helpers.md +++ b/rails-helpers.md @@ -1,6 +1,7 @@ --- -title: Helpers +title: Rails helpers category: Rails +layout: 2017/sheet --- ### Date diff --git a/rails-i18n.md b/rails-i18n.md index cf51c12c1..e180efb7e 100644 --- a/rails-i18n.md +++ b/rails-i18n.md @@ -1,8 +1,18 @@ --- -title: i18n +title: Rails i18n category: Rails +layout: 2017/sheet --- +### References + + * + * + * + * + +### Example + ```rb t('my.messages.hello') @@ -12,7 +22,8 @@ t(:hello, scope: [:my, :messages]) t('my.messages.hello', default: "Hello") ``` -{:.light} + +#### YAML ```yml en: @@ -26,7 +37,8 @@ en: ```rb t('hello', name: "John") ``` -{:.light} + +#### YAML ```yml hello: "Hello %{name}" @@ -38,7 +50,8 @@ hello: "Hello %{name}" # from the 'books/index' view t('.title') ``` -{:.light} + +#### YAML ```yml en: @@ -53,7 +66,8 @@ en: t(:inbox, count: 1) #=> 'one message' t(:inbox, count: 2) #=> '2 messages' ``` -{:.light} + +#### YAML ```yml inbox: @@ -69,7 +83,8 @@ inbox: l(Time.now) l(Time.now, format: :short) ``` -{:.light} + +#### YAML ```yml en: @@ -85,7 +100,8 @@ en: ```rb l(Date.today) ``` -{:.light} + +#### YAML ```yml en: @@ -104,7 +120,8 @@ en: User.model_name.human #=> "User" Child.model_name.human(count: 2) #=> "Children" ``` -{:.light} + +#### YAML ```yml en: @@ -121,7 +138,8 @@ en: ```rb User.human_attribute_for :name #=> "Name" ``` -{:.light} + +#### YAML ```yml en: @@ -138,7 +156,8 @@ en: ```rb error_messages_for(...) ``` -{:.light} + +#### YAML ```yml activerecord: @@ -150,6 +169,8 @@ activerecord: blank: "Please enter a name." ``` +### Scopes + Possible scopes (in order): ```yml @@ -181,7 +202,8 @@ validates form_for @post do f.label :body ``` -{:.light} + +#### YAML ```yml helpers: @@ -197,7 +219,8 @@ helpers: form_for @post do f.submit ``` -{:.light} + +#### YAML ```yml helpers: @@ -223,14 +246,14 @@ number_to_rounded(3.14, precision: 0) #=> "3" number_to_human(12_000) #=> "12 Thousand" number_to_human_size(12345) #=> "12.3 kb" ``` -{:.light} ### Delimited ```rb number_to_delimited(n) ``` -{:.light} + +#### YAML ```yml number: @@ -266,7 +289,8 @@ number: ```rb number_to_percentage(n) ``` -{:.light} + +#### YAML ```yml number: @@ -278,6 +302,8 @@ number: ## Programmatic access +### Programmatic access + ```rb I18n.backend.store_translations :en, ok: "Ok" I18n.locale = :en @@ -288,11 +314,3 @@ I18n.available_locales I18n.translate :ok # aka, I18n.t I18n.localize date # aka, I18n.l ``` -{:.light} - -## Reference - - * http://guides.rubyonrails.org/i18n.html - * http://rails-i18n.org/wiki - * https://github.com/svenfuchs/i18n - * https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/en.yml diff --git a/rails-migrations.md b/rails-migrations.md index b1b4392fa..67289ff40 100644 --- a/rails-migrations.md +++ b/rails-migrations.md @@ -1,6 +1,7 @@ --- -title: Migrations +title: Rails migrations category: Rails +layout: 2017/sheet --- ### Automatically make migrations diff --git a/rails-plugins.md b/rails-plugins.md index bc98e3b26..9339d2fae 100644 --- a/rails-plugins.md +++ b/rails-plugins.md @@ -1,10 +1,10 @@ --- title: Rails plugins category: Rails +layout: 2017/sheet --- -Generate a plugin ------------------ +### Generate a plugin Generate a Rails Engine plugin: @@ -13,10 +13,14 @@ Generate a Rails Engine plugin: Initializers ------------ +### Initializers + * [Rails::Railtie](http://edgeapi.rubyonrails.org/classes/Rails/Railtie.html) * [EngineYard blog post](http://www.engineyard.com/blog/2010/extending-rails-3-with-railties/) +### Initializer method + Subclass Railtie and provide an `initializer` method. module NewPlugin @@ -36,8 +40,12 @@ Subclass Railtie and provide an `initializer` method. Custom routes ------------- +### Custom routes + * [ActionDispatch::Routing::Mapper](http://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper.html) +### Creating routes + To create custom `routes.rb` keywords: # # routes.rb: @@ -65,6 +73,8 @@ Example with a block: Custom generators ----------------- +### Custom generators + * [Guide: generators](http://guides.rubyonrails.org/generators.html) * [ActiveRecord::Generators::Base](http://api.rubyonrails.org/classes/ActiveRecord/Generators/Base.html) @@ -118,6 +128,8 @@ When invoking `rails g XXX:YYY`: ActiveModel 'acts as' --------------------- +### acts as + # yaffle/lib/yaffle/acts_as_yaffle.rb module Yaffle module ActsAsYaffle diff --git a/rails-routes.md b/rails-routes.md index 1745ba0c1..0986efab9 100644 --- a/rails-routes.md +++ b/rails-routes.md @@ -1,9 +1,12 @@ --- title: Routes category: Rails +layout: 2017/sheet --- -## Multiple resources (`resources`) +## Resources + +### Multiple resources (`resources`) resources :photos diff --git a/rails-tricks.md b/rails-tricks.md index cbcde345c..7fc4b50e2 100644 --- a/rails-tricks.md +++ b/rails-tricks.md @@ -1,8 +1,13 @@ --- title: Rails tricks category: Rails +layout: 2017/sheet +tags: [Archived] +archived: This sheet may describe practices that might be outdated. --- +### Sass source maps + in config/environments/development.rb: # Source maps for Sass @@ -12,7 +17,7 @@ in config/environments/development.rb: # Don't break apart config.assets.debug = false -Partial locals +### Partial locals <%= render 'article', full: true %> <%= render 'article' %> @@ -21,12 +26,12 @@ Partial locals ... <% end %> -HTML in i18n +### HTML in i18n en: read_more_html: "read more..." -Exception handling: +### Exception handling # config/application.rb config.exceptions_app = self.routes @@ -40,25 +45,25 @@ Exception handling: end end -Rails updating: +### Rails updating rake rails:update -Distinct pluck: +### Distinct pluck Article.distinct.pluck('author') -Relation#merge +### Relation#merge scope :with_drafts, -> { uniq.joins(:articles).merge(Article.draft) } -Order +### Order scope :recent, -> { order created_at: :desc } -Group by month +### Group by month .group("to_char(created_at, 'YYYY-MM')") .group("to_char(created_at, 'YYYY-MM')").count diff --git a/tape.md b/tape.md index 379bad5d9..0bf05e790 100644 --- a/tape.md +++ b/tape.md @@ -1,8 +1,11 @@ --- title: Tape category: JavaScript libraries +layout: 2017/sheet --- +### Example + ```js test('things', (t) => { t.plan(1)