enabled: true
hostname: devhints.io
-id: "UA-106902774-1"
+id: "G-N7TC6B227L"
+# id: "UA-106902774-1"
---
title: Angular.js
category: JavaScript libraries
+tags: [Archived]
+archived: This describes an older version of Angular.
+layout: 2017/sheet
---
+
+### About
+{: .-intro}
+
+ * <https://github.com/angular/angular-seed>
+ * <https://angularjs.org/>
+
+### ng-app
+
```html
<html ng-app="nameApp">
```
})
});
```
-References:
-
- * https://github.com/angular/angular-seed
- * https://angularjs.org/
---
title: Ansible
category: Ansible
+layout: 2017/sheet
---
{% raw %}
## Getting started
+### About
+{: .-intro}
+
+- <https://www.ansible.com/>
+
### Hosts
$ sudo mkdir /etc/ansible
$ ansible-playbook playbook.yml
-## Tasks
+## Playbook files
+
+### Tasks
- hosts: all
user: root
handlers:
- include: db.yml user=timmy
-## Handlers
+### Handlers
handlers:
- name: start apache2
notify:
- start apache2
-## Vars
+### Vars
- host: lol
vars_files:
file: state=directory path=${project_root}/home/.ssh/
only_if: "$vm == 0"
-## Roles
+### Roles
- host: xxx
roles:
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 %}
---
title: Applinks
category: HTML
+layout: 2017/sheet
---
+### About
+
+- <http://applinks.org/>
+
+### Applinks
<meta property="al:ios:url" content="applinks://docs" />
<meta property="al:ios:app_store_id" content="12345" />
---
title: Arel
category: Rails
+layout: 2017/sheet
---
+### About
+{: .-intro}
+
+Arel is an SQL abstraction library built into Ruby on Rails.
+
+* <https://github.com/rails/arel>
+
### Tables
```rb
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
-
-* <http://github.com/rails/arel>
---
title: Bookshelf.js
category: JavaScript libraries
+layout: 2017/sheet
---
Model
-----
+### Model
```js
Summary = bookshelf.Model.extend({
tableName: 'summaries',
---
title: Browsersync
category: JavaScript libraries
+layout: 2017/sheet
---
-```
-npm i -g browser-sync
-```
-{:.terminal}
+### About
+{: .-intro}
+
+`npm i -g browser-sync`
+
+* [browsersync.io](https://browsersync.io)
### Start a server
--port=N
--proxy="http://127.0.0.1:3000"
```
-
-### Reference
-
-* [browsersync.io](http://browsersync.io)
---
title: Browserify
category: JavaScript libraries
+layout: 2017/sheet
+tags: [Archived]
+archived: Browserify has not been in active development.
---
+### About
+{: .-intro}
+
+Browserify is a bundler for JavaScript.
+
+- <https://browserify.org/>
+
+### Usage
+
browserify input.js
-o output.js
-t coffeeify
---
title: Bundler
category: Ruby
+layout: 2017/sheet
---
### Commands
expect(page).to have_no_button('Save') # OK
```
```ruby
-expect(page).not_to have_button('Save') # Bad
+expect(page).not_to have_button('Save') # OK
+```
+```ruby
+!expect(page).to have_button('Save') # Bad
```
-
-Use `should have_no_*` versions with RSpec matchers because
-`should_not have_*` doesn't wait for a timeout from the driver.
## RSpec
---
title: Caskroom index
+layout: 2017/sheet
+tags: [Archived]
+archived: This sheet may have outdated information.
---
-# Caskroom
-
#### A
---
title: CircleCI
category: Devops
+layout: 2017/sheet
---
-## circle.yml
+### About
+{: .-intro}
+
+- <https://circleci.com/docs/config-sample>
+
+### circle.yml
* __machine__: adjusting the VM to your preferences and requirements
* __checkout__: checking out and cloning your git repo
See: <https://circleci.com/docs/configuration>
-## Sample
+### Sample
```yml
## Customize the test machine
# A list of hashes representing hooks. Only the url field is supported.
- url: https://someurl.com/hooks/circle
```
-
-See: <https://circleci.com/docs/config-sample>
title: Command Line Interface Pages
category: CLI
layout: 2017/sheet
-tags: [Featured]
updated: 2023-02-23
keywords:
- CLI
---
title: Command line stuff
+layout: 2017/sheet
---
## List (ls)
+{: .-three-column}
+
+### Usage
ls [options] [paths]
|---
| `-F` | Add / after directories |
| `-G` | Color |
-{:.shortcuts}
### Options
| `-R` | Recurse |
| `-a` | Include hidden (dotfiles) |
| `-A` | Include hidden (but not . and ..) |
-{:.shortcuts}
### Sorting
| `-c` | sort by time status was changed |
|---
| `-h` | Human-readable size (3k) |
-{:.shortcuts}
-
-<br>
## Tail
+{: .-three-column}
+
+### Usage
tail [-F | -f | -r] [-bN | -cN | -nN] [file ...]
| `-f` | follow |
| `-F` | follow by filename (accounts for log rotation) |
| `-r` | Reverse order |
-{:.shortcuts}
### Options
| `-cN` | N bytes |
| `-nN` | N lines |
| `+N` | Start from line N |
-{:.shortcuts}
<br>
## Sudo
+{: .-three-column}
+
+### Usage
```
sudo [options] <command>
### Listing
| `-l` | List allowed commands |
-{:.shortcuts}
### 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
|----
| `-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}
-
-<br>
## wc (Word count)
+{: .-three-column}
+
+### wc
```
... | wc [options]
```
+### Options
+
| `-c` | Bytes |
| `-l` | Lines |
| `-m` | Characters (incl multi-byte) |
| `-w` | Words |
-{:.shortcuts}
-
-<br>
-
-## Search-and-replace in all files
-
- perl -p -i -e 's/hello/HELLO/g' **/*
-
-<br>
## Grep
+{: .-three-column}
+
+### Usage
```
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' **/*
---
title: Commander.js
category: JavaScript libraries
+layout: 2017/sheet
---
+### About
+{: .-intro}
+
+- <https://github.com/tj/commander.js/>
+
### Initialize
var cli = require('commander');
---
title: Devise
+layout: 2017/sheet
---
+### About
+{: .-intro}
+
[Devise](https://github.com/plataformatec/devise) is a flexible authentication
gem.
-Installation
-------------
+- <https://github.com/plataformatec/devise>
+
+### Installation
Rails 3: Add the following to your Gemfile
$ rails generate devise:views
-Helpers
--------
+### Helpers
user_signed_in?
current_user
edit_user_registration_path (Edit registration)
new_user_registration_path (Register new user)
-Controller stuff
-----------------
+### Controller stuff
before_filter :authenticate_user!
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: <https://github.com/plataformatec/devise/blob/1094ba65aac1d37713f2cba71f9edad76b5ca274/lib/devise/test_helpers.rb>
---
title: Divshot
+layout: 2017/sheet
+tags: [Archived]
+archived: Divshot is no longer in operation.
---
## Getting started
+### About
+
+Divshot was a static hosting platform.
+
+- <https://divshot.com/>
+
### Install divshot-cli
```
---
title: Do gem
category: Ruby libraries
+layout: 2017/sheet
---
+### About
+{: .-intro}
+
* [DAddYE/do](https://github.com/DAddYE/do)
### Connection
---
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).
---
title: Emacs
category: CLI
+layout: 2017/sheet
---
### Movements
---
title: Ember.js
category: JavaScript libraries
+layout: 2017/sheet
+tags: [Archived]
+archived: This sheet describes an older version of Ember.
---
{% raw %}
---
title: Express.js
category: JavaScript libraries
+layoute: 2017/sheet
---
### Settings
---
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)
---
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.
---
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
# go back to previous branch
git checkout -
-## Collaboration
+### Collaboration
# Rebase your changes on top of the remote master
git pull --rebase upstream master
Submodules
----------
+### Submodules
+
# Import .gitmodules
git submodule init
Log options
-----------
+### Options
+
--oneline
e11e9f9 Commit message here
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 <GPG KEY ID> # Sets GPG key to use for signing
---
title: Google Analytics
+layout: 2017/sheet
+tags: [Archived]
+archived: This sheet describes an older version of Google Analytics (UA).
---
### Pageview
// Scope = 1 (visitor), 2 (session), 3 (page, default)
-https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables
-https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide
+### References
+
+- <https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables>
+- <https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide>
---
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
---
title: Hledger
category: Ledger
+layout: 2017/sheet
---
-## Reporting
+### About
+{: .-intro}
+
+- <https://hledger.org>
+- <https://hledger.org/quickstart.html>
+
+### Reporting
```
hledger bal {query}
hledger reg {query}
```
-{:.large.terminal}
## Query
+### Queries
+
Queries are used on all commands (`bal`, `reg`, etc). [(docs)](http://hledger.org/manual.html#queries)
```
---
title: iOS Provisioning Profiles
+layout: 2017/sheet
---
### Types of profiles
---
title: Koa
category: JavaScript libraries
+layout: 2017/sheet
---
+### About
+{: .-intro}
+
+Koa is a web framework for Node.js.
+
+- <https://koajs.com/>
+
### Reference
```js
---
title: Kramdown
category: Markup
+layout: 2017/sheet
---
+### About
+{: .-intro}
+
+Kramdown is a Markdown parser in Ruby.
+
+- <https://kramdown.gettalong.org/>
+
### Configuration
* `parse_block_html` - process kramdown syntax inside blocks
---
title: Ledger examples
category: Ledger
+layout: 2017/sheet
---
-Inspecting transactions:
+### Inspecting transactions
# show me expenses for october (--period)
ledger r Expenses -p oct
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
# ...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
---
title: Ledger format
category: Ledger
+layout: 2017/sheet
---
+### Example
```
2015/01/01 Pay rent
Assets:Savings -$300
```
## Accounts
+
+### Accounts
+
Only relevant with `--strict` or `--pedantic`
```
## Others
+### Others
+
```
D $1,000.00 ; set default commodity
---
title: Ledger periods
category: Ledger
+layout: 2017/sheet
---
+### About
+{: .-intro}
+
+- <https://ledger-cli.org/3.0/doc/ledger3.html#Period-Expressions>
+
+### Usage
+
[INTERVAL] [BEGIN] [END]
-Interval:
+#### Intervals
every day
every week
quarterly
yearly
-Begin:
+#### Begin
from <SPEC>
since <SPEC>
-The end time can be either of:
+#### End
to <SPEC>
until <SPEC>
-Spec:
+### Spec
2004
2004/10
next week
last week
-Examples:
+### Examples
$ ledger r -p "since last month"
-
-See: http://ledger-cli.org/3.0/doc/ledger3.html#Period-Expressions
layout: 2017/sheet
---
+### About
+
+- <https://ledger-cli.org/3.0/doc/ledger3.html#Complex-expressions>
+
### Query characters
| Query | Description |
ledger r @taco
ledger r comment =~ /landline/
```
-
-## References
-{: .-one-column}
-
-- <http://ledger-cli.org/3.0/doc/ledger3.html#Complex-expressions>
---
title: Less.js
+layout: 2017/sheet
---
### Functions
---
title: Linux
+layout: 2017/sheet
---
### Read/Write/Execute a file
---
title: Lua
+layout: 2017/sheet
---
-## Comments
+## Basic examples
+
+### References
+
+- <https://www.lua.org/pil/13.html>
+- <http://lua-users.org/wiki/ObjectOrientedProgramming>
+
+### Comments
-- comment
--[[ Multiline
comment ]]
-## Invoking functions
+### Invoking functions
print()
print("Hi")
f{x=10, y=20} <--> f({x=10, y=20})
type{} <--> type({})
-## Tables / arrays
+### Tables / arrays
t = {}
t = { a = 1, b = 2 }
print(array[2]) -- "b" (one-indexed)
print(#array) -- 4 (length)
-## Loops
+### Loops
while condition do
end
if condition then break end
end
-## Conditionals
+### Conditionals
if condition then
print("yes")
print("no")
end
-## Variables
+### Variables
local x = 2
two, four = 2, 4
-## Functions
+### Functions
function myFunction()
return 1
doAction('write', "Shirley", "Abed")
-## Lookups
+### Lookups
mytable = { x = 2, y = function() .. end }
function X:y(z) .. end
function X.y(self, z) .. end
-## Metatables
+## More concepts
+### Metatables
mt = {}
print(myobject)
-## Classes
+### Classes
Account = {}
a = Account:new(9000)
a:withdraw(200) -- method call
-## Constants
+### Constants
nil
false
## Operators (and their metatable names)
+### Relational
+
-- Relational (binary)
-- __eq __lt __gt __le __ge
== < > <= >=
-- __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)
-- 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")
tonumber("34")
tonumber("8f", 16)
-## API: Strings
+### API: Strings
'string'..'concatenation'
s:byte()
s:format()
-## API: Tables
+### API: Tables
table.foreach(t, function(row) ... end)
table.setn
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
math.sqrt(144)
math
-## API: Misc
+### API: Misc
io.output(io.open("file.txt", "w"))
io.write(x)
file:read()
file:lines()
file:close()
-
-## Reference
-
- https://www.lua.org/pil/13.html
- http://lua-users.org/wiki/ObjectOrientedProgramming
---
title: Machinist
category: Ruby libraries
+layout: 2017/sheet
+tags: [Archived]
+archived: Machinist has not been in active development since 2013.
---
+### About
+
+Machinist is a fixture management library for Ruby.
+
+- <https://github.com/notahat/machinist>
+
### Installing
# Gemfile
---
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
@$(bin)/coffee < $^ > $@
```
-## Stylus + Autoprefixer
+### Stylus + Autoprefixer
bin := ./node_modules/.bin
stylus := $(bin)/stylus
%.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")
category: CLI
---
-## Var assignment
+### Var assignment
```makefile
foo = "bar"
`=` expressions are only evaluated when they're being used.
-## Magic variables
+### Magic variables
```makefile
out.o: src.c src.h
$(@D) # target directory
```
-## Command prefixes
+### Command prefixes
| Prefix | Description |
| ------ | ------------------------------------------- |
-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
assets = $(patsubst images/%, assets/%, $(wildcard images/*))
```
-## More functions
+### More functions
```makefile
$(strip $(string_var))
$(filter-out %.less, $(files))
```
-## Building files
+### Building files
```makefile
%.o: %.c
foo $^
```
-## Includes
+### Includes
```makefile
-include foo.make
```
-## Options
+### Options
```sh
make
-j, --jobs=N # parallel processing
```
-## Conditionals
+### Conditionals
```makefile
foo: $(objects)
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/)
---
title: Middleman 3
category: JavaScript libraries
+layout: 2017/sheet
+tags: [Archived]
+archived: This guide is for Middleman v3.
---
+### About
+
**NB:** This is for Middleman 3, not Middleman 4+.
### Compass config
---
title: Minitest
category: Ruby
+layout: 2017/sheet
---
### Usage
---
title: Mocha HTML
category: JavaScript libraries
+layout: 2017/sheet
---
+### About
+
This is a mocha template that loads js/css from cdn.
+### Template
+
```html
<!doctype html>
<html>
---
title: Mocha.js TDD interface
category: JavaScript libraries
+layout: 2017/sheet
---
### TDD
---
title: Mocha.js
category: JavaScript libraries
+layout: 2017/sheet
---
### BDD
---
title: Modernizr
category: JavaScript libraries
+layout: 2017/sheet
+tags: [Archived]
+archived: Modernizr is no longer in active development.
---
### Script
---
title: fs
category: Node.js
+layout: 2017/sheet
---
### Reading
---
title: process
category: Node.js
+layout: 2017/sheet
---
### Streams
---
title: Node.js API
category: Node.js
+layout: 2017/sheet
---
-## Globals
+### Globals
__filename
__dirname
}
});
-## Snippets
+### Snippets
info = require('../package.json')
info.version
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' });
---
title: Nopt
category: JavaScript libraries
+layout: 2017/sheet
---
+### About
+{: .-intro}
+
+- <https://www.npmjs.org/package/nopt>
+
+### Example
+
```js
var args = require('nopt')({
foo: [String, null],
process.exit(0);
}
```
-
-https://www.npmjs.org/package/nopt
title: Pacman
category: Linux
updated: 2018-07-07
-intro: |
- Pacman is the package manager for Arch linux and its derivatives.
+layout: 2017/sheet
---
## Commands
{: .-three-column}
+### About
+{: .-intro}
+
+Pacman is the package manager for Arch Linux and its derivatives.
+
+- <https://wiki.archlinux.org/title/pacman>
+
### Common commands
| Command | Description |
---
title: Parsimmon
category: JavaScript libraries
+layout: 2017/sheet
---
+### Basic usage
```js
const P = require('parsimmon')
//=> { status: true, value: ['hello'] }
```
-## Atoms
+### Atoms
```js
P.regexp(/[a-z]+/)
P.eof
```
-## Combinators
+### Combinators
```js
P.seq(a, b, c) // sequence of these
a.atLeast(10)
```
-## Formatting
+### Formatting
```js
P.seq(P.number, P.oneOf('+-*/'), P.number)
.map(([left, oper, right]) => ({ oper, left, right }))
```
-## Reference
+### Reference
- <https://github.com/jneen/parsimmon/blob/master/API.md>
---
title: Perl-pie
category: Development
+layout: 2017/sheet
---
+### About
+{: .-intro}
+
+Use `perl` to search and replace across many files.
+
### Search and replace
```sh
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
end
```
-## Changesets
+### Changesets
```elixir
def changeset(user, params \\ :empty) do
---
title: PlantUML
+layout: 2017/sheet
---
+### About
+{: .-intro}
+
+PlantUML is a markup language for creating diagrams.
+
+- <https://plantuml.com/>
+
### Format
@startuml
---
title: PostgreSQL
category: Databases
+layout: 2017/sheet
---
-Replace anything within `<placeholder>` accordingly
-
### Console
$ psql #logs in to default database & default user
$ sudo -u <rolename:postgres> psql #logs in with a particular user
+Replace anything within `<placeholder>` accordingly
+
### Commands
* Show roles: `\du`
---
title: Projectionist
category: Vim
+layout: 2017/sheet
---
+### Basic usage
```json
/* .projectionist.vim */
}
```
-## Available options
+### Available options
```js
{
}
```
-## Commands
+### Commands
| Command | Description |
|---------|-------------|
| `:Lcd` | cd to root using :lcd |
|---------|-------------|
| `:ProjectDo {cmd}` | run command in root |
-{:.shortcuts}
-## Reference
+### Reference
See [vim-projectionist](https://github.com/tpope/vim-projectionist).
---
title: Pry
category: Ruby libraries
+layout: 2017/sheet
---
+### About
+{: .-intro}
+
+Pry is a runtime development console for Ruby.
+
+- <https://github.com/pry/pry>
+
### cd
```
---
title: Python
category: Python
+layout: 2017/sheet
---
### Tuples (immutable)
---
title: Q.js
category: JavaScript libraries
+layout: 2017/sheet
---
+### About
+{: .-intro}
+
+* <https://github.com/kriskowal/q>
+* <https://github.com/kriskowal/q/wiki/API-Reference>
+
### Creating promises (Q.promise)
Q.promise (ok, fail) =>
.catch (e) ->
console.error "Oh well", e
-
-### Reference
-
- * https://github.com/kriskowal/q/wiki/API-Reference
---
title: Ractive.js
category: JavaScript libraries
-vim: ft=javascript
+layout: 2017/sheet
---
{% raw %}
+
+### About
+{: .-intro}
+
+Ractive is a UI library for JavaScript.
+
+- <https://ractive.js.org/>
+- <https://ractivejs.org/>
+
### [Initialization](http://docs.ractivejs.org/latest/options)
new Ractive({
---
-title: Controllers
+title: Rails controllers
category: Rails
+layout: 2017/sheet
---
### Common stuff
---
-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|
```
---
-title: Helpers
+title: Rails helpers
category: Rails
+layout: 2017/sheet
---
### Date
---
-title: i18n
+title: Rails i18n
category: Rails
+layout: 2017/sheet
---
+### References
+
+ * <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>
+
+### Example
+
```rb
t('my.messages.hello')
t('my.messages.hello', default: "Hello")
```
-{:.light}
+
+#### YAML
```yml
en:
```rb
t('hello', name: "John")
```
-{:.light}
+
+#### YAML
```yml
hello: "Hello %{name}"
# from the 'books/index' view
t('.title')
```
-{:.light}
+
+#### YAML
```yml
en:
t(:inbox, count: 1) #=> 'one message'
t(:inbox, count: 2) #=> '2 messages'
```
-{:.light}
+
+#### YAML
```yml
inbox:
l(Time.now)
l(Time.now, format: :short)
```
-{:.light}
+
+#### YAML
```yml
en:
```rb
l(Date.today)
```
-{:.light}
+
+#### YAML
```yml
en:
User.model_name.human #=> "User"
Child.model_name.human(count: 2) #=> "Children"
```
-{:.light}
+
+#### YAML
```yml
en:
```rb
User.human_attribute_for :name #=> "Name"
```
-{:.light}
+
+#### YAML
```yml
en:
```rb
error_messages_for(...)
```
-{:.light}
+
+#### YAML
```yml
activerecord:
blank: "Please enter a name."
```
+### Scopes
+
Possible scopes (in order):
```yml
form_for @post do
f.label :body
```
-{:.light}
+
+#### YAML
```yml
helpers:
form_for @post do
f.submit
```
-{:.light}
+
+#### YAML
```yml
helpers:
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:
```rb
number_to_percentage(n)
```
-{:.light}
+
+#### YAML
```yml
number:
## Programmatic access
+### Programmatic access
+
```rb
I18n.backend.store_translations :en, ok: "Ok"
I18n.locale = :en
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
---
-title: Migrations
+title: Rails migrations
category: Rails
+layout: 2017/sheet
---
### Automatically make migrations
---
title: Rails plugins
category: Rails
+layout: 2017/sheet
---
-Generate a plugin
------------------
+### Generate a plugin
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
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:
Custom generators
-----------------
+### Custom generators
+
* [Guide: generators](http://guides.rubyonrails.org/generators.html)
* [ActiveRecord::Generators::Base](http://api.rubyonrails.org/classes/ActiveRecord/Generators/Base.html)
ActiveModel 'acts as'
---------------------
+### acts as
+
# yaffle/lib/yaffle/acts_as_yaffle.rb
module Yaffle
module ActsAsYaffle
---
title: Routes
category: Rails
+layout: 2017/sheet
---
-## Multiple resources (`resources`)
+## Resources
+
+### Multiple resources (`resources`)
resources :photos
---
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
# Don't break apart
config.assets.debug = false
-Partial locals
+### Partial locals
<%= render 'article', full: true %>
<%= render 'article' %>
...
<% end %>
-HTML in i18n
+### HTML in i18n
en:
read_more_html: "read <b>more</b>..."
-Exception handling:
+### Exception handling
# config/application.rb
config.exceptions_app = self.routes
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
---
title: Tape
category: JavaScript libraries
+layout: 2017/sheet
---
+### Example
+
```js
test('things', (t) => {
t.plan(1)
tags: [Archived]
intro: |
[weinre](https://www.npmjs.com/package/weinre) is a remote Web inspector. Note that it has been deprecated since 2016.
+archived: Weinre has been deprecated since 2016.
---
### Usage