About
+ + + + + + +About
- https://github.com/angular/angular-seed @@ -251,48 +298,295 @@ gtag('config','UA-106902774-1'); }); +
diff --git a/101.html b/101.html index 1128cf51f..1e29d43f4 100644 --- a/101.html +++ b/101.html @@ -33,8 +33,8 @@ - - + + @@ -99,11 +99,11 @@ gtag('config','UA-106902774-1'); @@ -706,7 +706,7 @@ function n(n,t,e){n.addEventListener?n.addEventListener(t,e):n.attachEvent("on"+ },{}],"eoMl":[function(require,module,exports) { "use strict";var e=u(require("./wrapify")),d=u(require("dom101/add-class")),t=u(require("dom101/on"));function u(e){return e&&e.__esModule?e:{default:e}}var a,o=document.querySelector("[data-js-main-body]");function r(){a||((0,d.default)(document.documentElement,"LoadDone"),a=!0)}o&&((0,e.default)(o),(0,d.default)(o,"-wrapified")),(0,t.default)(window,"load",r),setTimeout(r,5e3); },{"./wrapify":"hE9p","dom101/add-class":"G20n","dom101/on":"DJ2P"}]},{},["eoMl"], null) - + diff --git a/404.html b/404.html index be8f2d0c4..67dc9f94d 100644 --- a/404.html +++ b/404.html @@ -33,8 +33,8 @@ - - + + @@ -99,11 +99,11 @@ gtag('config','UA-106902774-1'); @@ -170,7 +170,7 @@ function n(n,t,e){n.addEventListener?n.addEventListener(t,e):n.attachEvent("on"+ },{}],"eoMl":[function(require,module,exports) { "use strict";var e=u(require("./wrapify")),d=u(require("dom101/add-class")),t=u(require("dom101/on"));function u(e){return e&&e.__esModule?e:{default:e}}var a,o=document.querySelector("[data-js-main-body]");function r(){a||((0,d.default)(document.documentElement,"LoadDone"),a=!0)}o&&((0,e.default)(o),(0,d.default)(o,"-wrapified")),(0,t.default)(window,"load",r),setTimeout(r,5e3); },{"./wrapify":"hE9p","dom101/add-class":"G20n","dom101/on":"DJ2P"}]},{},["eoMl"], null) - + diff --git a/absinthe.html b/absinthe.html index 248eadb45..db7a6fb59 100644 --- a/absinthe.html +++ b/absinthe.html @@ -33,8 +33,8 @@ - - + + @@ -103,11 +103,11 @@ gtag('config','UA-106902774-1'); @@ -573,7 +573,7 @@ function n(n,t,e){n.addEventListener?n.addEventListener(t,e):n.attachEvent("on"+ },{}],"eoMl":[function(require,module,exports) { "use strict";var e=u(require("./wrapify")),d=u(require("dom101/add-class")),t=u(require("dom101/on"));function u(e){return e&&e.__esModule?e:{default:e}}var a,o=document.querySelector("[data-js-main-body]");function r(){a||((0,d.default)(document.documentElement,"LoadDone"),a=!0)}o&&((0,e.default)(o),(0,d.default)(o,"-wrapified")),(0,t.default)(window,"load",r),setTimeout(r,5e3); },{"./wrapify":"hE9p","dom101/add-class":"G20n","dom101/on":"DJ2P"}]},{},["eoMl"], null) - + diff --git a/activeadmin.html b/activeadmin.html index 341c877c6..8a2bd672b 100644 --- a/activeadmin.html +++ b/activeadmin.html @@ -33,8 +33,8 @@ - - + + @@ -99,11 +99,11 @@ gtag('config','UA-106902774-1'); @@ -572,7 +572,7 @@ function n(n,t,e){n.addEventListener?n.addEventListener(t,e):n.attachEvent("on"+ },{}],"eoMl":[function(require,module,exports) { "use strict";var e=u(require("./wrapify")),d=u(require("dom101/add-class")),t=u(require("dom101/on"));function u(e){return e&&e.__esModule?e:{default:e}}var a,o=document.querySelector("[data-js-main-body]");function r(){a||((0,d.default)(document.documentElement,"LoadDone"),a=!0)}o&&((0,e.default)(o),(0,d.default)(o,"-wrapified")),(0,t.default)(window,"load",r),setTimeout(r,5e3); },{"./wrapify":"hE9p","dom101/add-class":"G20n","dom101/on":"DJ2P"}]},{},["eoMl"], null) - + diff --git a/adb.html b/adb.html index ca3c1635e..5b7073a01 100644 --- a/adb.html +++ b/adb.html @@ -33,8 +33,8 @@ - - + + @@ -99,11 +99,11 @@ gtag('config','UA-106902774-1'); @@ -666,7 +666,7 @@ function n(n,t,e){n.addEventListener?n.addEventListener(t,e):n.attachEvent("on"+ },{}],"eoMl":[function(require,module,exports) { "use strict";var e=u(require("./wrapify")),d=u(require("dom101/add-class")),t=u(require("dom101/on"));function u(e){return e&&e.__esModule?e:{default:e}}var a,o=document.querySelector("[data-js-main-body]");function r(){a||((0,d.default)(document.documentElement,"LoadDone"),a=!0)}o&&((0,e.default)(o),(0,d.default)(o,"-wrapified")),(0,t.default)(window,"load",r),setTimeout(r,5e3); },{"./wrapify":"hE9p","dom101/add-class":"G20n","dom101/on":"DJ2P"}]},{},["eoMl"], null) - + diff --git a/analytics.html b/analytics.html index 518d70264..cc3bc010c 100644 --- a/analytics.html +++ b/analytics.html @@ -33,8 +33,8 @@ - - + + @@ -99,11 +99,11 @@ gtag('config','UA-106902774-1'); @@ -458,7 +458,7 @@ function n(n,t,e){n.addEventListener?n.addEventListener(t,e):n.attachEvent("on"+ },{}],"eoMl":[function(require,module,exports) { "use strict";var e=u(require("./wrapify")),d=u(require("dom101/add-class")),t=u(require("dom101/on"));function u(e){return e&&e.__esModule?e:{default:e}}var a,o=document.querySelector("[data-js-main-body]");function r(){a||((0,d.default)(document.documentElement,"LoadDone"),a=!0)}o&&((0,e.default)(o),(0,d.default)(o,"-wrapified")),(0,t.default)(window,"load",r),setTimeout(r,5e3); },{"./wrapify":"hE9p","dom101/add-class":"G20n","dom101/on":"DJ2P"}]},{},["eoMl"], null) - + diff --git a/analytics.js.html b/analytics.js.html index f31194ca1..0f929503a 100644 --- a/analytics.js.html +++ b/analytics.js.html @@ -33,8 +33,8 @@ - - + + @@ -99,11 +99,11 @@ gtag('config','UA-106902774-1'); @@ -471,7 +471,7 @@ function n(n,t,e){n.addEventListener?n.addEventListener(t,e):n.attachEvent("on"+ },{}],"eoMl":[function(require,module,exports) { "use strict";var e=u(require("./wrapify")),d=u(require("dom101/add-class")),t=u(require("dom101/on"));function u(e){return e&&e.__esModule?e:{default:e}}var a,o=document.querySelector("[data-js-main-body]");function r(){a||((0,d.default)(document.documentElement,"LoadDone"),a=!0)}o&&((0,e.default)(o),(0,d.default)(o,"-wrapified")),(0,t.default)(window,"load",r),setTimeout(r,5e3); },{"./wrapify":"hE9p","dom101/add-class":"G20n","dom101/on":"DJ2P"}]},{},["eoMl"], null) - + diff --git a/angularjs.html b/angularjs.html index 9089733e7..6a9d0e485 100644 --- a/angularjs.html +++ b/angularjs.html @@ -1,7 +1,7 @@ - -
- + + + @@ -33,8 +33,8 @@ - - + + @@ -89,25 +89,26 @@ gtag('config','UA-106902774-1'); - + - - - - - - --
- Devhints.io cheatsheets is a collection of cheatsheets I've written over the years. - Suggestions and corrections? Send them in. - - I'm Rico Sta. Cruz. - Check out my Today I learned blog for more. -
- - - --
+ +-
$ sudo mkdir /etc/ansible
@@ -178,7 +231,9 @@ $ sudo vim /etc/ansible/hosts
$ ansible-playbook playbook.yml
-Tasks
+Playbook files
+
+Tasks
- hosts: all
user: root
@@ -199,7 +254,7 @@ handlers:
- include: db.yml user=timmy
-Handlers
+Handlers
handlers:
- name: start apache2
@@ -212,7 +267,7 @@ tasks:
- start apache2
-Vars
+Vars
- host: lol
vars_files:
@@ -225,7 +280,7 @@ tasks:
only_if: "$vm == 0"
-Roles
+Roles
- host: xxx
roles:
@@ -256,56 +311,268 @@ tasks:
local_home: "{{ lookup('env','HOME') }}"
-References
-
+ - Devhints.io cheatsheets is a collection of cheatsheets I've written over the years. - Suggestions and corrections? Send them in. - - I'm Rico Sta. Cruz. - Check out my Today I learned blog for more. -
- - - --
+ +-
Arel is an SQL abstraction library built into Ruby on Rails.
+ + + +users = Arel::Table.new(:users)
users = User.arel_table # ActiveRecord model
@@ -266,54 +321,295 @@ this_month = photos_with_credits.where(photos[:created_at].gteq(Date.today.be
recent_photos = photos_with_credits.where(photos[:created_at].gteq(Date.today.beginning_of_month)).limit(5)
-- Devhints.io cheatsheets is a collection of cheatsheets I've written over the years. - Suggestions and corrections? Send them in. - - I'm Rico Sta. Cruz. - Check out my Today I learned blog for more. -
- - - --
+ +-
- Devhints.io cheatsheets is a collection of cheatsheets I've written over the years. - Suggestions and corrections? Send them in. - - I'm Rico Sta. Cruz. - Check out my Today I learned blog for more. -
- - - --
+ +-
See: https://circleci.com/docs/configuration
-## Customize the test machine
machine:
@@ -250,50 +303,295 @@ notify:
- url: https://someurl.com/hooks/circle
-
+ - Devhints.io cheatsheets is a collection of cheatsheets I've written over the years. - Suggestions and corrections? Send them in. - - I'm Rico Sta. Cruz. - Check out my Today I learned blog for more. -
- - - --
+ +-
ls [options] [paths]
| Switch | @@ -210,7 +259,7 @@ gtag('config','UA-106902774-1');
|---|
-R |
@@ -229,7 +278,7 @@ gtag('config','UA-106902774-1');
| Switch | @@ -270,16 +319,16 @@ gtag('config','UA-106902774-1');
|---|
tail [-F | -f | -r] [-bN | -cN | -nN] [file ...]
-f |
@@ -298,7 +347,7 @@ gtag('config','UA-106902774-1');
-bN |
@@ -321,14 +370,16 @@ gtag('config','UA-106902774-1');
-l |
@@ -339,7 +390,7 @@ gtag('config','UA-106902774-1');
-A |
@@ -374,7 +425,7 @@ gtag('config','UA-106902774-1');
-C fd |
@@ -385,7 +436,7 @@ gtag('config','UA-106902774-1');
-p prompt |
@@ -396,7 +447,7 @@ gtag('config','UA-106902774-1');
| Switch | @@ -427,7 +478,7 @@ gtag('config','UA-106902774-1');
|---|
-v |
@@ -444,14 +495,16 @@ gtag('config','UA-106902774-1');
... | wc [options]
--c |
@@ -472,23 +525,16 @@ gtag('config','UA-106902774-1');
perl -p -i -e 's/hello/HELLO/g' **/*
-
-
-grep [options] [pattern] [file ...]
-| Switch | @@ -567,48 +613,302 @@ gtag('config','UA-106902774-1'); fgrep => grep -F +
|---|
| Switch | \nDescription | \n
|---|---|
-1 | \n One entry per line | \n
-l | \n Long view | \n
-o | \n Long view (without groups) | \n
-C | \n Multicolumn (sorted horizontally) | \n
-x | \n Multicolumn (sorted vertically) | \n
-F | \n Add / after directories | \n
-G | \n Color | \n
-R | \n Recurse | \n
-a | \n Include hidden (dotfiles) | \n
-A | \n Include hidden (but not . and ..) | \n
| Switch | \nDescription | \n
|---|---|
-r | \n reverse order | \n
-S | \n sort by size | \n
-t | \n sort by time modified | \n
-u | \n sort by time accessed | \n
-U | \n sort by time created | \n
-c | \n sort by time status was changed | \n
-h | \n Human-readable size (3k) | \n
tail [-F | -f | -r] [-bN | -cN | -nN] [file ...]\n\n\n-f | \n follow | \n
-F | \n follow by filename (accounts for log rotation) | \n
-r | \n Reverse order | \n
-bN | \n N*512 bytes | \n
-cN | \n N bytes | \n
-nN | \n N lines | \n
+N | \n Start from line N | \n
sudo [options] <command>\n\n\n-l | \n List allowed commands | \n
-A | \n Use $SUDO_ASKPASS | \n
-b | \n Run in background | \n
-E | \n Preserve environment | \n
-H | \n use target’s $HOME | \n
-n | \n Don’t prompt for password | \n
-P | \n Preserve group vector | \n
-S | \n Read password from stdin | \n
-C fd | \n Close all open file descriptors | \n
-p prompt | \n Custom prompt (-p “%p password:”) | \n
| Switch | \nDescription | \n
|---|---|
-i [cmd] | \n Interactive shell without variables | \n
-s [cmd] | \n Interactive shell | \n
-u user | \n run as this user | \n
-g group | \n run as this group | \n
-v | \n revalidate timestamp for 5 mins | \n
-k | \n invalidate timestamp | \n
-K | \n just like -k | \n
... | wc [options]\n\n\n-c | \n Bytes | \n
-l | \n Lines | \n
-m | \n Characters (incl multi-byte) | \n
-w | \n Words | \n
perl -p -i -e 's/hello/HELLO/g' **/*\n\n\ngrep [options] [pattern] [file ...]\n\n\n| Switch | \nDescription | \n
|---|---|
-A num | \n Print num lines of training context | \n
-G | \n –basic-regexp (default) | \n
-E | \n –extended-regexp | \n
-P | \n –perl-regexp | \n
-f file | \n –file (Get patterns for file) | \n
-F | \n –fixed-strings | \n
-h | \n –no-filename | \n
-H | \n –with-filename | \n
-l | \n –files-with-matches (just print filenames) | \n
-L | \n –files-without-match | \n
-r, -R | \n –recursive | \n
-v | \n –invert-match | \n
-i | \n –ignore-case | \n
egrep => grep -E\nfgrep => grep -F\n",
+ "content_html": "ls [options] [paths]\n\n\n| Switch | \nDescription | \n
|---|---|
-1 | \n One entry per line | \n
-l | \n Long view | \n
-o | \n Long view (without groups) | \n
-C | \n Multicolumn (sorted horizontally) | \n
-x | \n Multicolumn (sorted vertically) | \n
-F | \n Add / after directories | \n
-G | \n Color | \n
-R | \n Recurse | \n
-a | \n Include hidden (dotfiles) | \n
-A | \n Include hidden (but not . and ..) | \n
| Switch | \nDescription | \n
|---|---|
-r | \n reverse order | \n
-S | \n sort by size | \n
-t | \n sort by time modified | \n
-u | \n sort by time accessed | \n
-U | \n sort by time created | \n
-c | \n sort by time status was changed | \n
-h | \n Human-readable size (3k) | \n
tail [-F | -f | -r] [-bN | -cN | -nN] [file ...]\n\n\n-f | \n follow | \n
-F | \n follow by filename (accounts for log rotation) | \n
-r | \n Reverse order | \n
-bN | \n N*512 bytes | \n
-cN | \n N bytes | \n
-nN | \n N lines | \n
+N | \n Start from line N | \n
sudo [options] <command>\n\n\n-l | \n List allowed commands | \n
-A | \n Use $SUDO_ASKPASS | \n
-b | \n Run in background | \n
-E | \n Preserve environment | \n
-H | \n use target’s $HOME | \n
-n | \n Don’t prompt for password | \n
-P | \n Preserve group vector | \n
-S | \n Read password from stdin | \n
-C fd | \n Close all open file descriptors | \n
-p prompt | \n Custom prompt (-p “%p password:”) | \n
| Switch | \nDescription | \n
|---|---|
-i [cmd] | \n Interactive shell without variables | \n
-s [cmd] | \n Interactive shell | \n
-u user | \n run as this user | \n
-g group | \n run as this group | \n
-v | \n revalidate timestamp for 5 mins | \n
-k | \n invalidate timestamp | \n
-K | \n just like -k | \n
... | wc [options]\n\n\n-c | \n Bytes | \n
-l | \n Lines | \n
-m | \n Characters (incl multi-byte) | \n
-w | \n Words | \n
grep [options] [pattern] [file ...]\n\n\n| Switch | \nDescription | \n
|---|---|
-A num | \n Print num lines of training context | \n
-G | \n –basic-regexp (default) | \n
-E | \n –extended-regexp | \n
-P | \n –perl-regexp | \n
-f file | \n –file (Get patterns for file) | \n
-F | \n –fixed-strings | \n
-h | \n –no-filename | \n
-H | \n –with-filename | \n
-l | \n –files-with-matches (just print filenames) | \n
-L | \n –files-without-match | \n
-r, -R | \n –recursive | \n
-v | \n –invert-match | \n
-i | \n –ignore-case | \n
egrep => grep -E\nfgrep => grep -F\n\n\nperl -p -i -e 's/hello/HELLO/g' **/*\n",
"intro_html": "",
"description_html": "",
"tags": null,
@@ -522,7 +522,7 @@
"url": "/commander.js",
"category": "JavaScript libraries",
"keywords": null,
- "content_html": "var cli = require('commander');\n\n\ncli\n .version(require('../package').version)\n .usage('[options] <command>')\n .option('-w, --words <n>', 'generate <n> words')\n .option('-i, --interval <n>', 'interval [1000]', 1000)\n .option('-s, --symbols', 'include symbols')\n .parse(process.argv);\n\n\n.on('--help', function() {\n console.log('');\n})\n\n\ncli.outputHelp();\ncli.args == [\"hello\"];\n\n\nprocess.exit(0);\n",
+ "content_html": "var cli = require('commander');\n\n\ncli\n .version(require('../package').version)\n .usage('[options] <command>')\n .option('-w, --words <n>', 'generate <n> words')\n .option('-i, --interval <n>', 'interval [1000]', 1000)\n .option('-s, --symbols', 'include symbols')\n .parse(process.argv);\n\n\n.on('--help', function() {\n console.log('');\n})\n\n\ncli.outputHelp();\ncli.args == [\"hello\"];\n\n\nprocess.exit(0);\n",
"intro_html": "",
"description_html": "",
"tags": null,
@@ -709,7 +709,7 @@
"url": "/devise",
"category": "Others",
"keywords": null,
- "content_html": "Devise is a flexible authentication \ngem.
\n\nRails 3: Add the following to your Gemfile
\n\ngem \"devise\"\ngem \"hpricot\"\ngem \"ruby_parser\"\n\n\nInstall devise in your project
\n\n$ rails generate devise:install\n\n\nGenerate devise for your model
\n\n$ rails generate devise MODEL\n$ rake db:migrate\n\n\n(Optional) Generate devise views
\n\n$ rails generate devise:views\n\n\nuser_signed_in?\ncurrent_user\nuser_session\ndestroy_user_session_path (Logout)\nnew_user_session_path (Login)\nedit_user_registration_path (Edit registration)\nnew_user_registration_path (Register new user)\n\n\nbefore_filter :authenticate_user!\n\n\nclass User < ActiveRecord::Base\n devise :database_authenticatable,\n :registerable,\n :confirmable,\n :recoverable,\n :rememberable,\n :trackable,\n :validatable\nend\n\n\ncreate_table :users do |t|\n t.database_authenticatable\n t.confirmable\n t.recoverable\n t.rememberable\n t.trackable\n t.timestamps\nend\n\n\nunauthenticated do\n root :to => 'home#index'\nend\n\nauthenticated do\n root :to => 'dashboard#index'\nend\n\n\nas :user do\n get 'sign_in', :to => 'devise/sessions#new'\nend\n\n\ndevise_for :users\n\n # Session routes for Authenticatable (default)\n new_user_session GET /users/sign_in {:controller=>\"devise/sessions\", :action=>\"new\"}\n user_session POST /users/sign_in {:controller=>\"devise/sessions\", :action=>\"create\"}\n destroy_user_session GET /users/sign_out {:controller=>\"devise/sessions\", :action=>\"destroy\"}\n \n # Password routes for Recoverable, if User model has :recoverable configured\n new_user_password GET /users/password/new(.:format) {:controller=>\"devise/passwords\", :action=>\"new\"}\n edit_user_password GET /users/password/edit(.:format) {:controller=>\"devise/passwords\", :action=>\"edit\"}\n user_password PUT /users/password(.:format) {:controller=>\"devise/passwords\", :action=>\"update\"}\n POST /users/password(.:format) {:controller=>\"devise/passwords\", :action=>\"create\"}\n \n # Confirmation routes for Confirmable, if User model has :confirmable configured\n new_user_confirmation GET /users/confirmation/new(.:format) {:controller=>\"devise/confirmations\", :action=>\"new\"}\n user_confirmation GET /users/confirmation(.:format) {:controller=>\"devise/confirmations\", :action=>\"show\"}\n POST /users/confirmation(.:format) {:controller=>\"devise/confirmations\", :action=>\"create\"}\n\n\ndevise_for :users,\n :path => \"usuarios\",\n :path_names => {\n :sign_in => 'login',\n :sign_out => 'logout',\n :password => 'secret',\n :confirmation => 'verification',\n :unlock => 'unblock',\n :registration => 'register',\n :sign_up => 'cmon_let_me_in' }\n\n\ninclude Devise::TestHelpers\nhttps://github.com/plataformatec/devise/blob/1094ba65aac1d37713f2cba71f9edad76b5ca274/lib/devise/test_helpers.rb\n\nsign_in @user\nsign_out @user\n",
+ "content_html": "Devise is a flexible authentication \ngem.
\n\n\n\nRails 3: Add the following to your Gemfile
\n\ngem \"devise\"\ngem \"hpricot\"\ngem \"ruby_parser\"\n\n\nInstall devise in your project
\n\n$ rails generate devise:install\n\n\nGenerate devise for your model
\n\n$ rails generate devise MODEL\n$ rake db:migrate\n\n\n(Optional) Generate devise views
\n\n$ rails generate devise:views\n\n\nuser_signed_in?\ncurrent_user\nuser_session\ndestroy_user_session_path (Logout)\nnew_user_session_path (Login)\nedit_user_registration_path (Edit registration)\nnew_user_registration_path (Register new user)\n\n\nbefore_filter :authenticate_user!\n\n\nclass User < ActiveRecord::Base\n devise :database_authenticatable,\n :registerable,\n :confirmable,\n :recoverable,\n :rememberable,\n :trackable,\n :validatable\nend\n\n\ncreate_table :users do |t|\n t.database_authenticatable\n t.confirmable\n t.recoverable\n t.rememberable\n t.trackable\n t.timestamps\nend\n\n\nunauthenticated do\n root :to => 'home#index'\nend\n\nauthenticated do\n root :to => 'dashboard#index'\nend\n\n\nas :user do\n get 'sign_in', :to => 'devise/sessions#new'\nend\n\n\ndevise_for :users\n\n # Session routes for Authenticatable (default)\n new_user_session GET /users/sign_in {:controller=>\"devise/sessions\", :action=>\"new\"}\n user_session POST /users/sign_in {:controller=>\"devise/sessions\", :action=>\"create\"}\n destroy_user_session GET /users/sign_out {:controller=>\"devise/sessions\", :action=>\"destroy\"}\n \n # Password routes for Recoverable, if User model has :recoverable configured\n new_user_password GET /users/password/new(.:format) {:controller=>\"devise/passwords\", :action=>\"new\"}\n edit_user_password GET /users/password/edit(.:format) {:controller=>\"devise/passwords\", :action=>\"edit\"}\n user_password PUT /users/password(.:format) {:controller=>\"devise/passwords\", :action=>\"update\"}\n POST /users/password(.:format) {:controller=>\"devise/passwords\", :action=>\"create\"}\n \n # Confirmation routes for Confirmable, if User model has :confirmable configured\n new_user_confirmation GET /users/confirmation/new(.:format) {:controller=>\"devise/confirmations\", :action=>\"new\"}\n user_confirmation GET /users/confirmation(.:format) {:controller=>\"devise/confirmations\", :action=>\"show\"}\n POST /users/confirmation(.:format) {:controller=>\"devise/confirmations\", :action=>\"create\"}\n\n\ndevise_for :users,\n :path => \"usuarios\",\n :path_names => {\n :sign_in => 'login',\n :sign_out => 'logout',\n :password => 'secret',\n :confirmation => 'verification',\n :unlock => 'unblock',\n :registration => 'register',\n :sign_up => 'cmon_let_me_in' }\n\n\ninclude Devise::TestHelpers\n\nsign_in @user\nsign_out @user\n\n\n",
"intro_html": "",
"description_html": "",
"tags": null,
@@ -808,7 +808,7 @@
"url": "/elixir-metaprogramming",
"category": "Elixir",
"keywords": null,
- "content_html": "Most of these magic is defined in Kernel.SpecialForms.
\n\n__DIR__ # current dir\n__MODULE__ # current module\n__CALLER__ # caller of the function\n\n\n__ENV__Map.keys(__ENV__)\n[:__struct__, :aliases, :context, :context_modules, :export_vars, :file,\n :function, :functions, :lexical_tracker, :line, :macro_aliases, :macros,\n :module, :requires, :vars]\n\n\n__CALLER__.module |> Module.definitions_in |> IO.inspect\n\n\napply(Enum, :reverse, [[1, 2, 3]])\n",
+ "content_html": "Most of these magic is defined in Kernel.SpecialForms.
\n\n__DIR__ # current dir\n__MODULE__ # current module\n__CALLER__ # caller of the function\n\n\n__ENV__Map.keys(__ENV__)\n[:__struct__, :aliases, :context, :context_modules, :export_vars, :file,\n :function, :functions, :lexical_tracker, :line, :macro_aliases, :macros,\n :module, :requires, :vars]\n\n\n__CALLER__.module |> Module.definitions_in |> IO.inspect\n\n\napply(Enum, :reverse, [[1, 2, 3]])\n",
"intro_html": "",
"description_html": "",
"tags": null,
@@ -1020,7 +1020,7 @@
"content_html": "line-height in <input type='button'>Console.count()box-shadowwindow.devicePixelRatioontouchstart<input type='number'><input type='color'>FillPaint and StrokePaint<iframe sandbox=...> (docs)<audio played> (and <video>)<source media=...>column-fill (docs)Map and Setbackground-position extended syntax:invalidrotate(0.5turn))text-align-last (docs)element.outerHTML (docs)text-size-adjust (docs)<bdi> elementfont-stretchtext-overflownavigator.doNotTracktext-overflow: ellipsishttp:// prefix in address barwindow.matchMediasetTimeout and setInterval clamped to 1000msmozRequestAnimationFrame<video buffered><script async>Dispatchers receive actions that get dispatched to its listeners.
\nStores are objects that store data, usually changed from a dispatcher listener.
\nViews are React components that listen to Store changes, or emit actions to the dispatcher.
\nA dispatcher emits events (.dispatch()) to its listeners (.register(fn)).
var Dispatcher = require('flux').Dispatcher;\n\nd = new Dispatcher();\n\n// send\nd.dispatch({ action: 'edit', ... };\n\n// receive\ntoken = d.register(function (payload) {\n payload.action === 'edit'\n})\n\n\nWith multiple listeners, you can ensure one is fired after another using .waitFor().
token1 = d.register(...);\n\ntoken2 = d.register(function (payload) {\n\n // ensure receiver 1 is fired before this\n d.waitFor([ token1 ]);\n \n // process here\n})\n\n\nObject.assign is the preferred way to subclass Dispatcher (think $.extend).
\nYou can also make action creators, which are shortcuts for dispatch().
var Dispatcher = require('flux').Dispatcher;\nvar assign = require('object-assign');\n\nvar AppDispatcher = assign({}, Dispatcher.prototype, {\n\n // action creator\n handleViewAction(action) {\n this.dispatch({\n source: 'VIEW_ACTION',\n action: action\n })\n } \n\n})\n\n\nStores are just like objects.
\n\nvar TodoStore = { list: [] };\n\n\nSometimes they’re eventemitters, too. Usually it’s used to emit change events for views to pick up.
var TodoStore = assign({}, EventEmitter.prototype, {\n ...\n});\n\nTodoStore.emit('change');\nTodoStore.on('change', function () { ... });\n\n\nLogic can sometimes belong in stores.
\n\n{\n isAllActive() {\n return this.list.every(item => item.active);\n }\n}\n\n\nMake a Dispatcher and Stores.
\n\nd = new Dispatcher();\nTabStore = { tab: 'home' };\n\n\nDispatch events to alter the store.
\n\nd.dispatch({ action: 'tab.change', tab: 'timeline' });\n\nd.register(function (data) {\n if (data.action === 'tab.change') {\n TabStore.tab = data.tab;\n }\n});\n\n\nViews (React Components) can listen to Dispatchers.
\n\nvar TodoApp = React.createClass({\n\n componentDidMount() {\n this.token = AppDispatcher.register((payload) => {\n switch (payload.action) {\n case 'tab.change':\n this.render();\n // ...\n }\n });\n },\n \n componentDidUnmount() {\n AppDispatcher.unregister(this.token);\n }\n \n});\n\n\nOr to Stores’s change events.
{\n componentDidMount() {\n TodoStore.on('change', this.onChange);\n },\n \n componentDidUnmount() {\n TodoState.removeListener('change', this.onChange);\n },\n \n onChange(data) {\n // ...\n }\n}\n\n\nFlux is an architecture for building client-side web applications.
\n\nDispatchers receive actions that get dispatched to its listeners.
\nStores are objects that store data, usually changed from a dispatcher listener.
\nViews are React components that listen to Store changes, or emit actions to the dispatcher.
\nA dispatcher emits events (.dispatch()) to its listeners (.register(fn)).
var Dispatcher = require('flux').Dispatcher;\n\nd = new Dispatcher();\n\n// send\nd.dispatch({ action: 'edit', ... };\n\n// receive\ntoken = d.register(function (payload) {\n payload.action === 'edit'\n})\n\n\nWith multiple listeners, you can ensure one is fired after another using .waitFor().
token1 = d.register(...);\n\ntoken2 = d.register(function (payload) {\n\n // ensure receiver 1 is fired before this\n d.waitFor([ token1 ]);\n \n // process here\n})\n\n\nObject.assign is the preferred way to subclass Dispatcher (think $.extend).
\nYou can also make action creators, which are shortcuts for dispatch().
var Dispatcher = require('flux').Dispatcher;\nvar assign = require('object-assign');\n\nvar AppDispatcher = assign({}, Dispatcher.prototype, {\n\n // action creator\n handleViewAction(action) {\n this.dispatch({\n source: 'VIEW_ACTION',\n action: action\n })\n } \n\n})\n\n\nStores are just like objects.
\n\nvar TodoStore = { list: [] };\n\n\nSometimes they’re eventemitters, too. Usually it’s used to emit change events for views to pick up.
var TodoStore = assign({}, EventEmitter.prototype, {\n ...\n});\n\nTodoStore.emit('change');\nTodoStore.on('change', function () { ... });\n\n\nLogic can sometimes belong in stores.
\n\n{\n isAllActive() {\n return this.list.every(item => item.active);\n }\n}\n\n\nMake a Dispatcher and Stores.
\n\nd = new Dispatcher();\nTabStore = { tab: 'home' };\n\n\nDispatch events to alter the store.
\n\nd.dispatch({ action: 'tab.change', tab: 'timeline' });\n\nd.register(function (data) {\n if (data.action === 'tab.change') {\n TabStore.tab = data.tab;\n }\n});\n\n\nViews (React Components) can listen to Dispatchers.
\n\nvar TodoApp = React.createClass({\n\n componentDidMount() {\n this.token = AppDispatcher.register((payload) => {\n switch (payload.action) {\n case 'tab.change':\n this.render();\n // ...\n }\n });\n },\n \n componentDidUnmount() {\n AppDispatcher.unregister(this.token);\n }\n \n});\n\n\nOr to Stores’s change events.
{\n componentDidMount() {\n TodoStore.on('change', this.onChange);\n },\n \n componentDidUnmount() {\n TodoState.removeListener('change', this.onChange);\n },\n \n onChange(data) {\n // ...\n }\n}\n\n\nHEAD^ # 1 commit before head\nHEAD^^ # 2 commits before head\nHEAD~5 # 5 commits before head\n\n\n# create a new branch\n git checkout -b $branchname\n git push origin $branchname --set-upstream\n\n# get a remote branch\n git fetch origin\n git checkout --track origin/$branchname\n\n# delete local remote-tracking branches (lol)\n git remote prune origin\n\n# list merged branches\n git branch -a --merged\n\n# delete remote branch\n git push origin :$branchname\n \n# go back to previous branch\n git checkout -\n\n\n# Rebase your changes on top of the remote master\n git pull --rebase upstream master\n \n# Squash multiple commits into one for a cleaner git log\n# (on the following screen change the word pick to either 'f' or 's')\n git rebase -i $commit_ref\n\n\n# Import .gitmodules\n git submodule init\n\n# Clone missing submodules, and checkout commits\n git submodule update --init --recursive\n\n# Update remote URLs in .gitmodules\n# (Use when you changed remotes in submodules)\n git submodule sync\n\n\ngit diff --stat\napp/a.txt | 2 +-\napp/b.txt | 8 ++----\n2 files changed, 10 insertions(+), 84 deletions(-)\n\n\ngit diff --summary\n\n\n--oneline\n e11e9f9 Commit message here\n\n--decorate\n shows \"(origin/master)\"\n\n--graph\n shows graph lines\n\n--date=relative\n \"2 hours ago\"\n\n\ngit rebase 76acada^\n\n\n# get current sha1 (?)\n git show-ref HEAD -s\n\n# show single commit info\n git log -1 f5a960b5\n\n# Go back up to root directory\n cd \"$(git rev-parse --show-top-level)\"\n\n\n $ git shortlog\n $ git shortlog HEAD~20.. # last 20 commits\n\n James Dean (1):\n Commit here\n Commit there\n\n Frank Sinatra (5):\n Another commit\n This other commit\n\n\ngit bisect start HEAD HEAD~6\ngit bisect run npm test\ngit checkout refs/bisect/bad # this is where it screwed up\ngit bisect reset\n\n\ngit bisect start\ngit bisect good # current version is good\n\ngit checkout HEAD~8\nnpm test # see if it's good\ngit bisect bad # current version is bad\n\ngit bisect reset # abort\n\n\ngit log --grep=\"fixes things\" # search in commit messages\ngit log -S\"window.alert\" # search in code\ngit log -G\"foo.*\" # search in code (regex)\n\n\ngit config set user.signingkey <GPG KEY ID> # Sets GPG key to use for signing\n\ngit commit -m \"Implement feature Y\" --gpg-sign # Or -S, GPG signs commit\n\ngit config set commit.gpgsign true # Sign commits by default\ngit commit -m \"Implement feature Y\" --no-gpg-sign # Do not sign\n",
+ "content_html": "HEAD^ # 1 commit before head\nHEAD^^ # 2 commits before head\nHEAD~5 # 5 commits before head\n\n\n# create a new branch\n git checkout -b $branchname\n git push origin $branchname --set-upstream\n\n# get a remote branch\n git fetch origin\n git checkout --track origin/$branchname\n\n# delete local remote-tracking branches (lol)\n git remote prune origin\n\n# list merged branches\n git branch -a --merged\n\n# delete remote branch\n git push origin :$branchname\n \n# go back to previous branch\n git checkout -\n\n\n# Rebase your changes on top of the remote master\n git pull --rebase upstream master\n \n# Squash multiple commits into one for a cleaner git log\n# (on the following screen change the word pick to either 'f' or 's')\n git rebase -i $commit_ref\n\n\n# Import .gitmodules\n git submodule init\n\n# Clone missing submodules, and checkout commits\n git submodule update --init --recursive\n\n# Update remote URLs in .gitmodules\n# (Use when you changed remotes in submodules)\n git submodule sync\n\n\ngit diff --stat\napp/a.txt | 2 +-\napp/b.txt | 8 ++----\n2 files changed, 10 insertions(+), 84 deletions(-)\n\n\ngit diff --summary\n\n\n--oneline\n e11e9f9 Commit message here\n\n--decorate\n shows \"(origin/master)\"\n\n--graph\n shows graph lines\n\n--date=relative\n \"2 hours ago\"\n\n\ngit rebase 76acada^\n\n\n# get current sha1 (?)\n git show-ref HEAD -s\n\n# show single commit info\n git log -1 f5a960b5\n\n# Go back up to root directory\n cd \"$(git rev-parse --show-top-level)\"\n\n\n $ git shortlog\n $ git shortlog HEAD~20.. # last 20 commits\n\n James Dean (1):\n Commit here\n Commit there\n\n Frank Sinatra (5):\n Another commit\n This other commit\n\n\ngit bisect start HEAD HEAD~6\ngit bisect run npm test\ngit checkout refs/bisect/bad # this is where it screwed up\ngit bisect reset\n\n\ngit bisect start\ngit bisect good # current version is good\n\ngit checkout HEAD~8\nnpm test # see if it's good\ngit bisect bad # current version is bad\n\ngit bisect reset # abort\n\n\ngit log --grep=\"fixes things\" # search in commit messages\ngit log -S\"window.alert\" # search in code\ngit log -G\"foo.*\" # search in code (regex)\n\n\ngit config set user.signingkey <GPG KEY ID> # Sets GPG key to use for signing\n\ngit commit -m \"Implement feature Y\" --gpg-sign # Or -S, GPG signs commit\n\ngit config set commit.gpgsign true # Sign commits by default\ngit commit -m \"Implement feature Y\" --no-gpg-sign # Do not sign\n",
"intro_html": "",
"description_html": "",
"tags": null,
@@ -1281,10 +1281,10 @@
"url": "/gulp",
"category": "JavaScript libraries",
"keywords": null,
- "content_html": "gulp-notify
\n// gulpfile.js\n// Load plugins\nvar gulp = require('gulp'),\n sass = require('gulp-ruby-sass'),\n autoprefixer = require('gulp-autoprefixer'),\n minifycss = require('gulp-minify-css'),\n jshint = require('gulp-jshint'),\n uglify = require('gulp-uglify'),\n imagemin = require('gulp-imagemin'),\n rename = require('gulp-rename'),\n clean = require('gulp-clean'),\n concat = require('gulp-concat'),\n notify = require('gulp-notify'),\n cache = require('gulp-cache'),\n livereload = require('gulp-livereload'),\n lr = require('tiny-lr'),\n server = lr();\n\n// Styles\ngulp.task('styles', function() {\n return gulp.src('src/styles/main.scss')\n .pipe(sass({ style: 'expanded', }))\n .pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))\n .pipe(gulp.dest('dist/styles'))\n .pipe(rename({ suffix: '.min' }))\n .pipe(minifycss())\n .pipe(livereload(server))\n .pipe(gulp.dest('dist/styles'))\n .pipe(notify({ message: 'Styles task complete' }));\n});\n\n// Scripts\ngulp.task('scripts', function() {\n return gulp.src('src/scripts/**/*.js')\n .pipe(jshint('.jshintrc'))\n .pipe(jshint.reporter('default'))\n .pipe(concat('main.js'))\n .pipe(gulp.dest('dist/scripts'))\n .pipe(rename({ suffix: '.min' }))\n .pipe(uglify())\n .pipe(livereload(server))\n .pipe(gulp.dest('dist/scripts'))\n .pipe(notify({ message: 'Scripts task complete' }));\n});\n\n// Images\ngulp.task('images', function() {\n return gulp.src('src/images/**/*')\n .pipe(cache(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true })))\n .pipe(livereload(server))\n .pipe(gulp.dest('dist/images'))\n .pipe(notify({ message: 'Images task complete' }));\n});\n\n// Clean\ngulp.task('clean', function() {\n return gulp.src(['dist/styles', 'dist/scripts', 'dist/images'], {read: false})\n .pipe(clean());\n});\n\n// Default task\ngulp.task('default', ['clean'], function() {\n gulp.start('styles', 'scripts', 'images');\n});\n\n// Watch\ngulp.task('watch', function() {\n\n // Listen on port 35729\n server.listen(35729, function (err) {\n if (err) {\n return console.log(err)\n };\n\n // Watch .scss files\n gulp.watch('src/styles/**/*.scss', ['styles']);\n\n // Watch .js files\n gulp.watch('src/scripts/**/*.js', ['scripts']);\n\n // Watch image files\n gulp.watch('src/images/**/*', ['images']);\n\n });\n\n});\n\n\nhttps://github.com/gulpjs/gulp/blob/master/docs/getting-started.md#getting-started
\n\nvar lr = require('tiny-lr')();\n\nfunction notify (lr, root) {\n return function (event) {\n var fname = require('path').relative(root, event.path);\n lr.changed({ body: { files: [ fname ] }});\n };\n}\n\ngulp.task('livereload', function () {\n lr.listen(35729)\n gulp.watch('public/**/*', notify(lr, __dirname+'/public'));\n});\n\n// Express\napp.use(require('connect-livereload')())\n<!-- livereload --><script>document.write('<script src=\"'+(location.protocol||'http:')+'//'+(location.hostname||'localhost')+':35729/livereload.js?snipver=1\"><\\/scr'+'ipt>')</script>\n",
+ "content_html": "gulp-notify
\n// gulpfile.js\n// Load plugins\nvar gulp = require('gulp'),\n sass = require('gulp-ruby-sass'),\n autoprefixer = require('gulp-autoprefixer'),\n minifycss = require('gulp-minify-css'),\n jshint = require('gulp-jshint'),\n uglify = require('gulp-uglify'),\n imagemin = require('gulp-imagemin'),\n rename = require('gulp-rename'),\n clean = require('gulp-clean'),\n concat = require('gulp-concat'),\n notify = require('gulp-notify'),\n cache = require('gulp-cache'),\n livereload = require('gulp-livereload'),\n lr = require('tiny-lr'),\n server = lr();\n\n// Styles\ngulp.task('styles', function() {\n return gulp.src('src/styles/main.scss')\n .pipe(sass({ style: 'expanded', }))\n .pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))\n .pipe(gulp.dest('dist/styles'))\n .pipe(rename({ suffix: '.min' }))\n .pipe(minifycss())\n .pipe(livereload(server))\n .pipe(gulp.dest('dist/styles'))\n .pipe(notify({ message: 'Styles task complete' }));\n});\n\n// Scripts\ngulp.task('scripts', function() {\n return gulp.src('src/scripts/**/*.js')\n .pipe(jshint('.jshintrc'))\n .pipe(jshint.reporter('default'))\n .pipe(concat('main.js'))\n .pipe(gulp.dest('dist/scripts'))\n .pipe(rename({ suffix: '.min' }))\n .pipe(uglify())\n .pipe(livereload(server))\n .pipe(gulp.dest('dist/scripts'))\n .pipe(notify({ message: 'Scripts task complete' }));\n});\n\n// Images\ngulp.task('images', function() {\n return gulp.src('src/images/**/*')\n .pipe(cache(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true })))\n .pipe(livereload(server))\n .pipe(gulp.dest('dist/images'))\n .pipe(notify({ message: 'Images task complete' }));\n});\n\n// Clean\ngulp.task('clean', function() {\n return gulp.src(['dist/styles', 'dist/scripts', 'dist/images'], {read: false})\n .pipe(clean());\n});\n\n// Default task\ngulp.task('default', ['clean'], function() {\n gulp.start('styles', 'scripts', 'images');\n});\n\n// Watch\ngulp.task('watch', function() {\n\n // Listen on port 35729\n server.listen(35729, function (err) {\n if (err) {\n return console.log(err)\n };\n\n // Watch .scss files\n gulp.watch('src/styles/**/*.scss', ['styles']);\n\n // Watch .js files\n gulp.watch('src/scripts/**/*.js', ['scripts']);\n\n // Watch image files\n gulp.watch('src/images/**/*', ['images']);\n\n });\n\n});\n\n\nhttps://github.com/gulpjs/gulp/blob/master/docs/getting-started.md#getting-started
\n\nvar lr = require('tiny-lr')();\n\nfunction notify (lr, root) {\n return function (event) {\n var fname = require('path').relative(root, event.path);\n lr.changed({ body: { files: [ fname ] }});\n };\n}\n\ngulp.task('livereload', function () {\n lr.listen(35729)\n gulp.watch('public/**/*', notify(lr, __dirname+'/public'));\n});\n\n// Express\napp.use(require('connect-livereload')())\n<!-- livereload --><script>document.write('<script src=\"'+(location.protocol||'http:')+'//'+(location.hostname||'localhost')+':35729/livereload.js?snipver=1\"><\\/scr'+'ipt>')</script>\n",
"intro_html": "",
"description_html": "",
- "tags": null,
+ "tags": ["Archived"],
"updated": null
},{
"id": "haml",
@@ -1798,7 +1798,7 @@
"url": "/ledger-examples",
"category": "Ledger",
"keywords": null,
- "content_html": "Inspecting transactions:
\n\n# show me expenses for october (--period)\n ledger r Expenses -p oct\n\n# what's the most expensive? (--sorted)\n ledger r Expenses -S amount --tail 10\n\n# how much was spent on grocery? (--weekly, --monthly)\n ledger r Grocery\n ledger r Grocery -W\n ledger r Grocery -M\n\n# what did I spend my Mastercard on? (--period, --begin, --end)\n ledger r mastercard\n ledger r mastercard -p \"january\"\n ledger r mastercard -b 01/25 -e 01/31\n\n\nGraphing:
\n\n# Graph my bank account balance, monthly\n ledger r Savings -M\n\n# Graph my expenses, monthly (-n = --collapse)\n ledger r Expenses -M -n\n\n# ...what's the average per month?\n ledger r Expenses -M -n --average\n\n\nSimple:
\n\n# what did I do yesterday?\n# ..list transactions on this day\n ledger r -p 01/26\n ledger r -p yesterday\n\n\nSwitches:
\n\n# what's everything I got in USD? (--exchange)\n ledger b Assets -X USD\n",
+ "content_html": "# show me expenses for october (--period)\n ledger r Expenses -p oct\n\n# what's the most expensive? (--sorted)\n ledger r Expenses -S amount --tail 10\n\n# how much was spent on grocery? (--weekly, --monthly)\n ledger r Grocery\n ledger r Grocery -W\n ledger r Grocery -M\n\n# what did I spend my Mastercard on? (--period, --begin, --end)\n ledger r mastercard\n ledger r mastercard -p \"january\"\n ledger r mastercard -b 01/25 -e 01/31\n\n\n# Graph my bank account balance, monthly\n ledger r Savings -M\n\n# Graph my expenses, monthly (-n = --collapse)\n ledger r Expenses -M -n\n\n# ...what's the average per month?\n ledger r Expenses -M -n --average\n\n\n# what did I do yesterday?\n# ..list transactions on this day\n ledger r -p 01/26\n ledger r -p yesterday\n\n\n# what's everything I got in USD? (--exchange)\n ledger b Assets -X USD\n",
"intro_html": "",
"description_html": "",
"tags": null,
@@ -1809,7 +1809,7 @@
"url": "/ledger-format",
"category": "Ledger",
"keywords": null,
- "content_html": "2015/01/01 Pay rent\n Assets:Savings -$300\n Expenses:Rent\n\n\n2015/01/01 * Pay rent ; tagname:\n^ ^ ^\nDate Flag Description ^ comment/tag\n\n\n2015/01/01 Pay rent\n Assets:Savings -$300 = $1200 ; assert there's $1200 left after\n Expenses:Rent\n\nFlags:
\n\n* cleared\n! pending\n\n\nOnly relevant with --strict or --pedantic
account Expenses:Food\n note This account is all about the chicken!\n alias food\n payee ^(KFC|Popeyes)$\n check commodity == \"$\"\n assert commodity == \"$\"\n eval print(\"Hello!\")\n default\n\n\nD $1,000.00 ; set default commodity\n\nalias Cash = Assets:Cash\n\nY2015 ; set default year (you can use 01/25 as date after)\n\n\naccount Home\ninclude home.journal\nend\n",
+ "content_html": "2015/01/01 Pay rent\n Assets:Savings -$300\n Expenses:Rent\n\n\n2015/01/01 * Pay rent ; tagname:\n^ ^ ^\nDate Flag Description ^ comment/tag\n\n\n2015/01/01 Pay rent\n Assets:Savings -$300 = $1200 ; assert there's $1200 left after\n Expenses:Rent\n\nFlags:
\n\n* cleared\n! pending\n\n\nOnly relevant with --strict or --pedantic
account Expenses:Food\n note This account is all about the chicken!\n alias food\n payee ^(KFC|Popeyes)$\n check commodity == \"$\"\n assert commodity == \"$\"\n eval print(\"Hello!\")\n default\n\n\nD $1,000.00 ; set default commodity\n\nalias Cash = Assets:Cash\n\nY2015 ; set default year (you can use 01/25 as date after)\n\n\naccount Home\ninclude home.journal\nend\n",
"intro_html": "",
"description_html": "",
"tags": null,
@@ -1820,7 +1820,7 @@
"url": "/ledger-periods",
"category": "Ledger",
"keywords": null,
- "content_html": "[INTERVAL] [BEGIN] [END]\n\n\nInterval:
\n\nevery day\nevery week\nevery month\nevery quarter\nevery year\nevery N days # N is any integer\nevery N weeks\nevery N months\nevery N quarters\nevery N years\ndaily\nweekly\nbiweekly\nmonthly\nbimonthly\nquarterly\nyearly\n\n\nBegin:
\n\nfrom <SPEC>\nsince <SPEC>\n\n\nThe end time can be either of:
\n\nto <SPEC>\nuntil <SPEC>\n\n\nSpec:
\n\n2004\n2004/10\n2004/10/1\n10/1\noctober\noct\nthis week # or day, month, quarter, year\nnext week\nlast week\n\n\nExamples:
\n\n$ ledger r -p \"since last month\"\n\n\nSee: http://ledger-cli.org/3.0/doc/ledger3.html#Period-Expressions
", + "content_html": "[INTERVAL] [BEGIN] [END]\n\n\nevery day\nevery week\nevery month\nevery quarter\nevery year\nevery N days # N is any integer\nevery N weeks\nevery N months\nevery N quarters\nevery N years\ndaily\nweekly\nbiweekly\nmonthly\nbimonthly\nquarterly\nyearly\n\n\nfrom <SPEC>\nsince <SPEC>\n\n\nto <SPEC>\nuntil <SPEC>\n\n\n2004\n2004/10\n2004/10/1\n10/1\noctober\noct\nthis week # or day, month, quarter, year\nnext week\nlast week\n\n\n$ ledger r -p \"since last month\"\n",
"intro_html": "",
"description_html": "",
"tags": null,
@@ -1831,7 +1831,7 @@
"url": "/ledger-query",
"category": "Ledger",
"keywords": null,
- "content_html": "| Query | \nDescription | \n
|---|---|
@payee | \n Payee | \n
%tag | \n Tag | \n
=note | \n Note | \n
#code | \n Code | \n
TERM and TERM | \n Boolean and | \n
TERM or TERM | \n Boolean or | \n
not TERM | \n Boolean not | \n
ledger r @taco\nledger r comment =~ /landline/\n\n\n| Query | \nDescription | \n
|---|---|
@payee | \n Payee | \n
%tag | \n Tag | \n
=note | \n Note | \n
#code | \n Code | \n
TERM and TERM | \n Boolean and | \n
TERM or TERM | \n Boolean or | \n
not TERM | \n Boolean not | \n
ledger r @taco\nledger r comment =~ /landline/\n",
"intro_html": "",
"description_html": "",
"tags": null,
@@ -1897,7 +1897,7 @@
"url": "/lua",
"category": "Others",
"keywords": null,
- "content_html": "-- comment\n--[[ Multiline\n comment ]]\n\n\nprint()\nprint(\"Hi\")\n\n-- You can omit parentheses if the argument is one string or table literal\nprint \"Hello World\" <--> print(\"Hello World\")\ndofile 'a.lua' <--> dofile ('a.lua')\nprint [[a multi-line <--> print([[a multi-line\n message]] message]])\nf{x=10, y=20} <--> f({x=10, y=20})\ntype{} <--> type({})\n\n\nt = {}\nt = { a = 1, b = 2 }\nt.a = function() ... end\n\nt = { [\"hello\"] = 200 }\nt.hello\n\n-- Remember, arrays are also tables\narray = { \"a\", \"b\", \"c\", \"d\" }\nprint(array[2]) -- \"b\" (one-indexed)\nprint(#array) -- 4 (length)\n\n\nwhile condition do\nend\n\nfor i = 1,5 do\nend\n\nfor i = start,finish,delta do\nend\n\nfor k,v in pairs(tab) do\nend\n\nrepeat\nuntil condition\n\n-- Breaking out:\nwhile x do\n if condition then break end\nend\n\n\nif condition then\n print(\"yes\")\nelseif condition then\n print(\"maybe\")\nelse\n print(\"no\")\nend\n\n\nlocal x = 2\ntwo, four = 2, 4\n\n\nfunction myFunction()\n return 1\nend\n\nfunction myFunctionWithArgs(a, b)\n -- ...\nend\n\nmyFunction()\n\nanonymousFunctions(function()\n -- ...\nend)\n\n-- Not exported in the module\nlocal function myPrivateFunction()\nend\n\n-- Splats\nfunction doAction(action, ...)\n print(\"Doing '\"..action..\"' to\", ...)\n --> print(\"Doing 'write' to\", \"Shirley\", \"Abed\")\nend\n\ndoAction('write', \"Shirley\", \"Abed\")\n\n\nmytable = { x = 2, y = function() .. end }\n\n-- The same:\nmytable.x\nmytable['x']\n\n-- Syntactic sugar, these are equivalent:\nmytable.y(mytable)\nmytable:y()\n\nmytable.y(mytable, a, b)\nmytable:y(a, b)\n\nfunction X:y(z) .. end\nfunction X.y(self, z) .. end\n\n\nmt = {}\n\n-- A metatable is simply a table with functions in it.\nmt.__tostring = function() return \"lol\" end\nmt.__add = function(b) ... end -- a + b\nmt.__mul = function(b) ... end -- a * b\nmt.__index = function(k) ... end -- Lookups (a[k] or a.k)\nmt.__newindex = function(k, v) ... end -- Setters (a[k] = v)\n\n-- Metatables allow you to override behavior of another table.\nmytable = {}\nsetmetatable(mytable, mt)\n\nprint(myobject)\n\n\nAccount = {}\n\nfunction Account:new(balance)\n local t = setmetatable({}, { __index = Account })\n\n -- Your constructor stuff\n t.balance = (balance or 0)\n return t\nend\n\nfunction Account:withdraw(amount)\n print(\"Withdrawing \"..amount..\"...\")\n self.balance = self.balance - amount\n self:report()\nend\n\nfunction Account:report()\n print(\"Your current balance is: \"..self.balance)\nend\n\na = Account:new(9000)\na:withdraw(200) -- method call\n\n\nnil\nfalse\ntrue\n\n\n-- Relational (binary)\n-- __eq __lt __gt __le __ge\n == < > <= >=\n~= -- Not equal, just like !=\n\n-- Arithmetic (binary)\n-- __add __sub __muv __div __mod __pow\n + - * / % ^\n\n-- Arithmetic (unary)\n-- __unm (unary minus)\n -\n\n-- Logic (and/or)\nnil and false --> nil\nfalse and nil --> false\n0 and 20 --> 20\n10 and 20 --> 20\n\n\n-- Length\n-- __len(array)\n#array\n\n\n-- Indexing\n-- __index(table, key)\nt[key]\nt.key\n\n-- __newindex(table, key, value)\nt[key]=value\n\n-- String concat\n-- __concat(left, right)\n\"hello, \"..name\n\n-- Call\n-- __call(func, ...)\n\n\ndofile(\"hello.lua\")\nloadfile(\"hello.lua\")\n\nassert(x) -- x or (raise an error)\nassert(x, \"failed\")\n\ntype(var) -- \"nil\" | \"number\" | \"string\" | \"boolean\" | \"table\" | \"function\" | \"thread\" | \"userdata\"\n\n-- Does /not/ invoke meta methods (__index and __newindex)\nrawset(t, index, value) -- Like t[index] = value\nrawget(t, index) -- Like t[index]\n\n_G -- Global context\nsetfenv(1, {}) -- 1: current function, 2: caller, and so on -- {}: the new _G\n\npairs(t) -- iterable list of {key, value}\nipairs(t) -- iterable list of {index, value}\n\ntonumber(\"34\")\ntonumber(\"8f\", 16)\n\n\n'string'..'concatenation'\n\ns = \"Hello\"\ns:upper()\ns:lower()\ns:len() -- Just like #s\n\ns:find()\ns:gfind()\n\ns:match()\ns:gmatch()\n\ns:sub()\ns:gsub()\n\ns:rep()\ns:char()\ns:dump()\ns:reverse()\ns:byte()\ns:format()\n\n\ntable.foreach(t, function(row) ... end)\ntable.setn\ntable.insert(t, 21) -- append (--> t[#t+1] = 21)\ntable.insert(t, 4, 99)\ntable.getn\ntable.concat\ntable.sort\ntable.remove(t, 4)\n\n\nmath.abs math.acos math.asin math.atan math.atan2\nmath.ceil math.cos math.cosh math.deg math.exp\nmath.floor math.fmod math.frexp math.ldexp math.log\nmath.log10 math.max math.min math.modf math.pow\nmath.rad math.random math.randomseed math.sin math.sinh\nmath.sqrt math.tan math.tanh\n\nmath.sqrt(144)\nmath\n\n\nio.output(io.open(\"file.txt\", \"w\"))\nio.write(x)\nio.close()\n\nfor line in io.lines(\"file.txt\")\n\nfile = assert(io.open(\"file.txt\", \"r\"))\nfile:read()\nfile:lines()\nfile:close()\n\n\nhttps://www.lua.org/pil/13.html\n http://lua-users.org/wiki/ObjectOrientedProgramming
", + "content_html": "-- comment\n--[[ Multiline\n comment ]]\n\n\nprint()\nprint(\"Hi\")\n\n-- You can omit parentheses if the argument is one string or table literal\nprint \"Hello World\" <--> print(\"Hello World\")\ndofile 'a.lua' <--> dofile ('a.lua')\nprint [[a multi-line <--> print([[a multi-line\n message]] message]])\nf{x=10, y=20} <--> f({x=10, y=20})\ntype{} <--> type({})\n\n\nt = {}\nt = { a = 1, b = 2 }\nt.a = function() ... end\n\nt = { [\"hello\"] = 200 }\nt.hello\n\n-- Remember, arrays are also tables\narray = { \"a\", \"b\", \"c\", \"d\" }\nprint(array[2]) -- \"b\" (one-indexed)\nprint(#array) -- 4 (length)\n\n\nwhile condition do\nend\n\nfor i = 1,5 do\nend\n\nfor i = start,finish,delta do\nend\n\nfor k,v in pairs(tab) do\nend\n\nrepeat\nuntil condition\n\n-- Breaking out:\nwhile x do\n if condition then break end\nend\n\n\nif condition then\n print(\"yes\")\nelseif condition then\n print(\"maybe\")\nelse\n print(\"no\")\nend\n\n\nlocal x = 2\ntwo, four = 2, 4\n\n\nfunction myFunction()\n return 1\nend\n\nfunction myFunctionWithArgs(a, b)\n -- ...\nend\n\nmyFunction()\n\nanonymousFunctions(function()\n -- ...\nend)\n\n-- Not exported in the module\nlocal function myPrivateFunction()\nend\n\n-- Splats\nfunction doAction(action, ...)\n print(\"Doing '\"..action..\"' to\", ...)\n --> print(\"Doing 'write' to\", \"Shirley\", \"Abed\")\nend\n\ndoAction('write', \"Shirley\", \"Abed\")\n\n\nmytable = { x = 2, y = function() .. end }\n\n-- The same:\nmytable.x\nmytable['x']\n\n-- Syntactic sugar, these are equivalent:\nmytable.y(mytable)\nmytable:y()\n\nmytable.y(mytable, a, b)\nmytable:y(a, b)\n\nfunction X:y(z) .. end\nfunction X.y(self, z) .. end\n\n\nmt = {}\n\n-- A metatable is simply a table with functions in it.\nmt.__tostring = function() return \"lol\" end\nmt.__add = function(b) ... end -- a + b\nmt.__mul = function(b) ... end -- a * b\nmt.__index = function(k) ... end -- Lookups (a[k] or a.k)\nmt.__newindex = function(k, v) ... end -- Setters (a[k] = v)\n\n-- Metatables allow you to override behavior of another table.\nmytable = {}\nsetmetatable(mytable, mt)\n\nprint(myobject)\n\n\nAccount = {}\n\nfunction Account:new(balance)\n local t = setmetatable({}, { __index = Account })\n\n -- Your constructor stuff\n t.balance = (balance or 0)\n return t\nend\n\nfunction Account:withdraw(amount)\n print(\"Withdrawing \"..amount..\"...\")\n self.balance = self.balance - amount\n self:report()\nend\n\nfunction Account:report()\n print(\"Your current balance is: \"..self.balance)\nend\n\na = Account:new(9000)\na:withdraw(200) -- method call\n\n\nnil\nfalse\ntrue\n\n\n-- Relational (binary)\n-- __eq __lt __gt __le __ge\n == < > <= >=\n~= -- Not equal, just like !=\n\n-- Arithmetic (binary)\n-- __add __sub __muv __div __mod __pow\n + - * / % ^\n\n-- Arithmetic (unary)\n-- __unm (unary minus)\n -\n\n\n-- Logic (and/or)\nnil and false --> nil\nfalse and nil --> false\n0 and 20 --> 20\n10 and 20 --> 20\n\n\n-- Length\n-- __len(array)\n#array\n\n\n-- Indexing\n-- __index(table, key)\nt[key]\nt.key\n\n-- __newindex(table, key, value)\nt[key]=value\n\n-- String concat\n-- __concat(left, right)\n\"hello, \"..name\n\n-- Call\n-- __call(func, ...)\n\n\ndofile(\"hello.lua\")\nloadfile(\"hello.lua\")\n\nassert(x) -- x or (raise an error)\nassert(x, \"failed\")\n\ntype(var) -- \"nil\" | \"number\" | \"string\" | \"boolean\" | \"table\" | \"function\" | \"thread\" | \"userdata\"\n\n-- Does /not/ invoke meta methods (__index and __newindex)\nrawset(t, index, value) -- Like t[index] = value\nrawget(t, index) -- Like t[index]\n\n_G -- Global context\nsetfenv(1, {}) -- 1: current function, 2: caller, and so on -- {}: the new _G\n\npairs(t) -- iterable list of {key, value}\nipairs(t) -- iterable list of {index, value}\n\ntonumber(\"34\")\ntonumber(\"8f\", 16)\n\n\n'string'..'concatenation'\n\ns = \"Hello\"\ns:upper()\ns:lower()\ns:len() -- Just like #s\n\ns:find()\ns:gfind()\n\ns:match()\ns:gmatch()\n\ns:sub()\ns:gsub()\n\ns:rep()\ns:char()\ns:dump()\ns:reverse()\ns:byte()\ns:format()\n\n\ntable.foreach(t, function(row) ... end)\ntable.setn\ntable.insert(t, 21) -- append (--> t[#t+1] = 21)\ntable.insert(t, 4, 99)\ntable.getn\ntable.concat\ntable.sort\ntable.remove(t, 4)\n\n\nmath.abs math.acos math.asin math.atan math.atan2\nmath.ceil math.cos math.cosh math.deg math.exp\nmath.floor math.fmod math.frexp math.ldexp math.log\nmath.log10 math.max math.min math.modf math.pow\nmath.rad math.random math.randomseed math.sin math.sinh\nmath.sqrt math.tan math.tanh\n\nmath.sqrt(144)\nmath\n\n\nio.output(io.open(\"file.txt\", \"w\"))\nio.write(x)\nio.close()\n\nfor line in io.lines(\"file.txt\")\n\nfile = assert(io.open(\"file.txt\", \"r\"))\nfile:read()\nfile:lines()\nfile:close()\n",
"intro_html": "",
"description_html": "",
"tags": null,
@@ -1930,10 +1930,10 @@
"url": "/make-assets",
"category": "Others",
"keywords": null,
- "content_html": "bin := ./node_modules/.bin\n\nall: build/foo.js\n\nbuild/%.js: src/%.coffee\n @$(bin)/coffee < $^ > $@\n\n\nbin := ./node_modules/.bin\nstylus := $(bin)/stylus\nautoprefixer := $(bin)/autoprefixer\nstyl_files := $(shell find web/ -name \"*.styl\")\n\nall: public/app.css\n\npublic/app.css: css/app.styl\n\n%.css: %.styl $(styl_files)\n @$(stylus) $< | $(autoprefixer) -b \"> 1%\" > $@\n\n\nhint:\n $(js_files)\n\n\nwatch:\n @echo \"... watching for changes\"\n @while true; do make -s; sleep 1; done\n\n\njs_files := $(shell find web/ -name \"*.js\")\n\npublic/app.js: web/app.js\npublic/vendor.js: web/vendor.js\n\npublic/%.js: web/%.js $(js_files)\n $(browserify) -t [ cssify -x .css ] $< > $@\n",
+ "content_html": "bin := ./node_modules/.bin\n\nall: build/foo.js\n\nbuild/%.js: src/%.coffee\n @$(bin)/coffee < $^ > $@\n\n\nbin := ./node_modules/.bin\nstylus := $(bin)/stylus\nautoprefixer := $(bin)/autoprefixer\nstyl_files := $(shell find web/ -name \"*.styl\")\n\nall: public/app.css\n\npublic/app.css: css/app.styl\n\n%.css: %.styl $(styl_files)\n @$(stylus) $< | $(autoprefixer) -b \"> 1%\" > $@\n\n\nhint:\n $(js_files)\n\n\nwatch:\n @echo \"... watching for changes\"\n @while true; do make -s; sleep 1; done\n\n\njs_files := $(shell find web/ -name \"*.js\")\n\npublic/app.js: web/app.js\npublic/vendor.js: web/vendor.js\n\npublic/%.js: web/%.js $(js_files)\n $(browserify) -t [ cssify -x .css ] $< > $@\n",
"intro_html": "",
"description_html": "",
- "tags": null,
+ "tags": ["Archived"],
"updated": null
},{
"id": "makefile",
@@ -1941,7 +1941,7 @@
"url": "/makefile",
"category": "CLI",
"keywords": null,
- "content_html": "foo = \"bar\"\nbar = $(foo) foo # dynamic (renewing) assignment\nfoo := \"boo\" # one time assignment, $(bar) now is \"boo foo\"\nfoo ?= /usr/local # safe assignment, $(foo) and $(bar) still the same\nbar += world # append, \"boo foo world\"\nfoo != echo fooo # exec shell command and assign to foo\n# $(bar) now is \"fooo foo world\"\n\n\n= expressions are only evaluated when they’re being used.
out.o: src.c src.h\n $@ # \"out.o\" (target)\n $< # \"src.c\" (first prerequisite)\n $^ # \"src.c src.h\" (all prerequisites)\n\n%.o: %.c\n $* # the 'stem' with which an implicit rule matches (\"foo\" in \"foo.c\")\n\nalso:\n $+ # prerequisites (all, with duplication)\n $? # prerequisites (new ones)\n $| # prerequisites (order-only?)\n\n $(@D) # target directory\n\n\n| Prefix | \nDescription | \n
|---|---|
- | \n Ignore errors | \n
@ | \n Don’t print command | \n
+ | \n Run even if Make is in ‘don’t execute’ mode | \n
build:\n @echo \"compiling\"\n -gcc $< $@\n\n-include .depend\n\n\njs_files := $(wildcard test/*.js)\nall_files := $(shell find images -name \"*\")\n\n\nfile = $(SOURCE:.cpp=.o) # foo.cpp => foo.o\noutputs = $(files:src/%.coffee=lib/%.js)\n\noutputs = $(patsubst %.c, %.o, $(wildcard *.c))\nassets = $(patsubst images/%, assets/%, $(wildcard images/*))\n\n\n$(strip $(string_var))\n\n$(filter %.less, $(files))\n$(filter-out %.less, $(files))\n\n\n%.o: %.c\n ffmpeg -i $< > $@ # Input and output\n foo $^\n\n\n-include foo.make\n\n\nmake\n -e, --environment-overrides\n -B, --always-make\n -s, --silent\n -j, --jobs=N # parallel processing\n\n\nfoo: $(objects)\nifeq ($(CC),gcc)\n $(CC) -o foo $(objects) $(libs_for_gcc)\nelse\n $(CC) -o foo $(objects) $(normal_libs)\nendif\n\n\ndeploy:\n $(MAKE) deploy2\n\n\nfoo = \"bar\"\nbar = $(foo) foo # dynamic (renewing) assignment\nfoo := \"boo\" # one time assignment, $(bar) now is \"boo foo\"\nfoo ?= /usr/local # safe assignment, $(foo) and $(bar) still the same\nbar += world # append, \"boo foo world\"\nfoo != echo fooo # exec shell command and assign to foo\n# $(bar) now is \"fooo foo world\"\n\n\n= expressions are only evaluated when they’re being used.
out.o: src.c src.h\n $@ # \"out.o\" (target)\n $< # \"src.c\" (first prerequisite)\n $^ # \"src.c src.h\" (all prerequisites)\n\n%.o: %.c\n $* # the 'stem' with which an implicit rule matches (\"foo\" in \"foo.c\")\n\nalso:\n $+ # prerequisites (all, with duplication)\n $? # prerequisites (new ones)\n $| # prerequisites (order-only?)\n\n $(@D) # target directory\n\n\n| Prefix | \nDescription | \n
|---|---|
- | \n Ignore errors | \n
@ | \n Don’t print command | \n
+ | \n Run even if Make is in ‘don’t execute’ mode | \n
build:\n @echo \"compiling\"\n -gcc $< $@\n\n-include .depend\n\n\njs_files := $(wildcard test/*.js)\nall_files := $(shell find images -name \"*\")\n\n\nfile = $(SOURCE:.cpp=.o) # foo.cpp => foo.o\noutputs = $(files:src/%.coffee=lib/%.js)\n\noutputs = $(patsubst %.c, %.o, $(wildcard *.c))\nassets = $(patsubst images/%, assets/%, $(wildcard images/*))\n\n\n$(strip $(string_var))\n\n$(filter %.less, $(files))\n$(filter-out %.less, $(files))\n\n\n%.o: %.c\n ffmpeg -i $< > $@ # Input and output\n foo $^\n\n\n-include foo.make\n\n\nmake\n -e, --environment-overrides\n -B, --always-make\n -s, --silent\n -j, --jobs=N # parallel processing\n\n\nfoo: $(objects)\nifeq ($(CC),gcc)\n $(CC) -o foo $(objects) $(libs_for_gcc)\nelse\n $(CC) -o foo $(objects) $(normal_libs)\nendif\n\n\ndeploy:\n $(MAKE) deploy2\n\n\nThis is a mocha template that loads js/css from cdn.
\n\n<!doctype html>\n<html>\n<head>\n <meta charset='utf-8'>\n <title>Mocha</title>\n <meta name='viewport' content='width=device-width, initial-scale=1.0'>\n <link href='https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.css' rel='stylesheet' />\n</head>\n<body>\n <div id='mocha'></div>\n <script src='https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js'></script>\n <script src='https://cdn.rawgit.com/chaijs/chai/2.3.0/chai.js'></script>\n <script>window.onerror=function(msg,url,line){document.getElementById('mocha').innerHTML+='<h1>'+msg+'</'+'h1>'+'<h2>'+url+':'+line+'</'+'h2>';return false}</script>\n <script>mocha.setup('bdd')</script>\n <!-- what to test: -->\n <script src='../index.js'></script>\n <!-- tests to run: -->\n <script src='first_test.js'></script>\n <script src='second_test.js'></script>\n <script>mocha.run()</script>\n</body>\n</html>\n",
+ "content_html": "This is a mocha template that loads js/css from cdn.
\n\n<!doctype html>\n<html>\n<head>\n <meta charset='utf-8'>\n <title>Mocha</title>\n <meta name='viewport' content='width=device-width, initial-scale=1.0'>\n <link href='https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.css' rel='stylesheet' />\n</head>\n<body>\n <div id='mocha'></div>\n <script src='https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js'></script>\n <script src='https://cdn.rawgit.com/chaijs/chai/2.3.0/chai.js'></script>\n <script>window.onerror=function(msg,url,line){document.getElementById('mocha').innerHTML+='<h1>'+msg+'</'+'h1>'+'<h2>'+url+':'+line+'</'+'h2>';return false}</script>\n <script>mocha.setup('bdd')</script>\n <!-- what to test: -->\n <script src='../index.js'></script>\n <!-- tests to run: -->\n <script src='first_test.js'></script>\n <script src='second_test.js'></script>\n <script>mocha.run()</script>\n</body>\n</html>\n",
"intro_html": "",
"description_html": "",
"tags": null,
@@ -2249,7 +2249,7 @@
"url": "/nodejs",
"category": "Node.js",
"keywords": null,
- "content_html": "__filename\n__dirname\n\n\nvar exec = require('child_process').exec,\n\nvar child = exec('cat *.js bad_file | wc -l',\n function (error, stdout, stderr) {\n console.log('stdout: ' + stdout);\n console.log('stderr: ' + stderr);\n if (error !== null) {\n console.log('exec error: ' + error);\n }\n});\n\n\ninfo = require('../package.json')\ninfo.version\n\nprocess.stdout.write(util.inspect(objekt, false, Infinity, true) + '\\n');\n\n\nvar spawn = require('child_process').spawn;\nvar proc = spawn(bin, argv, { stdio: 'inherit' });\nproc.on('error', function(err) {\n if (err.code == \"ENOENT\") { \"does not exist\" }\n if (err.code == \"EACCES\") { \"not executable\" }\n});\nproc.on('exit', function(code) { ... });\n\n// also { stdio: ['pipe', 'pipe', process.stdout] }\n// also { stdio: [process.stdin, process.stderr, process.stdout] }\n\nproc.stdout.on('data', function (data) {\n});\nproc.stderr.on('data', function (data) {\n});\n",
+ "content_html": "__filename\n__dirname\n\n\nvar exec = require('child_process').exec,\n\nvar child = exec('cat *.js bad_file | wc -l',\n function (error, stdout, stderr) {\n console.log('stdout: ' + stdout);\n console.log('stderr: ' + stderr);\n if (error !== null) {\n console.log('exec error: ' + error);\n }\n});\n\n\ninfo = require('../package.json')\ninfo.version\n\nprocess.stdout.write(util.inspect(objekt, false, Infinity, true) + '\\n');\n\n\nvar spawn = require('child_process').spawn;\nvar proc = spawn(bin, argv, { stdio: 'inherit' });\nproc.on('error', function(err) {\n if (err.code == \"ENOENT\") { \"does not exist\" }\n if (err.code == \"EACCES\") { \"not executable\" }\n});\nproc.on('exit', function(code) { ... });\n\n// also { stdio: ['pipe', 'pipe', process.stdout] }\n// also { stdio: [process.stdin, process.stderr, process.stdout] }\n\nproc.stdout.on('data', function (data) {\n});\nproc.stderr.on('data', function (data) {\n});\n",
"intro_html": "",
"description_html": "",
"tags": null,
@@ -2260,7 +2260,7 @@
"url": "/nopt",
"category": "JavaScript libraries",
"keywords": null,
- "content_html": "var args = require('nopt')({\n foo: [String, null],\n size: ['big', 'medium', 'small'],\n many: [String, Array],\n debug: Boolean,\n version: Boolean,\n help: Boolean\n}, {\n h: '--help',\n v: '--version'\n}, process.argv);\n\nargs == {\n debug: true,\n version: true,\n size: 'big',\n argv: {\n remain: ['...', '...'],\n cooked: ...,\n original: ...\n }\n}\n\n\nif (args.help) {\n console.log([\n 'Usage:',\n ' hicat [options] [file]',\n '',\n 'Options:',\n ' -h, --help print usage information',\n ' -v, --version show version info and exit',\n ].join('\\n'));\n process.exit(0);\n}\n\nif (args.version) {\n console.log(require('../package.json').version);\n process.exit(0);\n}\n\n\nhttps://www.npmjs.org/package/nopt
", + "content_html": "var args = require('nopt')({\n foo: [String, null],\n size: ['big', 'medium', 'small'],\n many: [String, Array],\n debug: Boolean,\n version: Boolean,\n help: Boolean\n}, {\n h: '--help',\n v: '--version'\n}, process.argv);\n\nargs == {\n debug: true,\n version: true,\n size: 'big',\n argv: {\n remain: ['...', '...'],\n cooked: ...,\n original: ...\n }\n}\n\n\nif (args.help) {\n console.log([\n 'Usage:',\n ' hicat [options] [file]',\n '',\n 'Options:',\n ' -h, --help print usage information',\n ' -v, --version show version info and exit',\n ].join('\\n'));\n process.exit(0);\n}\n\nif (args.version) {\n console.log(require('../package.json').version);\n process.exit(0);\n}\n",
"intro_html": "",
"description_html": "",
"tags": null,
@@ -2337,7 +2337,7 @@
"url": "/parsimmon",
"category": "JavaScript libraries",
"keywords": null,
- "content_html": "const P = require('parsimmon')\n\nP.regexp(/[a-z]+/)\n.parse('hello')\n//=> { status: true, value: ['hello'] }\n\n\nP.regexp(/[a-z]+/)\nP.string('hello')\nP.oneOf('abc') // like P.regexp(/[abc]/)\n\nP.whitespace\nP.optWhitespace\nP.eof\n\n\nP.seq(a, b, c) // sequence of these\nP.alt(a, b) // any of these\nP.sepBy(a, P.string(',')) // sequence of `a`, separated by ','\nP.sepBy1(a, P.string(',')) // same, at least once\n\na.or(b) // like P.alt(a, b)\na.skip(b) // parses `b` but discards it\n\na.many()\na.times(3)\na.times(1, 4) // 1 <= x <= 4\na.atMost(10)\na.atLeast(10)\n\n\nP.seq(P.number, P.oneOf('+-*/'), P.number)\n.map(([left, oper, right]) => ({ oper, left, right }))\n\n\nconst P = require('parsimmon')\n\nP.regexp(/[a-z]+/)\n.parse('hello')\n//=> { status: true, value: ['hello'] }\n\n\nP.regexp(/[a-z]+/)\nP.string('hello')\nP.oneOf('abc') // like P.regexp(/[abc]/)\n\nP.whitespace\nP.optWhitespace\nP.eof\n\n\nP.seq(a, b, c) // sequence of these\nP.alt(a, b) // any of these\nP.sepBy(a, P.string(',')) // sequence of `a`, separated by ','\nP.sepBy1(a, P.string(',')) // same, at least once\n\na.or(b) // like P.alt(a, b)\na.skip(b) // parses `b` but discards it\n\na.many()\na.times(3)\na.times(1, 4) // 1 <= x <= 4\na.atMost(10)\na.atLeast(10)\n\n\nP.seq(P.number, P.oneOf('+-*/'), P.number)\n.map(([left, oper, right]) => ({ oper, left, right }))\n\n\nThis is for Phoenix 1.2 and below. Phoenix 1.3 has a new API..
\n\n$ mix phoenix.gen.html Profile profiles email:string age:integer\n$ mix phoenix.gen.html User users email:string hashed_password:string\n\n\ndefmodule User do\n use Ecto.Schema\n\n schema \"users\" do\n field :name\n field :age, :integer\n # :id :binary :integer :float :boolean :string :binary\n # {:array, inner_type} :decimal :map\n\n field :password, virtual: true\n end\nend\n\n\ndef changeset(user, params \\\\ :empty) do\n %User{}\n |> Ecto.Changeset.change # basic casting to changeset\n\n user\n |> cast(params, ~w(name email), ~w(age)) # params to Changeset\n\n |> validate_format(:email, ~r/@/)\n\n |> validate_inclusion(:age, 18..100)\n |> validate_exclusion(:role, ~w(admin superadmin))\n |> validate_subset(:pets, ~w(cat dog parrot whale))\n\n |> validate_length(:body, min: 1)\n |> validate_length(:body, min: 1, max: 160)\n |> validate_length(:partners, is: 2)\n\n |> validate_number(:pi, greater_than: 3)\n |> validate_number(:pi, less_than: 4)\n |> validate_number(:pi, equal_to: 42)\n\n |> validate_change(:title, fn _, _ -> [])\n |> validate_confirmation(:password, message: \"does not match\")\n\n |> unique_constraint(:email)\n |> foreign_key_constraint(:post_id)\n |> assoc_constraint(:post) # ensure post_id exists\n |> no_assoc_constraint(:post) # negative (useful for deletions)\nend\n\n\nchangeset.valid?\nchangeset.errors #=> [title: \"empty\"]\n\nchangeset.changes #=> %{}\nchangeset.params[:title]\n\nchangeset.required #=> [:title]\nchangeset.optional #=> [:body]\n\n\nchangeset #(or model)\n|> change(title: \"New title\")\n|> change(%{ title: \"New title\" })\n|> put_change(:title, \"New title\")\n|> force_change(:title, \"New title\")\n|> update_change(:title, &(&1 <> \"...\"))\n\n|> delete_change(:title)\n|> merge(other_changeset)\n\n|> add_error(:title, \"empty\")\n\n\nget_change(changeset, :title) #=> \"hi\" (if changed)\nget_field(changeset, :title) #=> \"hi\" (even if unchanged)\n\nfetch_change(changeset, :title) #=> {:ok, \"hi\"} | :error\nfetch_field(changeset, :title) #=> {:changes | :model, \"value\"} | :error\n\n\nRepo.get(User, id)\nRepo.get_by(User, email: \"john@hello.com\") #=> %User{} | nil\n\n# also get! get_by!\n\n\nchangeset |> Repo.update\nchangeset |> Repo.insert\nchangeset |> Repo.insert_or_update\n\n\nUser\n|> Ecto.Changeset.change(%{name: \"hi\"})\n|> Repo.insert\n\n\nfrom p in Post,\n where: p.title == \"Hello\",\n where: [state: \"Sweden\"],\n\n limit: 1,\n offset: 10,\n\n order_by: c.name,\n order_by: [c.name, c.title],\n order_by: [asc: c.name, desc: c.title],\n\n preload: [:comments],\n preload: [comments: {c, likes: l}],\n\n join: c in assoc(c, :comments),\n join: p in Post, on: c.post_id == p.id,\n group_by: p,\n\n select: p,\n select: {p.title, p.description},\n select: [p.title, p.description],\n\n\nRepo.all(User)\n\n\nRepo.update_all(Post, set: [title: \"Title\"])\nRepo.update_all(Post, inc: [views: 1])\n\n\n_all with queriesfrom(p in Post, where: p.id < 10)\n|> Repo.update_all(...)\n\nfrom(p in Post, where: p.id < 10)\n|> Repo.all()\n",
+ "content_html": "This is for Phoenix 1.2 and below. Phoenix 1.3 has a new API..
\n\n$ mix phoenix.gen.html Profile profiles email:string age:integer\n$ mix phoenix.gen.html User users email:string hashed_password:string\n\n\ndefmodule User do\n use Ecto.Schema\n\n schema \"users\" do\n field :name\n field :age, :integer\n # :id :binary :integer :float :boolean :string :binary\n # {:array, inner_type} :decimal :map\n\n field :password, virtual: true\n end\nend\n\n\ndef changeset(user, params \\\\ :empty) do\n %User{}\n |> Ecto.Changeset.change # basic casting to changeset\n\n user\n |> cast(params, ~w(name email), ~w(age)) # params to Changeset\n\n |> validate_format(:email, ~r/@/)\n\n |> validate_inclusion(:age, 18..100)\n |> validate_exclusion(:role, ~w(admin superadmin))\n |> validate_subset(:pets, ~w(cat dog parrot whale))\n\n |> validate_length(:body, min: 1)\n |> validate_length(:body, min: 1, max: 160)\n |> validate_length(:partners, is: 2)\n\n |> validate_number(:pi, greater_than: 3)\n |> validate_number(:pi, less_than: 4)\n |> validate_number(:pi, equal_to: 42)\n\n |> validate_change(:title, fn _, _ -> [])\n |> validate_confirmation(:password, message: \"does not match\")\n\n |> unique_constraint(:email)\n |> foreign_key_constraint(:post_id)\n |> assoc_constraint(:post) # ensure post_id exists\n |> no_assoc_constraint(:post) # negative (useful for deletions)\nend\n\n\nchangeset.valid?\nchangeset.errors #=> [title: \"empty\"]\n\nchangeset.changes #=> %{}\nchangeset.params[:title]\n\nchangeset.required #=> [:title]\nchangeset.optional #=> [:body]\n\n\nchangeset #(or model)\n|> change(title: \"New title\")\n|> change(%{ title: \"New title\" })\n|> put_change(:title, \"New title\")\n|> force_change(:title, \"New title\")\n|> update_change(:title, &(&1 <> \"...\"))\n\n|> delete_change(:title)\n|> merge(other_changeset)\n\n|> add_error(:title, \"empty\")\n\n\nget_change(changeset, :title) #=> \"hi\" (if changed)\nget_field(changeset, :title) #=> \"hi\" (even if unchanged)\n\nfetch_change(changeset, :title) #=> {:ok, \"hi\"} | :error\nfetch_field(changeset, :title) #=> {:changes | :model, \"value\"} | :error\n\n\nRepo.get(User, id)\nRepo.get_by(User, email: \"john@hello.com\") #=> %User{} | nil\n\n# also get! get_by!\n\n\nchangeset |> Repo.update\nchangeset |> Repo.insert\nchangeset |> Repo.insert_or_update\n\n\nUser\n|> Ecto.Changeset.change(%{name: \"hi\"})\n|> Repo.insert\n\n\nfrom p in Post,\n where: p.title == \"Hello\",\n where: [state: \"Sweden\"],\n\n limit: 1,\n offset: 10,\n\n order_by: c.name,\n order_by: [c.name, c.title],\n order_by: [asc: c.name, desc: c.title],\n\n preload: [:comments],\n preload: [comments: {c, likes: l}],\n\n join: c in assoc(c, :comments),\n join: p in Post, on: c.post_id == p.id,\n group_by: p,\n\n select: p,\n select: {p.title, p.description},\n select: [p.title, p.description],\n\n\nRepo.all(User)\n\n\nRepo.update_all(Post, set: [title: \"Title\"])\nRepo.update_all(Post, inc: [views: 1])\n\n\n_all with queriesfrom(p in Post, where: p.id < 10)\n|> Repo.update_all(...)\n\nfrom(p in Post, where: p.id < 10)\n|> Repo.all()\n",
"intro_html": "",
"description_html": "",
- "tags": null,
+ "tags": ["Archived"],
"updated": null
},{
"id": "phoenix-ecto@1.3",
@@ -2557,7 +2557,7 @@
"url": "/postgresql",
"category": "Databases",
"keywords": null,
- "content_html": "Replace anything within <placeholder> accordingly
$ psql #logs in to default database & default user\n$ sudo -u <rolename:postgres> psql #logs in with a particular user\n\n\n\\du\\dt\\l\\c <database>\\d <table> or \\d+ <table>\\q $ createdb databasename\n",
+ "content_html": "$ psql #logs in to default database & default user\n$ sudo -u <rolename:postgres> psql #logs in with a particular user\n\n\nReplace anything within <placeholder> accordingly
\\du\\dt\\l\\c <database>\\d <table> or \\d+ <table>\\q $ createdb databasename\n",
"intro_html": "",
"description_html": "",
"tags": null,
@@ -2579,7 +2579,7 @@
"url": "/projectionist",
"category": "Vim",
"keywords": null,
- "content_html": "/* .projectionist.vim */\n{\n \"app/assets/react/components/*.jsx\": {\n \"type\": \"component\",\n \"template\": [\n \"import React from 'react'\",\n \"export default {} = React.createClass({ ... })\"\n ]\n }\n\n\n{\n \"lib/*.rb\": {\n \"type\": \"lib\", /* enables :Elib */\n \"alternate\": \"test/{}_spec.rb\", /* for :A */\n \"template\": [ ... ],\n\n \"path\": \"include\", /* for `gf` i think */\n\n \"console\": \"node\", /* for :Console */\n \"dispatch\": \"node\", /* for :Dispatch (dispatch.vim) */\n \"start\": \"rails server\", /* for :Start (dispatch.vim) */\n \"make\": \"node\", /* for makeprg */\n }\n}\n\n\n| Command | \nDescription | \n
|---|---|
:A | \n Edit alternate | \n
:A {file} | \n Edit file | \n
:AS | \n Edit in split | \n
:AV | \n Edit in vsplit | \n
:AT | \n Edit in tab | \n
:AD | \n Replace with template | \n
:Cd | \n cd to root | \n
:Cd {path} | \n cd to path in root | \n
:Lcd | \n cd to root using :lcd | \n
:ProjectDo {cmd} | \n run command in root | \n
See vim-projectionist.
", + "content_html": "/* .projectionist.vim */\n{\n \"app/assets/react/components/*.jsx\": {\n \"type\": \"component\",\n \"template\": [\n \"import React from 'react'\",\n \"export default {} = React.createClass({ ... })\"\n ]\n }\n\n\n{\n \"lib/*.rb\": {\n \"type\": \"lib\", /* enables :Elib */\n \"alternate\": \"test/{}_spec.rb\", /* for :A */\n \"template\": [ ... ],\n\n \"path\": \"include\", /* for `gf` i think */\n\n \"console\": \"node\", /* for :Console */\n \"dispatch\": \"node\", /* for :Dispatch (dispatch.vim) */\n \"start\": \"rails server\", /* for :Start (dispatch.vim) */\n \"make\": \"node\", /* for makeprg */\n }\n}\n\n\n| Command | \nDescription | \n
|---|---|
:A | \n Edit alternate | \n
:A {file} | \n Edit file | \n
:AS | \n Edit in split | \n
:AV | \n Edit in vsplit | \n
:AT | \n Edit in tab | \n
:AD | \n Replace with template | \n
:Cd | \n cd to root | \n
:Cd {path} | \n cd to path in root | \n
:Lcd | \n cd to root using :lcd | \n
:ProjectDo {cmd} | \n run command in root | \n
See vim-projectionist.
", "intro_html": "", "description_html": "", "tags": null, @@ -2685,7 +2685,7 @@ "updated": null },{ "id": "rails-controllers", - "title": "Controllers", + "title": "Rails controllers", "url": "/rails-controllers", "category": "Rails", "keywords": null, @@ -2696,18 +2696,18 @@ "updated": null },{ "id": "rails-forms", - "title": "Form helpers", + "title": "Rails form helpers", "url": "/rails-forms", "category": "Rails", "keywords": null, - "content_html": "- form_for @post do |f|\n\n\nField names will be prefixed with post (the class name), and values will be derived from this object (eg, f.text_field :name from @post.name).
- form_for @post, |\n url: { method: 'put', action: 'create' }, |\n html: { class: 'nifty_form' } |\n do |f|\n\n\nf.text_field :title\nf.text_area :body, size: '60x12'\n\n\nf.check_box :remember_me\nf.label :remember_me, \"Remember me\"\n\n\nf.radio_button :gender, 'male'\nf.label :gender_male, \"Male\"\n\nf.radio_button :gender, 'female'\nf.label :gender_female, \"Female\"\n\n\nf.label :title\nf.label :title, \"Title\"\nf.label :title, \"Title\", class: \"title\"\nf.label(:post, :terms) { \"Accept terms\" }\n\n\nf.submit \"Create\"\n\n\nf.hidden_field :id\n\n\nf.object\n\n\n= form_for @post do |f|\n = fields_for :author, @post.author do |ff|\n = ff.text_field :name\n\n\nf.select :city_id, [['Lisbon',1], ['Madrid',2], ...], 4\n# (4 = selected)\n\noptions_for_select [['Lisbon',1], ['Madrid',2], ...], 4\n# Just makes <option> tags\n\n\nf.collection_radio_buttons :author_id, Author.all, :id, :name_with_initial\nf.collection_select :city_id, City.all, :id, :name\n# (field, collection, value_key, label_key)\n\n\nf.time_zone_select :time_zone\nf.date_select :birthday\n\nhelpers:\n submit:\n # helpers.submit.<action>\n create: \"Create a %{model}\"\n update: \"Confirm changes to %{model}\"\n\n # helpers.submit.<model>.<action>\n article:\n create: \"Publish article\"\n update: \"Update article\"\n\n # helpers.label.<model>.<field>\n label:\n post:\n body: \"Your body text\"\n\n\nfradio_button(\"post\", \"category\", \"rails\")\nradio_button(\"post\", \"category\", \"java\")\n\n# picks from @post.category\n# <input type=\"radio\" id=\"post_category_rails\" name=\"post[category]\"\n# value=\"rails\" checked=\"checked\" />\n\n\nselect(method, choices = nil, options = {}, html_options = {}, &block)\n choices == [ ['label', id], ... ]\n\nsubmit(value=nil, options={})\n",
+ "content_html": "- form_for @post do |f|\n\n\nField names will be prefixed with post (the class name), and values will be derived from this object (eg, f.text_field :name from @post.name).
- form_for @post, |\n url: { method: 'put', action: 'create' }, |\n html: { class: 'nifty_form' } |\n do |f|\n\n\nf.text_field :title\nf.text_area :body, size: '60x12'\n\n\nf.check_box :remember_me\nf.label :remember_me, \"Remember me\"\n\n\nf.radio_button :gender, 'male'\nf.label :gender_male, \"Male\"\n\nf.radio_button :gender, 'female'\nf.label :gender_female, \"Female\"\n\n\nf.label :title\nf.label :title, \"Title\"\nf.label :title, \"Title\", class: \"title\"\nf.label(:post, :terms) { \"Accept terms\" }\n\n\nf.submit \"Create\"\n\n\nf.hidden_field :id\n\n\nf.object\n\n\n= form_for @post do |f|\n = fields_for :author, @post.author do |ff|\n = ff.text_field :name\n\n\nf.select :city_id, [['Lisbon',1], ['Madrid',2], ...], 4\n# (4 = selected)\n\noptions_for_select [['Lisbon',1], ['Madrid',2], ...], 4\n# Just makes <option> tags\n\n\nf.collection_radio_buttons :author_id, Author.all, :id, :name_with_initial\nf.collection_select :city_id, City.all, :id, :name\n# (field, collection, value_key, label_key)\n\n\nf.time_zone_select :time_zone\nf.date_select :birthday\n\nhelpers:\n submit:\n # helpers.submit.<action>\n create: \"Create a %{model}\"\n update: \"Confirm changes to %{model}\"\n\n # helpers.submit.<model>.<action>\n article:\n create: \"Publish article\"\n update: \"Update article\"\n\n # helpers.label.<model>.<field>\n label:\n post:\n body: \"Your body text\"\n\n\nfradio_button(\"post\", \"category\", \"rails\")\nradio_button(\"post\", \"category\", \"java\")\n\n# picks from @post.category\n# <input type=\"radio\" id=\"post_category_rails\" name=\"post[category]\"\n# value=\"rails\" checked=\"checked\" />\n\n\nselect(method, choices = nil, options = {}, html_options = {}, &block)\n choices == [ ['label', id], ... ]\n\nsubmit(value=nil, options={})\n",
"intro_html": "",
"description_html": "",
"tags": null,
"updated": null
},{
"id": "rails-helpers",
- "title": "Helpers",
+ "title": "Rails helpers",
"url": "/rails-helpers",
"category": "Rails",
"keywords": null,
@@ -2718,18 +2718,18 @@
"updated": null
},{
"id": "rails-i18n",
- "title": "i18n",
+ "title": "Rails i18n",
"url": "/rails-i18n",
"category": "Rails",
"keywords": null,
- "content_html": "t('my.messages.hello')\n\n# same as 'my.messages.hello'\nt(:hello, scope: 'my.messages')\nt(:hello, scope: [:my, :messages])\n\nt('my.messages.hello', default: \"Hello\")\n\n\nen:\n my:\n messages:\n hello: \"Hello\"\n\n\nt('hello', name: \"John\")\n\n\nhello: \"Hello %{name}\"\n\n\n# from the 'books/index' view\nt('.title')\n\n\nen:\n books:\n index:\n title: \"Título\"\n\n\nt(:inbox, count: 1) #=> 'one message'\nt(:inbox, count: 2) #=> '2 messages'\n\n\ninbox:\n one: 'one message',\n other: '%{count} messages'\n\n\nl(Time.now)\nl(Time.now, format: :short)\n\n\nen:\n time:\n formats:\n default: \"%a, %d %b %Y %H:%M:%S %z\"\n long: \"%B %d, %Y %H:%M\"\n short: \"%d %b %H:%M\"\n\n\nl(Date.today)\n\n\nen:\n date:\n formats:\n default: \"%Y-%m-%d\" # 2015-06-25\n long: \"%B %d, %Y\" # June 25, 2015\n short: \"%b %d\" # Jun 25\n\n\nUser.model_name.human #=> \"User\"\nChild.model_name.human(count: 2) #=> \"Children\"\n\n\nen:\n activerecord:\n models:\n user: \"User\"\n child:\n one: \"Child\"\n other: \"Children\"\n\n\nUser.human_attribute_for :name #=> \"Name\"\n\n\nen:\n activerecord:\n attributes:\n user:\n # activerecord.attributes.<model>.<field>\n name: \"Name\"\n email: \"Email\"\n\n\nerror_messages_for(...)\n\n\nactiverecord:\n errors:\n models:\n venue:\n attributes:\n name:\n blank: \"Please enter a name.\"\n\n\nPossible scopes (in order):
\n\nactiverecord.errors.models.[model_name].attributes.[attribute_name].[error]\nactiverecord.errors.models.[model_name].[error]\nactiverecord.errors.messages.[error]\nerrors.attributes.[attribute_name].[error]\nerrors.messages.[error]\n\n\nWhere [error] can be:
validates\n confirmation - :confirmation\n acceptance - :accepted\n presence - :blank\n length - :too_short (%{count})\n length - :too_long (%{count})\n length - :wrong_length (%{count})\n uniqueness - :taken\n format - :invalid\n numericality - :not_a_number\n\n\nform_for @post do\n f.label :body\n\n\nhelpers:\n # helpers.label.<model>.<field>\n label:\n post:\n body: \"Your body text\"\n\n\nform_for @post do\n f.submit\n\n\nhelpers:\n submit:\n # helpers.submit.<action>\n create: \"Create a %{model}\"\n update: \"Confirm changes to %{model}\"\n\n # helpers.submit.<model>.<action>\n article:\n create: \"Publish article\"\n update: \"Update article\"\n\n\nnumber_to_delimited(2000) #=> \"2,000\"\nnumber_to_currency(12.3) #=> \"$12.30\"\nnumber_to_percentage(0.3) #=> \"30%\"\nnumber_to_rounded(3.14, precision: 0) #=> \"3\"\nnumber_to_human(12_000) #=> \"12 Thousand\"\nnumber_to_human_size(12345) #=> \"12.3 kb\"\n\n\nnumber_to_delimited(n)\n\n\nnumber:\n format:\n separator: '.'\n delimiter: ','\n precision: 3\n significant: false\n strip_insignificant_zeroes: false\n\n\nnumber_to_currency(n)\n\n\nnumber:\n currency:\n format:\n format: \"%u%n\" # %u = unit, %n = number\n unit: \"$\"\n separator: '.'\n delimiter: ','\n precision: 3\n # (see number.format)\n\n\nnumber_to_percentage(n)\n\n\nnumber:\n percentage:\n format:\n format: \"%n%\"\n # (see number.format)\n\n\nI18n.backend.store_translations :en, ok: \"Ok\"\nI18n.locale = :en\nI18n.default_locale = :en\n\nI18n.available_locales\n\nI18n.translate :ok # aka, I18n.t\nI18n.localize date # aka, I18n.l\n\n\nt('my.messages.hello')\n\n# same as 'my.messages.hello'\nt(:hello, scope: 'my.messages')\nt(:hello, scope: [:my, :messages])\n\nt('my.messages.hello', default: \"Hello\")\n\n\nen:\n my:\n messages:\n hello: \"Hello\"\n\n\nt('hello', name: \"John\")\n\n\nhello: \"Hello %{name}\"\n\n\n# from the 'books/index' view\nt('.title')\n\n\nen:\n books:\n index:\n title: \"Título\"\n\n\nt(:inbox, count: 1) #=> 'one message'\nt(:inbox, count: 2) #=> '2 messages'\n\n\ninbox:\n one: 'one message',\n other: '%{count} messages'\n\n\nl(Time.now)\nl(Time.now, format: :short)\n\n\nen:\n time:\n formats:\n default: \"%a, %d %b %Y %H:%M:%S %z\"\n long: \"%B %d, %Y %H:%M\"\n short: \"%d %b %H:%M\"\n\n\nl(Date.today)\n\n\nen:\n date:\n formats:\n default: \"%Y-%m-%d\" # 2015-06-25\n long: \"%B %d, %Y\" # June 25, 2015\n short: \"%b %d\" # Jun 25\n\n\nUser.model_name.human #=> \"User\"\nChild.model_name.human(count: 2) #=> \"Children\"\n\n\nen:\n activerecord:\n models:\n user: \"User\"\n child:\n one: \"Child\"\n other: \"Children\"\n\n\nUser.human_attribute_for :name #=> \"Name\"\n\n\nen:\n activerecord:\n attributes:\n user:\n # activerecord.attributes.<model>.<field>\n name: \"Name\"\n email: \"Email\"\n\n\nerror_messages_for(...)\n\n\nactiverecord:\n errors:\n models:\n venue:\n attributes:\n name:\n blank: \"Please enter a name.\"\n\n\nPossible scopes (in order):
\n\nactiverecord.errors.models.[model_name].attributes.[attribute_name].[error]\nactiverecord.errors.models.[model_name].[error]\nactiverecord.errors.messages.[error]\nerrors.attributes.[attribute_name].[error]\nerrors.messages.[error]\n\n\nWhere [error] can be:
validates\n confirmation - :confirmation\n acceptance - :accepted\n presence - :blank\n length - :too_short (%{count})\n length - :too_long (%{count})\n length - :wrong_length (%{count})\n uniqueness - :taken\n format - :invalid\n numericality - :not_a_number\n\n\nform_for @post do\n f.label :body\n\n\nhelpers:\n # helpers.label.<model>.<field>\n label:\n post:\n body: \"Your body text\"\n\n\nform_for @post do\n f.submit\n\n\nhelpers:\n submit:\n # helpers.submit.<action>\n create: \"Create a %{model}\"\n update: \"Confirm changes to %{model}\"\n\n # helpers.submit.<model>.<action>\n article:\n create: \"Publish article\"\n update: \"Update article\"\n\n\nnumber_to_delimited(2000) #=> \"2,000\"\nnumber_to_currency(12.3) #=> \"$12.30\"\nnumber_to_percentage(0.3) #=> \"30%\"\nnumber_to_rounded(3.14, precision: 0) #=> \"3\"\nnumber_to_human(12_000) #=> \"12 Thousand\"\nnumber_to_human_size(12345) #=> \"12.3 kb\"\n\n\nnumber_to_delimited(n)\n\n\nnumber:\n format:\n separator: '.'\n delimiter: ','\n precision: 3\n significant: false\n strip_insignificant_zeroes: false\n\n\nnumber_to_currency(n)\n\n\nnumber:\n currency:\n format:\n format: \"%u%n\" # %u = unit, %n = number\n unit: \"$\"\n separator: '.'\n delimiter: ','\n precision: 3\n # (see number.format)\n\n\nnumber_to_percentage(n)\n\n\nnumber:\n percentage:\n format:\n format: \"%n%\"\n # (see number.format)\n\n\nI18n.backend.store_translations :en, ok: \"Ok\"\nI18n.locale = :en\nI18n.default_locale = :en\n\nI18n.available_locales\n\nI18n.translate :ok # aka, I18n.t\nI18n.localize date # aka, I18n.l\n",
"intro_html": "",
"description_html": "",
"tags": null,
"updated": null
},{
"id": "rails-migrations",
- "title": "Migrations",
+ "title": "Rails migrations",
"url": "/rails-migrations",
"category": "Rails",
"keywords": null,
@@ -2755,7 +2755,7 @@
"url": "/rails-plugins",
"category": "Rails",
"keywords": null,
- "content_html": "Generate a Rails Engine plugin:
\n\nrails plugin new myplugin --skip-bundle --full\n\n\nSubclass Railtie and provide an initializer method.
module NewPlugin\n class Railtie < Rails::Railtie\n initializer \"newplugin.initialize\" do |app|\n \n # subscribe to all rails notifications: controllers, AR, etc.\n ActiveSupport::Notifications.subscribe do |*args|\n event = ActiveSupport::Notifications::Event.new(*args)\n puts \"Got notification: #{event.inspect}\"\n end\n \n end\n end\nend\n\n\nTo create custom routes.rb keywords:
# # routes.rb:\n# myplugin_for x\n#\nclass ActionDispatch::Routing\n class Mapper\n def myplugin_for(*x)\n end\n end\nend\n\n\nExample with a block:
\n\n# authenticated do\n# resources :users\n# end\n#\ndef authenticated\n constraint = lambda { |request| request... }\n\n constraints(constraint) { yield }\nend\n\n\n# rails g initializer\n# lib/generators/initializer_generator.rb\nclass InitializerGenerator < Rails::Generators::Base\n def create_initializer_file\n create_file \"config/initializers/initializer.rb\", \"# Add initialization content here\"\n end\nend\n\n\nRails::Generators::Base.$ rails generate generator initializer\n\n\nUse NamedBase instead if you want to take an argument. It will be available as \nfile_name.
class InitializerGenerator < Rails::Generators::Base\n def lol\n puts file_name\n end\nend\n\n\nclass InitializerGenerator < Rails::Generators::NamedBase\n # \n source_root File.expand_path(\"../templates\", __FILE__)\n desc \"Description goes here.\"\nend\n\n\nWhen invoking rails g XXX:
[rails/]generators/XXX/XXX_generator.rb\n[rails/]generators/XXX_generator.rb\n\n\nWhen invoking rails g XXX:YYY:
[rails/]generators/XXX/YYY_generator.rb\n\n\n# yaffle/lib/yaffle/acts_as_yaffle.rb\nmodule Yaffle\n module ActsAsYaffle\n extend ActiveSupport::Concern\n \n included do\n end\n \n module ClassMethods\n def acts_as_yaffle(options = {})\n # your code will go here\n end\n end\n end\nend\n \nActiveRecord::Base.send :include, Yaffle::ActsAsYaffle\n",
+ "content_html": "Generate a Rails Engine plugin:
\n\nrails plugin new myplugin --skip-bundle --full\n\n\nSubclass Railtie and provide an initializer method.
module NewPlugin\n class Railtie < Rails::Railtie\n initializer \"newplugin.initialize\" do |app|\n \n # subscribe to all rails notifications: controllers, AR, etc.\n ActiveSupport::Notifications.subscribe do |*args|\n event = ActiveSupport::Notifications::Event.new(*args)\n puts \"Got notification: #{event.inspect}\"\n end\n \n end\n end\nend\n\n\nTo create custom routes.rb keywords:
# # routes.rb:\n# myplugin_for x\n#\nclass ActionDispatch::Routing\n class Mapper\n def myplugin_for(*x)\n end\n end\nend\n\n\nExample with a block:
\n\n# authenticated do\n# resources :users\n# end\n#\ndef authenticated\n constraint = lambda { |request| request... }\n\n constraints(constraint) { yield }\nend\n\n\n# rails g initializer\n# lib/generators/initializer_generator.rb\nclass InitializerGenerator < Rails::Generators::Base\n def create_initializer_file\n create_file \"config/initializers/initializer.rb\", \"# Add initialization content here\"\n end\nend\n\n\nRails::Generators::Base.$ rails generate generator initializer\n\n\nUse NamedBase instead if you want to take an argument. It will be available as \nfile_name.
class InitializerGenerator < Rails::Generators::Base\n def lol\n puts file_name\n end\nend\n\n\nclass InitializerGenerator < Rails::Generators::NamedBase\n # \n source_root File.expand_path(\"../templates\", __FILE__)\n desc \"Description goes here.\"\nend\n\n\nWhen invoking rails g XXX:
[rails/]generators/XXX/XXX_generator.rb\n[rails/]generators/XXX_generator.rb\n\n\nWhen invoking rails g XXX:YYY:
[rails/]generators/XXX/YYY_generator.rb\n\n\n# yaffle/lib/yaffle/acts_as_yaffle.rb\nmodule Yaffle\n module ActsAsYaffle\n extend ActiveSupport::Concern\n \n included do\n end\n \n module ClassMethods\n def acts_as_yaffle(options = {})\n # your code will go here\n end\n end\n end\nend\n \nActiveRecord::Base.send :include, Yaffle::ActsAsYaffle\n",
"intro_html": "",
"description_html": "",
"tags": null,
@@ -2766,7 +2766,7 @@
"url": "/rails-routes",
"category": "Rails",
"keywords": null,
- "content_html": "resources)resources :photos\n\n# PhotosController:\n# index => GET /photos\n# new => GET /photos/new\n# create => POST /photos/new\n# show => GET /photos/:id\n# edit => GET /photos/:id/edit\n# update => PUT /photos/:id\n# delete => DELETE /photos/:id\n#\n# Helpers:\n# new_photo_path\n# photo_path(id)\n# edit_photo_path(id)\n\n\nresources :photos do\n member { get 'preview' } # /photo/1/preview\n collection { get 'search' } # /photos/search\n\n get 'preview', on: :member # (..same as the first)\nend\n\n\nresources :photos,\n path_names: { new: 'brand_new' } # /photos/1/brand_new\n path: 'postings' # /postings\n only: :index\n only: [:index, :show]\n except: :show\n except: [:index, :show]\n\n shallow: true # also generate shallow routes\n shalow_path: 'secret'\n shallow_prefix: 'secret'\n\n\nresource)resource :coder\n\n# CodersController:\n# new => GET /coder/new\n# create => POST /coder/new\n# show => GET /coder\n# edit => GET /coder/edit\n# update => PUT /coder\n# delete => DELETE /coder\n\n\nmatch)match 'photo/:id' => 'photos#show' # /photo/what-is-it\nmatch 'photo/:id', id: /[0-9]+/ # /photo/0192\nmatch 'photo/:id' => 'photos#show', constraints: { id: /[0-9]+/ }\nmatch 'photo/:id', via: :get\nmatch 'photo/:id', via: [:get, :post]\n\nmatch 'photo/*path' => 'photos#unknown' # /photo/what/ever\n\n# params[:format] == 'jpg'\nmatch 'photos/:id' => 'photos#show', :defaults => { :format => 'jpg' }\n\n\nget is the same as match via: :get.
get 'photo/:id' => 'photos#show'\n# same as match 'photo/:id' => 'photos#show', via: :get\n\npost 'photo/:id' => 'photos#update'\n# same as match 'photo/:id' => 'photos#show', via: :post\n\n\nmatch '/stories' => redirect('/posts')\nmatch '/stories/:name' => redirect('/posts/%{name}')\n\n\n# logout_path\nmatch 'exit' => 'sessions#destroy', as: :logout\n\n\nmatch '/', constraints: { subdomain: 'admin' }\n\n# admin.site.com/admin/photos\nnamespace 'admin' do\n constraints subdomain: 'admin' do\n resources :photos\n end\nend\n\n\nclass BlacklistConstraint\n def initialize\n @ips = Blacklist.retrieve_ips\n end\n \n def matches?(request)\n @ips.include?(request.remote_ip)\n end\nend\n \nTwitterClone::Application.routes.draw do\n match \"*path\" => \"blacklist#index\",\n :constraints => BlacklistConstraint.new\nend\n\n\nscope 'admin', constraints: { subdomain: 'admin' } do\n resources ...\nend\n\n\n# Yes, Sprockets is middleware\nmatch '/application.js' => Sprockets\n\n\nprojects_path # /projects\nprojects_url # http://site.com/projects\n\n\n# The priority is based upon order of creation:\n# first created -> highest priority.\n\n# Sample of regular route:\nmatch 'products/:id' => 'catalog#view'\n\n# Keep in mind you can assign values other than :controller and :action\n\n# Sample of named route:\nmatch 'products/:id/purchase' => 'catalog#purchase', :as => :purchase\n\n# This route can be invoked with purchase_url(:id => product.id)\n\n# Sample resource route (maps HTTP verbs to controller actions automatically):\nresources :products\n\n# Sample resource route with options:\nresources :products do\n member do\n get 'short'\n post 'toggle'\n end\n\n collection do\n get 'sold'\n end\nend\n\n# Sample resource route with sub-resources:\nresources :products do\n resources :comments, :sales\n resource :seller\nend\n\n# Sample resource route with more complex sub-resources\nresources :products do\n resources :comments\n resources :sales do\n get 'recent', :on => :collection\n end\nend\n\n# Sample resource route within a namespace:\nnamespace :admin do\n # Directs /admin/products/* to Admin::ProductsController\n # (app/controllers/admin/products_controller.rb)\n resources :products\nend\n\n# You can have the root of your site routed with \"root\"\n# just remember to delete public/index.html.\nroot :to => 'welcome#index'\n\n# See how all your routes lay out with \"rake routes\"\n\n# This is a legacy wild controller route that's not recommended for RESTful applications.\n# Note: This route will make all actions in every controller accessible via GET requests.\nmatch ':controller(/:action(/:id(.:format)))'\n\n\nActionDispatch::Routing::Mapper\n (See included modules)
\nresources)resources :photos\n\n# PhotosController:\n# index => GET /photos\n# new => GET /photos/new\n# create => POST /photos/new\n# show => GET /photos/:id\n# edit => GET /photos/:id/edit\n# update => PUT /photos/:id\n# delete => DELETE /photos/:id\n#\n# Helpers:\n# new_photo_path\n# photo_path(id)\n# edit_photo_path(id)\n\n\nresources :photos do\n member { get 'preview' } # /photo/1/preview\n collection { get 'search' } # /photos/search\n\n get 'preview', on: :member # (..same as the first)\nend\n\n\nresources :photos,\n path_names: { new: 'brand_new' } # /photos/1/brand_new\n path: 'postings' # /postings\n only: :index\n only: [:index, :show]\n except: :show\n except: [:index, :show]\n\n shallow: true # also generate shallow routes\n shalow_path: 'secret'\n shallow_prefix: 'secret'\n\n\nresource)resource :coder\n\n# CodersController:\n# new => GET /coder/new\n# create => POST /coder/new\n# show => GET /coder\n# edit => GET /coder/edit\n# update => PUT /coder\n# delete => DELETE /coder\n\n\nmatch)match 'photo/:id' => 'photos#show' # /photo/what-is-it\nmatch 'photo/:id', id: /[0-9]+/ # /photo/0192\nmatch 'photo/:id' => 'photos#show', constraints: { id: /[0-9]+/ }\nmatch 'photo/:id', via: :get\nmatch 'photo/:id', via: [:get, :post]\n\nmatch 'photo/*path' => 'photos#unknown' # /photo/what/ever\n\n# params[:format] == 'jpg'\nmatch 'photos/:id' => 'photos#show', :defaults => { :format => 'jpg' }\n\n\nget is the same as match via: :get.
get 'photo/:id' => 'photos#show'\n# same as match 'photo/:id' => 'photos#show', via: :get\n\npost 'photo/:id' => 'photos#update'\n# same as match 'photo/:id' => 'photos#show', via: :post\n\n\nmatch '/stories' => redirect('/posts')\nmatch '/stories/:name' => redirect('/posts/%{name}')\n\n\n# logout_path\nmatch 'exit' => 'sessions#destroy', as: :logout\n\n\nmatch '/', constraints: { subdomain: 'admin' }\n\n# admin.site.com/admin/photos\nnamespace 'admin' do\n constraints subdomain: 'admin' do\n resources :photos\n end\nend\n\n\nclass BlacklistConstraint\n def initialize\n @ips = Blacklist.retrieve_ips\n end\n \n def matches?(request)\n @ips.include?(request.remote_ip)\n end\nend\n \nTwitterClone::Application.routes.draw do\n match \"*path\" => \"blacklist#index\",\n :constraints => BlacklistConstraint.new\nend\n\n\nscope 'admin', constraints: { subdomain: 'admin' } do\n resources ...\nend\n\n\n# Yes, Sprockets is middleware\nmatch '/application.js' => Sprockets\n\n\nprojects_path # /projects\nprojects_url # http://site.com/projects\n\n\n# The priority is based upon order of creation:\n# first created -> highest priority.\n\n# Sample of regular route:\nmatch 'products/:id' => 'catalog#view'\n\n# Keep in mind you can assign values other than :controller and :action\n\n# Sample of named route:\nmatch 'products/:id/purchase' => 'catalog#purchase', :as => :purchase\n\n# This route can be invoked with purchase_url(:id => product.id)\n\n# Sample resource route (maps HTTP verbs to controller actions automatically):\nresources :products\n\n# Sample resource route with options:\nresources :products do\n member do\n get 'short'\n post 'toggle'\n end\n\n collection do\n get 'sold'\n end\nend\n\n# Sample resource route with sub-resources:\nresources :products do\n resources :comments, :sales\n resource :seller\nend\n\n# Sample resource route with more complex sub-resources\nresources :products do\n resources :comments\n resources :sales do\n get 'recent', :on => :collection\n end\nend\n\n# Sample resource route within a namespace:\nnamespace :admin do\n # Directs /admin/products/* to Admin::ProductsController\n # (app/controllers/admin/products_controller.rb)\n resources :products\nend\n\n# You can have the root of your site routed with \"root\"\n# just remember to delete public/index.html.\nroot :to => 'welcome#index'\n\n# See how all your routes lay out with \"rake routes\"\n\n# This is a legacy wild controller route that's not recommended for RESTful applications.\n# Note: This route will make all actions in every controller accessible via GET requests.\nmatch ':controller(/:action(/:id(.:format)))'\n\n\nActionDispatch::Routing::Mapper\n (See included modules)
\nin config/environments/development.rb:
\n\n# Source maps for Sass\nconfig.sass.debug_info = true\nconfig.sass.line_comments = false\n\n# Don't break apart\nconfig.assets.debug = false\n\n\nPartial locals
\n\n<%= render 'article', full: true %>\n<%= render 'article' %>\n\n<% if local_assigns[:full] %>\n ...\n<% end %>\n\n\nHTML in i18n
\n\nen:\n read_more_html: \"read <b>more</b>...\"\n\n\nException handling:
\n\n# config/application.rb\nconfig.exceptions_app = self.routes\n\nget '/404', to: 'errors#not_found'\nget '/500', to: 'errors#server_error'\n\nclass ErrorsController\n def not_found\n render status: :not_found\n end\n end\n\n\nRails updating:
\n\nrake rails:update\n\n\nDistinct pluck:
\n\nArticle.distinct.pluck('author')\n\n\nRelation#merge
\n\nscope :with_drafts, -> {\n uniq.joins(:articles).merge(Article.draft)\n}\n\n\nOrder
\n\nscope :recent, -> { order created_at: :desc }\n\n\nGroup by month
\n\n.group(\"to_char(created_at, 'YYYY-MM')\")\n.group(\"to_char(created_at, 'YYYY-MM')\").count\n",
+ "content_html": "in config/environments/development.rb:
\n\n# Source maps for Sass\nconfig.sass.debug_info = true\nconfig.sass.line_comments = false\n\n# Don't break apart\nconfig.assets.debug = false\n\n\n<%= render 'article', full: true %>\n<%= render 'article' %>\n\n<% if local_assigns[:full] %>\n ...\n<% end %>\n\n\nen:\n read_more_html: \"read <b>more</b>...\"\n\n\n# config/application.rb\nconfig.exceptions_app = self.routes\n\nget '/404', to: 'errors#not_found'\nget '/500', to: 'errors#server_error'\n\nclass ErrorsController\n def not_found\n render status: :not_found\n end\n end\n\n\nrake rails:update\n\n\nArticle.distinct.pluck('author')\n\n\nscope :with_drafts, -> {\n uniq.joins(:articles).merge(Article.draft)\n}\n\n\nscope :recent, -> { order created_at: :desc }\n\n\n.group(\"to_char(created_at, 'YYYY-MM')\")\n.group(\"to_char(created_at, 'YYYY-MM')\").count\n",
"intro_html": "",
"description_html": "",
- "tags": null,
+ "tags": ["Archived"],
"updated": null
},{
"id": "rails",
@@ -3360,7 +3360,7 @@
"url": "/tape",
"category": "JavaScript libraries",
"keywords": null,
- "content_html": "test('things', (t) => {\n t.plan(1)\n\n t.equal('actual', 'expected')\n t.equal('actual', 'expected', 'should be equal') // messages are optional\n\n t.end(err)\n t.fail('msg')\n t.pass('msg')\n t.timeoutAfter(2000)\n t.skip('msg')\n\n t.ok(value, 'is truthy')\n t.notOk(value, 'is falsy')\n t.error(err, 'is falsy (print err.message)')\n\n t.equal(actual, expected, 'is equal')\n t.notEqual\n\n t.deepEqual(actual, expected, 'is equal (use node's deepEqual)')\n t.notDeepEqual\n\n t.looseEqual(actual, expected, 'is equal (use node's deepEqual with ==)')\n t.notLooseEqual\n\n t.throws(fn, /FooError/)\n t.throws(fn, FooError /* class */)\n t.doesNotThrow\n\n t.comment('message')\n})\n\n\ntest.only((t) => { ... })\n",
+ "content_html": "test('things', (t) => {\n t.plan(1)\n\n t.equal('actual', 'expected')\n t.equal('actual', 'expected', 'should be equal') // messages are optional\n\n t.end(err)\n t.fail('msg')\n t.pass('msg')\n t.timeoutAfter(2000)\n t.skip('msg')\n\n t.ok(value, 'is truthy')\n t.notOk(value, 'is falsy')\n t.error(err, 'is falsy (print err.message)')\n\n t.equal(actual, expected, 'is equal')\n t.notEqual\n\n t.deepEqual(actual, expected, 'is equal (use node's deepEqual)')\n t.notDeepEqual\n\n t.looseEqual(actual, expected, 'is equal (use node's deepEqual with ==)')\n t.notLooseEqual\n\n t.throws(fn, /FooError/)\n t.throws(fn, FooError /* class */)\n t.doesNotThrow\n\n t.comment('message')\n})\n\n\ntest.only((t) => { ... })\n",
"intro_html": "",
"description_html": "",
"tags": null,
diff --git a/datetime.html b/datetime.html
index ec8c10878..9a891b41c 100644
--- a/datetime.html
+++ b/datetime.html
@@ -33,8 +33,8 @@
-
-
+
+
@@ -103,11 +103,11 @@ gtag('config','UA-106902774-1');
@@ -1038,7 +1038,7 @@ function n(n,t,e){n.addEventListener?n.addEventListener(t,e):n.attachEvent("on"+
},{}],"eoMl":[function(require,module,exports) {
"use strict";var e=u(require("./wrapify")),d=u(require("dom101/add-class")),t=u(require("dom101/on"));function u(e){return e&&e.__esModule?e:{default:e}}var a,o=document.querySelector("[data-js-main-body]");function r(){a||((0,d.default)(document.documentElement,"LoadDone"),a=!0)}o&&((0,e.default)(o),(0,d.default)(o,"-wrapified")),(0,t.default)(window,"load",r),setTimeout(r,5e3);
},{"./wrapify":"hE9p","dom101/add-class":"G20n","dom101/on":"DJ2P"}]},{},["eoMl"], null)
-
+
diff --git a/deis.html b/deis.html
index 6071f5cf7..48c79deda 100644
--- a/deis.html
+++ b/deis.html
@@ -33,8 +33,8 @@
-
-
+
+
@@ -99,11 +99,11 @@ gtag('config','UA-106902774-1');
@@ -399,6 +399,8 @@ deis limits:set web=1024 --cpu
cheatsheet
+
+
@@ -548,7 +550,7 @@ function n(n,t,e){n.addEventListener?n.addEventListener(t,e):n.attachEvent("on"+
},{}],"eoMl":[function(require,module,exports) {
"use strict";var e=u(require("./wrapify")),d=u(require("dom101/add-class")),t=u(require("dom101/on"));function u(e){return e&&e.__esModule?e:{default:e}}var a,o=document.querySelector("[data-js-main-body]");function r(){a||((0,d.default)(document.documentElement,"LoadDone"),a=!0)}o&&((0,e.default)(o),(0,d.default)(o,"-wrapified")),(0,t.default)(window,"load",r),setTimeout(r,5e3);
},{"./wrapify":"hE9p","dom101/add-class":"G20n","dom101/on":"DJ2P"}]},{},["eoMl"], null)
-
+
diff --git a/deku.html b/deku.html
index d21caa6c6..cc5c412cb 100644
--- a/deku.html
+++ b/deku.html
@@ -33,8 +33,8 @@
-
-
+
+
@@ -99,11 +99,11 @@ gtag('config','UA-106902774-1');
@@ -538,7 +538,7 @@ function n(n,t,e){n.addEventListener?n.addEventListener(t,e):n.attachEvent("on"+
},{}],"eoMl":[function(require,module,exports) {
"use strict";var e=u(require("./wrapify")),d=u(require("dom101/add-class")),t=u(require("dom101/on"));function u(e){return e&&e.__esModule?e:{default:e}}var a,o=document.querySelector("[data-js-main-body]");function r(){a||((0,d.default)(document.documentElement,"LoadDone"),a=!0)}o&&((0,e.default)(o),(0,d.default)(o,"-wrapified")),(0,t.default)(window,"load",r),setTimeout(r,5e3);
},{"./wrapify":"hE9p","dom101/add-class":"G20n","dom101/on":"DJ2P"}]},{},["eoMl"], null)
-
+
diff --git a/deku@1.html b/deku@1.html
index 99e732902..90e13d7a7 100644
--- a/deku@1.html
+++ b/deku@1.html
@@ -33,8 +33,8 @@
-
-
+
+
@@ -99,11 +99,11 @@ gtag('config','UA-106902774-1');
@@ -584,7 +584,7 @@ function n(n,t,e){n.addEventListener?n.addEventListener(t,e):n.attachEvent("on"+
},{}],"eoMl":[function(require,module,exports) {
"use strict";var e=u(require("./wrapify")),d=u(require("dom101/add-class")),t=u(require("dom101/on"));function u(e){return e&&e.__esModule?e:{default:e}}var a,o=document.querySelector("[data-js-main-body]");function r(){a||((0,d.default)(document.documentElement,"LoadDone"),a=!0)}o&&((0,e.default)(o),(0,d.default)(o,"-wrapified")),(0,t.default)(window,"load",r),setTimeout(r,5e3);
},{"./wrapify":"hE9p","dom101/add-class":"G20n","dom101/on":"DJ2P"}]},{},["eoMl"], null)
-
+
diff --git a/deprecated/bower-api.html b/deprecated/bower-api.html
index c0dba17d5..0308bb4de 100644
--- a/deprecated/bower-api.html
+++ b/deprecated/bower-api.html
@@ -33,8 +33,8 @@
-
-
+
+
@@ -99,11 +99,11 @@ gtag('config','UA-106902774-1');
@@ -519,7 +519,7 @@ function n(n,t,e){n.addEventListener?n.addEventListener(t,e):n.attachEvent("on"+
},{}],"eoMl":[function(require,module,exports) {
"use strict";var e=u(require("./wrapify")),d=u(require("dom101/add-class")),t=u(require("dom101/on"));function u(e){return e&&e.__esModule?e:{default:e}}var a,o=document.querySelector("[data-js-main-body]");function r(){a||((0,d.default)(document.documentElement,"LoadDone"),a=!0)}o&&((0,e.default)(o),(0,d.default)(o,"-wrapified")),(0,t.default)(window,"load",r),setTimeout(r,5e3);
},{"./wrapify":"hE9p","dom101/add-class":"G20n","dom101/on":"DJ2P"}]},{},["eoMl"], null)
-
+
diff --git a/devise.html b/devise.html
index 9d766c870..829b0cb9b 100644
--- a/devise.html
+++ b/devise.html
@@ -1,7 +1,7 @@
-
-
-
+
+
+
@@ -33,8 +33,8 @@
-
-
+
+
@@ -85,25 +85,26 @@ gtag('config','UA-106902774-1');
-
+
-
-
-
-
-
-
--
Devise is a flexible authentication
+
+
+
+
+
+
+ Devise is a flexible authentication
gem. Rails 3: Add the following to your GemfileAbout
+
+Installation
+
+
+Installation
-$ rails generate devise:views
Helpers
+Helpers
-user_signed_in?
current_user
@@ -199,7 +252,7 @@ edit_user_registration_path (Edit registration)
new_user_registration_path (Register new user)
Controller stuff
+Controller stuff
@@ -287,55 +340,305 @@ end
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
- Devhints.io cheatsheets is a collection of cheatsheets I've written over the years. - Suggestions and corrections? Send them in. - - I'm Rico Sta. Cruz. - Check out my Today I learned blog for more. -
- - - --
+ +-
Most of these magic is defined in Kernel.SpecialForms.
@@ -185,48 +232,295 @@ __CALLER__ # caller of the functionapply(Enum, :reverse, [[1, 2, 3]])
+ - Devhints.io cheatsheets is a collection of cheatsheets I've written over the years. - Suggestions and corrections? Send them in. - - I'm Rico Sta. Cruz. - Check out my Today I learned blog for more. -
- - - --
+ +-
- Devhints.io cheatsheets is a collection of cheatsheets I've written over the years. - Suggestions and corrections? Send them in. - - I'm Rico Sta. Cruz. - Check out my Today I learned blog for more. -
- - - --
+ +-
Flux is an architecture for building client-side web applications.
+ +- Devhints.io cheatsheets is a collection of cheatsheets I've written over the years. - Suggestions and corrections? Send them in. - - I'm Rico Sta. Cruz. - Check out my Today I learned blog for more. -
- - - --
+ +-
HEAD^ # 1 commit before head
HEAD^^ # 2 commits before head
HEAD~5 # 5 commits before head
-# create a new branch
git checkout -b $branchname
@@ -190,7 +237,7 @@ HEAD~5 # 5 commits before head
git checkout -
-# Rebase your changes on top of the remote master
git pull --rebase upstream master
@@ -202,6 +249,8 @@ HEAD~5 # 5 commits before head
Submodules
+Submodules
+
# Import .gitmodules
git submodule init
@@ -230,6 +279,8 @@ app/b.txt | 8 ++----
Log options
+Options
+
--oneline
e11e9f9 Commit message here
@@ -296,14 +347,14 @@ git bisect bad # current version is bad
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
@@ -314,48 +365,295 @@ git commit -m "Implement feature Y" --no-gpg-sign # Do not sign
+
- Devhints.io cheatsheets is a collection of cheatsheets I've written over the years. - Suggestions and corrections? Send them in. - - I'm Rico Sta. Cruz. - Check out my Today I learned blog for more. -
- - - --
+ +-
- Devhints.io cheatsheets is a collection of cheatsheets I've written over the years. - Suggestions and corrections? Send them in. - - I'm Rico Sta. Cruz. - Check out my Today I learned blog for more. -
- - - --
+ +ansible
+
+
Ansible
@@ -6935,6 +6937,8 @@ gtag('config','UA-106902774-1');
postgresql
+
+
PostgreSQL
@@ -7345,6 +7349,8 @@ gtag('config','UA-106902774-1');
circle
+
+
CircleCI
@@ -8305,6 +8311,8 @@ gtag('config','UA-106902774-1');
elixir-metaprogramming
+
+
Elixir metaprogramming
@@ -8711,6 +8719,8 @@ gtag('config','UA-106902774-1');
phoenix-ecto@1.2
+
+
Phoenix: Ecto models
@@ -9379,6 +9389,8 @@ gtag('config','UA-106902774-1');
git-tricks
+
+
Git tricks
@@ -12639,6 +12651,8 @@ gtag('config','UA-106902774-1');
angularjs
+
+
Angular.js
@@ -12917,6 +12931,8 @@ gtag('config','UA-106902774-1');
commander.js
+
+
Commander.js
@@ -13213,6 +13229,8 @@ gtag('config','UA-106902774-1');
gulp
+
+
Gulp
@@ -13701,6 +13719,8 @@ gtag('config','UA-106902774-1');
mocha-html
+
+
Mocha HTML
@@ -13719,6 +13739,8 @@ gtag('config','UA-106902774-1');
mocha-tdd
+
+
Mocha.js TDD interface
@@ -13855,6 +13877,8 @@ gtag('config','UA-106902774-1');
nopt
+
+
Nopt
@@ -13885,6 +13909,8 @@ gtag('config','UA-106902774-1');
parsimmon
+
+
Parsimmon
@@ -14365,6 +14391,8 @@ gtag('config','UA-106902774-1');
tape
+
+
Tape
@@ -15803,6 +15831,8 @@ gtag('config','UA-106902774-1');
ledger-examples
+
+
Ledger examples
@@ -15821,6 +15851,8 @@ gtag('config','UA-106902774-1');
ledger-format
+
+
Ledger format
@@ -15839,6 +15871,8 @@ gtag('config','UA-106902774-1');
ledger-periods
+
+
Ledger periods
@@ -20045,6 +20079,8 @@ gtag('config','UA-106902774-1');
python
+
+
Python
@@ -20335,6 +20371,8 @@ gtag('config','UA-106902774-1');
arel
+
+
Arel
@@ -20809,8 +20847,10 @@ gtag('config','UA-106902774-1');
rails-controllers
+
+
- Controllers
+ Rails controllers
@@ -20827,8 +20867,10 @@ gtag('config','UA-106902774-1');
rails-forms
+
+
- Form helpers
+ Rails form helpers
@@ -20845,8 +20887,10 @@ gtag('config','UA-106902774-1');
rails-helpers
+
+
- Helpers
+ Rails helpers
@@ -20863,8 +20907,10 @@ gtag('config','UA-106902774-1');
rails-i18n
+
+
- i18n
+ Rails i18n
@@ -20881,8 +20927,10 @@ gtag('config','UA-106902774-1');
rails-migrations
+
+
- Migrations
+ Rails migrations
@@ -20919,6 +20967,8 @@ gtag('config','UA-106902774-1');
rails-plugins
+
+
Rails plugins
@@ -20937,6 +20987,8 @@ gtag('config','UA-106902774-1');
rails-routes
+
+
Routes
@@ -20955,6 +21007,8 @@ gtag('config','UA-106902774-1');
rails-tricks
+
+
Rails tricks
@@ -21447,6 +21501,8 @@ gtag('config','UA-106902774-1');
flux
+
+
Flux architecture
@@ -24431,6 +24487,8 @@ gtag('config','UA-106902774-1');
projectionist
+
+
Projectionist
@@ -25747,6 +25805,8 @@ gtag('config','UA-106902774-1');
cask-index
+
+
Caskroom index
@@ -25799,6 +25859,8 @@ gtag('config','UA-106902774-1');
command_line
+
+
Command line stuff
@@ -25887,6 +25949,8 @@ gtag('config','UA-106902774-1');
devise
+
+
Devise
@@ -26013,6 +26077,8 @@ gtag('config','UA-106902774-1');
firefox
+
+
Firefox
@@ -26359,6 +26425,8 @@ gtag('config','UA-106902774-1');
lua
+
+
Lua
@@ -26381,6 +26449,8 @@ gtag('config','UA-106902774-1');
make-assets
+
+
Make for assets
@@ -27143,7 +27213,7 @@ function n(n,t,e){n.addEventListener?n.addEventListener(t,e):n.attachEvent("on"+
},{}],"eoMl":[function(require,module,exports) {
"use strict";var e=u(require("./wrapify")),d=u(require("dom101/add-class")),t=u(require("dom101/on"));function u(e){return e&&e.__esModule?e:{default:e}}var a,o=document.querySelector("[data-js-main-body]");function r(){a||((0,d.default)(document.documentElement,"LoadDone"),a=!0)}o&&((0,e.default)(o),(0,d.default)(o,"-wrapified")),(0,t.default)(window,"load",r),setTimeout(r,5e3);
},{"./wrapify":"hE9p","dom101/add-class":"G20n","dom101/on":"DJ2P"}]},{},["eoMl"], null)
-
+
diff --git a/index@2016.html b/index@2016.html
index 8c719cff5..a36305c12 100644
--- a/index@2016.html
+++ b/index@2016.html
@@ -33,8 +33,8 @@
-
-
+
+
@@ -90,9 +90,9 @@ gtag('config','UA-106902774-1');
-
-
-
+
+
+
-
Inspecting transactions:
+ + + + + + +# show me expenses for october (--period)
ledger r Expenses -p oct
@@ -179,7 +226,7 @@ gtag('config','UA-106902774-1');
ledger r mastercard -b 01/25 -e 01/31
-Graphing:
+# Graph my bank account balance, monthly
ledger r Savings -M
@@ -191,7 +238,7 @@ gtag('config','UA-106902774-1');
ledger r Expenses -M -n --average
-Simple:
+# what did I do yesterday?
# ..list transactions on this day
@@ -199,54 +246,301 @@ gtag('config','UA-106902774-1');
ledger r -p yesterday
-Switches:
+# what's everything I got in USD? (--exchange)
ledger b Assets -X USD
+ - Devhints.io cheatsheets is a collection of cheatsheets I've written over the years. - Suggestions and corrections? Send them in. - - I'm Rico Sta. Cruz. - Check out my Today I learned blog for more. -
- - - --
+ +-
2015/01/01 Pay rent
+
+
+
+
+
+
+
+ Example
+2015/01/01 Pay rent
Assets:Savings -$300
Expenses:Rent
@@ -185,6 +233,9 @@ Date Flag Description ^ comment/tag
Only relevant with --strict or --pedantic
account Expenses:Food
@@ -199,6 +250,8 @@ Date Flag Description ^ comment/tag
Others
+Others
+
D $1,000.00 ; set default commodity
alias Cash = Assets:Cash
@@ -213,48 +266,295 @@ include home.journal
end
+
+- Devhints.io cheatsheets is a collection of cheatsheets I've written over the years. - Suggestions and corrections? Send them in. - - I'm Rico Sta. Cruz. - Check out my Today I learned blog for more. -
- - - --
+ +-
[INTERVAL] [BEGIN] [END]
+
+
+
+
+
+
+
+ About
+
+
+
+Usage
+
+[INTERVAL] [BEGIN] [END]
-Interval:
+Intervals
every day
every week
@@ -184,19 +239,19 @@ 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
@@ -209,55 +264,300 @@ next week
last week
-Examples:
+Examples
$ ledger r -p "since last month"
-See: http://ledger-cli.org/3.0/doc/ledger3.html#Period-Expressions
+
+- Devhints.io cheatsheets is a collection of cheatsheets I've written over the years. - Suggestions and corrections? Send them in. - - I'm Rico Sta. Cruz. - Check out my Today I learned blog for more. -
- - - --
+ +| Command | @@ -250,52 +299,299 @@ gtag('config','UA-106902774-1');
|---|
See vim-projectionist.
+ + + +- Devhints.io cheatsheets is a collection of cheatsheets I've written over the years. - Suggestions and corrections? Send them in. - - I'm Rico Sta. Cruz. - Check out my Today I learned blog for more. -
- - - --
+ +-
tuple = ()
@@ -326,48 +373,239 @@ file.close()
# It closes the file automatically at the end of scope, no need for `file.close()`.
+ - Devhints.io cheatsheets is a collection of cheatsheets I've written over the years. - Suggestions and corrections? Send them in. - - I'm Rico Sta. Cruz. - Check out my Today I learned blog for more. -
- - - --
+ +-
redirect_to root_url
redirect_to root_url, notice: "Good."
@@ -325,48 +372,295 @@ send_file Rails.root.join('public','filename.txt') [filename: '..', type: '..']
- HttpAuthentication::Token
+ - Devhints.io cheatsheets is a collection of cheatsheets I've written over the years. - Suggestions and corrections? Send them in. - - I'm Rico Sta. Cruz. - Check out my Today I learned blog for more. -
- - - --
+ +-
- form_for @post do |f|
@@ -289,50 +338,295 @@ submit(value=nil, options={})
+ - Devhints.io cheatsheets is a collection of cheatsheets I've written over the years. - Suggestions and corrections? Send them in. - - I'm Rico Sta. Cruz. - Check out my Today I learned blog for more. -
- - - --
+ +-
distance_of_time_in_words(Time.now, project.end_date) #=> 3 hours
distance_of_time_in_words_to_now(project.end_date) #=> 3 hours
@@ -264,48 +311,295 @@ t('x_files', count: files.count)
* http://api.rubyonrails.org/classes/ActionView/Helpers.html
+ - Devhints.io cheatsheets is a collection of cheatsheets I've written over the years. - Suggestions and corrections? Send them in. - - I'm Rico Sta. Cruz. - Check out my Today I learned blog for more. -
- - - --
+ +-
t('my.messages.hello')
+
+
+
+
+
+
+
+ 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
+
+t('my.messages.hello')
# same as 'my.messages.hello'
t(:hello, scope: 'my.messages')
@@ -169,6 +227,8 @@ t(:hello, scope: [:my, :messages])
t('my.messages.hello', default: "Hello")
+YAML
+
en:
my:
messages:
@@ -177,18 +237,22 @@ t('my.messages.hello', default: "Hello")
Interpolation
-t('hello', name: "John")
+t('hello', name: "John")
+YAML
+
hello: "Hello %{name}"
Lazy lookup
-# from the 'books/index' view
+# from the 'books/index' view
t('.title')
+YAML
+
en:
books:
index:
@@ -197,10 +261,12 @@ t('.title')
Plural
-t(:inbox, count: 1) #=> 'one message'
+t(:inbox, count: 1) #=> 'one message'
t(:inbox, count: 2) #=> '2 messages'
+YAML
+
inbox:
one: 'one message',
other: '%{count} messages'
@@ -210,10 +276,12 @@ t(:inbox, count: 2) #=> '2 messages'
Time
-l(Time.now)
+l(Time.now)
l(Time.now, format: :short)
+YAML
+
en:
time:
formats:
@@ -224,9 +292,11 @@ l(Time.now, format: :short)
Date
-l(Date.today)
+l(Date.today)
+YAML
+
en:
date:
formats:
@@ -239,10 +309,12 @@ l(Time.now, format: :short)
Model names
-User.model_name.human #=> "User"
+User.model_name.human #=> "User"
Child.model_name.human(count: 2) #=> "Children"
+YAML
+
en:
activerecord:
models:
@@ -254,9 +326,11 @@ Child.model_name.human(count: 2) #=> "Children"
Attributes
-User.human_attribute_for :name #=> "Name"
+User.human_attribute_for :name #=> "Name"
+YAML
+
en:
activerecord:
attributes:
@@ -268,9 +342,11 @@ Child.model_name.human(count: 2) #=> "Children"
Error messages
-error_messages_for(...)
+error_messages_for(...)
+YAML
+
activerecord:
errors:
models:
@@ -280,6 +356,8 @@ Child.model_name.human(count: 2) #=> "Children"
blank: "Please enter a name."
+Scopes
+
Possible scopes (in order):
activerecord.errors.models.[model_name].attributes.[attribute_name].[error]
@@ -305,10 +383,12 @@ errors.messages.[error]
Form labels
-form_for @post do
+
+ + 0 Comments + + for this cheatsheet. + Write yours! +
+