diff --git a/activeadmin.md b/activeadmin.md index 1253fb5b3..93f738f8a 100644 --- a/activeadmin.md +++ b/activeadmin.md @@ -8,6 +8,10 @@ Allows you to filter listings by a certain scope. scope :draft scope :for_approval + scope :public, if: ->{ current_admin_user.can?(...) } + scope "Unapproved", :pending + scope("Published") { |books| books.where(:published: true) } + ### Sidebar filters filter :email diff --git a/ansi.md b/ansi.md index 6769a64ed..323efd0d8 100644 --- a/ansi.md +++ b/ansi.md @@ -17,6 +17,11 @@ Where: 30-37 fg color 40-47 bg color + 1K clear line (to beginning of line) + 2K clear line (entire line) + 2J clear screen + 0;0H move cursor to 0;0 + Colors 0 black diff --git a/ansible-examples.md b/ansible-examples.md new file mode 100644 index 000000000..a140936aa --- /dev/null +++ b/ansible-examples.md @@ -0,0 +1,13 @@ +--- +title: Ansible examples +layout: default +--- + +### Examples + + * [Ruby]( https://github.com/chelsea/ansible-example-ruby/blob/master/roles/webserver/tasks/main.yml ) + + * [Postgres]( https://github.com/chelsea/ansible-example-ruby/blob/master/roles/db/tasks/main.yml ) + + https://github.com/tingtun/ansible-playbook-gitlab + diff --git a/ansible-guide.md b/ansible-guide.md new file mode 100644 index 000000000..f90693262 --- /dev/null +++ b/ansible-guide.md @@ -0,0 +1,80 @@ +--- +title: Ansible: getting started +layout: default +--- + +### Install Ansible + +~~~ sh +$ brew install ansible # OSX +$ [sudo] pip install ansible # elsewhere +~~~ + +### Start your project + +~~~ sh +~$ mkdir setup +~$ cd setup +~~~ + +### Create an inventory file + +This is a list of hosts you want to manage, grouped into groups. (Hint: try +using 127.0.0.1 to deploy to your local machine) + +~~~ dosini +# ~/setup/hosts + +[sites] +127.0.0.1 +192.168.0.1 +192.168.0.2 +192.168.0.3 +~~~ + +### Create your first Playbook + +~~~ yaml +# ~/setup/playbook.yml + +- hosts: 127.0.0.1 + user: root + tasks: + - name: install nginx + apt: pkg=nginx state=present + + - name: start nginx every bootup + service: name=nginx state=started enabled=yes + + - name: do something in the shell + shell: echo hello > /tmp/abc.txt + + - name: install bundler + gem: name=bundler state=latest +~~~ + +### Run it + +~~~ sh +~/setup$ ls +hosts +playbook.yml + +~/setup$ ansible-playbook -i hosts playbook.yml +PLAY [all] ******************************************************************** + +GATHERING FACTS *************************************************************** +ok: [127.0.0.1] + +TASK: [install nginx] ********************************************************* +ok: [127.0.0.1] + +TASK: start nginx every bootup] *********************************************** +ok: [127.0.0.1] +... +~~~ + +### Read more + + * http://lowendbox.com/blog/getting-started-with-ansible/ + * http://www.ansibleworks.com/docs/modules.html diff --git a/ansible-modules.md b/ansible-modules.md new file mode 100644 index 000000000..016eeb185 --- /dev/null +++ b/ansible-modules.md @@ -0,0 +1,60 @@ +--- +title: Ansible modules +layout: default +--- + +### Aptitude + + - apt_key: id=AC40B2F7 url="http://..." + state=present + + - apt: pkg=nodejs state=present + state=present # absent | latest + update_cache=yes + force=no + + - apt_repository: repo='deb https://... raring main' + state=present + +### file + + - file: + state=directory # file | link | hard | touch | absent + path=/etc/dir + owner=bin + group=wheel + mode=0644 + recurse=yes # mkdir -p + force=yes # ln -nfs + + - copy: + src=/app/config/nginx.conf + dest=/etc/nginx/nginx.conf + + - template: + src=config/redis.j2 + dest=/etc/redis.conf + +### git + + - git: repo=git://github.com/ + dest=/srv/checkout + version=master + depth=10 + bare=yes + +### user + - user: state=present name=git + system=yes + shell=/bin/sh + comment="Git Version Control" + +### service + + - service: name=nginx state=started [enabled=yes] + +### shell + + - shell: apt-get install nginx -y + - script: /x/y/script.sh + diff --git a/ansible-roles.md b/ansible-roles.md new file mode 100644 index 000000000..c55641dff --- /dev/null +++ b/ansible-roles.md @@ -0,0 +1,20 @@ +--- +title: Ansible roles +layout: default +--- + +### Structure + + roles/ + common/ + tasks/ + handlers/ + files/ # 'copy' will refer to this + templates/ # 'template' will refer to this + meta/ # Role dependencies here + vars/ + defaults/main.yml + +### References + + * http://www.ansibleworks.com/docs/playbooks_roles.html diff --git a/ansible.md b/ansible.md new file mode 100644 index 000000000..2c27bff2d --- /dev/null +++ b/ansible.md @@ -0,0 +1,96 @@ +--- +title: Ansible +layout: default +--- + +## Getting started + +### Hosts + + $ sudo mkdir /etc/ansible + $ sudo vim /etc/ansible/hosts + + [example] + 192.0.2.101 + 192.0.2.102 + +### Running a playbook + + $ ansible-playbook playbook.yml + +## Tasks + + - hosts: all + user: root + sudo: no + vars: + aaa: bbb + tasks: + - ... + handlers: + - ... + +### Includes + + tasks: + - include: db.yml + handlers: + - include: db.yml user=timmy + +## Handlers + + handlers: + - name: start apache2 + action: service name=apache2 state=started + + tasks: + - name: install apache + action: apt pkg=apache2 state=latest + notify: + - start apache2 + +## Vars + + - host: lol + vars_files: + - vars.yml + vars: + project_root: /etc/xyz + tasks: + - name: Create the SSH directory. + file: state=directory path=${project_root}/home/.ssh/ + only_if: "$vm == 0" + +## Roles + + - host: xxx + roles: + - db + - { role:ruby, sudo_user:$user } + - web + + # Uses: + # roles/db/tasks/*.yml + # roles/db/handlers/*.yml + +### Task: Failures + + - name: my task + command: ... + register: result + failed_when: "'FAILED' in result.stderr" + + ignore_errors: yes + + changed_when: "result.rc != 2" + +### Env vars + + vars: + local_home: "{{ lookup('env','HOME') }}" + +## Refereneces + + * http://www.ansibleworks.com/docs/intro_configuration.html + * http://www.ansibleworks.com/docs/modules.html + diff --git a/bookshelf-contrib.md b/bookshelf-contrib.md new file mode 100644 index 000000000..b992fe2c0 --- /dev/null +++ b/bookshelf-contrib.md @@ -0,0 +1,21 @@ +# bookshelf-contrib.Scopes +# +class Books + scopes: + published: (q) -> q.where(published: true) + +Books.published().fetchAll() + + +# bookshelf-contrib.QueryProxy +# +Books.query().where(published: true) +Books.where(published: true) + +# bookshelf-contrib.Migration +class Migration + up: -> + down: -> + + + diff --git a/brunch.md b/brunch.md index 8b84f2c3b..ef9104b42 100644 --- a/brunch.md +++ b/brunch.md @@ -51,11 +51,27 @@ layout: default global_defs: DEBUG: false -## Stuff +## Extensions + +Compile to JS/CSS - * uglify-js-brunch * stylus-brunch * coffee-script-brunch + * less-brunch + +Compile to HTML + + * static-jade-brunch + +Embedded templates + + * emblem-brunch + +Etc + + * uglify-js-brunch + * jshint-brunch + * imageoptimizer-brunch ## References diff --git a/chai.md b/chai.md index 2754209bf..d5f3db3e8 100644 --- a/chai.md +++ b/chai.md @@ -55,8 +55,8 @@ layout: default expect(object) .equal(expected) - .eql // deepequal - .deep.equal(expected) + .eql + .deep.equal(expected) // same as .eql .be.a('string') .include(val) @@ -69,10 +69,54 @@ layout: default .be.empty .be.arguments .be.function + .be.instanceOf + + .gt(5) # or .above .greaterThan + .gte # or .at.least + .lt(5) # or .below + + .respondTo('bar') + .satisfy (n) -> n > 0 + + .have.members([2, 3, 4]) + .have.keys(['foo']) + .have.key('foo') .exist - expect(10).above(5) +### Chai-jQuery + + global.jQuery = ...; + chai.use(require('chai-jquery')); + + expect($body) + + .have.attr('foo') + .have.prop('disabled') + .have.css('background') + .have.css('background-color', '#ffffff') + .have.data('foo') + + .have.class('active') + .have.id('id') + + .have.html('hi') + .have.text('hello') + .have.value('2013') + + .be.visible + .be.hidden + + .be.checked + .be.selected + + .be.enabled + .be.disabled + + .be.empty + .to.exist + .to.contain('text') + .to.have('.selector') ### References diff --git a/css.md b/css.md index f857dab1c..35cc13b56 100644 --- a/css.md +++ b/css.md @@ -3,6 +3,36 @@ title: CSS layout: default --- +Selectors +--------- + + = [attr="value"] - exact + ~= [class~="box"] - has word + |= [class|="icon"] - exact, or prefix (eg, value-) + $= [href$=".doc"] - ends in + *= [class*="-is-"] - contains + + + adjacent sibling + ~ far sibling + > direct child + + :target (h2#foo:target) + :disabled + + :nth-child + :nth-child(3n) + :nth-child(3n+2) + :nth-child(-n+4) + :nth-last-child(...) + + :first-of-type + :last-of-type + :nth-of-type + :only-of-type - only child of its parent thats like that + + :only-child + + Background ---------- diff --git a/emacs.md b/emacs.md new file mode 100644 index 000000000..995ddc226 --- /dev/null +++ b/emacs.md @@ -0,0 +1,27 @@ +--- +title: Emacs +layout: default +--- + +### Movements + + ^n ^p # up/down + ^f ^b # left/right + + ^v Mv # up/down page + + ^a ^e # begin/end of line + Ma Me # begin/end of sentence + +### Basic + + ^x ^f # find file + ^x ^s # save file + +### Command line + + Mx + +### Packages + + Mx package-install RET evil RET diff --git a/ember.md b/ember.md new file mode 100644 index 000000000..0410dcb76 --- /dev/null +++ b/ember.md @@ -0,0 +1,67 @@ +--- +title: Ember.js +layout: default +--- + +### Routes + + App.Router.map(function() { + this.resource('trips', function() { + this.route('item', { path: '/:trip_id' }); + }); + + this.route('upcoming'); + this.route('about', { path: '/about' }); + this.route('schedules'); + this.route('history'); + this.route('post'); + }); + +### A route + + App.IndexRoute = Ember.Route.extend({ + setupController: function(controller) { + controller.set('title', 'my app'); + //

{{title}}

+ }, + + setupController: function(controller, model) { + controller.set("model", model); + this.controllerFor('topPost').set('model', model); + }, + + model: function(params) { + return this.store.find('posts'); + return this.store.find('post', params.post_id); + }, + + serialize: function(model) { + // this will make the URL `/posts/foo-post` + return { post_slug: model.get('slug') }; + } + }); + +### markup + + Invite your friends + + CNAME + $ git commit && git push + +Subdomain (like www): + + CNAME => username.github.io + +Apex domains: + + ALIAS => username.github.io + +Apex domains (alternative): + + A => 192.30.252.153, 192.30.252.154 diff --git a/git.md b/git.md index c457a4a96..13028c1ef 100644 --- a/git.md +++ b/git.md @@ -14,3 +14,7 @@ layout: default # Update remote URLs in .gitmodules # (Use when you changed remotes in submodules) git submodule sync + +## Cherry pick + + git rebase 76acada^ diff --git a/github.md b/github.md new file mode 100644 index 000000000..3c31f0e76 --- /dev/null +++ b/github.md @@ -0,0 +1,9 @@ +--- +title: GitHub +layout: default +--- + +### URLs + + github.com/:userrepo/blame/:branch/:path + github.com/:userrepo/commit/:commit diff --git a/google_analytics.md b/google_analytics.md index a1ef585ff..1e516c1e3 100644 --- a/google_analytics.md +++ b/google_analytics.md @@ -3,13 +3,24 @@ title: Google Analytics layout: default --- +### Pageview + + // Analytics.js + ga('create', 'UA-XXXX-Y', 'auto'); + ga('send', 'pageview'); + ### Track events + // ga.js // [..., category, action, label, value (int), noninteraction (bool)] _gaq.push(['_trackEvent', 'Videos', 'Play', 'Birthday video', true]) _gaq.push(['_trackEvent', 'Projects', 'Donate', 'Project name']) _gaq.push(['_trackEvent', 'Accounts', 'Login']) + // Analytics.js + // , , category, action, label, value (int) + ga('send', 'event', 'button', 'click', 'nav buttons', 4); + ### Variables // [..., index, name, value, scope (optional)] diff --git a/gulp.md b/gulp.md new file mode 100644 index 000000000..d7527e0c9 --- /dev/null +++ b/gulp.md @@ -0,0 +1,115 @@ +--- +title: Gulp +--- + + * gulp-ruby-sass + * gulp-autoprefixer + * gulp-minify-css + * gulp-jshint + * gulp-concat + * gulp-uglify + * gulp-imagemin + * gulp-livereload (requires tiny-lr) + * gulp-clean + * gulp-cache + * gulp-notify + + * gulp-header (headers in files) + * gulp-mocha + * gulp-stylus + * gulp-compass + * gulp-nodemon + * gulp-size (displays size) + + Example + + + // Load plugins + var gulp = require('gulp'), + sass = require('gulp-ruby-sass'), + autoprefixer = require('gulp-autoprefixer'), + minifycss = require('gulp-minify-css'), + jshint = require('gulp-jshint'), + uglify = require('gulp-uglify'), + imagemin = require('gulp-imagemin'), + rename = require('gulp-rename'), + clean = require('gulp-clean'), + concat = require('gulp-concat'), + notify = require('gulp-notify'), + cache = require('gulp-cache'), + livereload = require('gulp-livereload'), + lr = require('tiny-lr'), + server = lr(); + + // Styles + gulp.task('styles', function() { + return gulp.src('src/styles/main.scss') + .pipe(sass({ style: 'expanded', })) + .pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4')) + .pipe(gulp.dest('dist/styles')) + .pipe(rename({ suffix: '.min' })) + .pipe(minifycss()) + .pipe(livereload(server)) + .pipe(gulp.dest('dist/styles')) + .pipe(notify({ message: 'Styles task complete' })); + }); + + // Scripts + gulp.task('scripts', function() { + return gulp.src('src/scripts/**/*.js') + .pipe(jshint('.jshintrc')) + .pipe(jshint.reporter('default')) + .pipe(concat('main.js')) + .pipe(gulp.dest('dist/scripts')) + .pipe(rename({ suffix: '.min' })) + .pipe(uglify()) + .pipe(livereload(server)) + .pipe(gulp.dest('dist/scripts')) + .pipe(notify({ message: 'Scripts task complete' })); + }); + + // Images + gulp.task('images', function() { + return gulp.src('src/images/**/*') + .pipe(cache(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))) + .pipe(livereload(server)) + .pipe(gulp.dest('dist/images')) + .pipe(notify({ message: 'Images task complete' })); + }); + + // Clean + gulp.task('clean', function() { + return gulp.src(['dist/styles', 'dist/scripts', 'dist/images'], {read: false}) + .pipe(clean()); + }); + + // Default task + gulp.task('default', ['clean'], function() { + gulp.start('styles', 'scripts', 'images'); + }); + + // Watch + gulp.task('watch', function() { + + // Listen on port 35729 + server.listen(35729, function (err) { + if (err) { + return console.log(err) + }; + + // Watch .scss files + gulp.watch('src/styles/**/*.scss', ['styles']); + + // Watch .js files + gulp.watch('src/scripts/**/*.js', ['scripts']); + + // Watch image files + gulp.watch('src/images/**/*', ['images']); + + }); + + }); + +### References + +https://github.com/gulpjs/gulp/blob/master/docs/getting-started.md#getting-started diff --git a/handlebarsjs.md b/handlebarsjs.md new file mode 100644 index 000000000..71eb12d2f --- /dev/null +++ b/handlebarsjs.md @@ -0,0 +1,22 @@ +--- +title: Handlebars.js +layout: default +--- + +### Helpers + + Handlebars.registerHelper('link_to', function() { + return "" + this.body + ""; + }); + + var context = { posts: [{url: "/hello-world", body: "Hello World!"}] }; + var source = "" + + var template = Handlebars.compile(source); + template(context); + + // Would render: + // + // diff --git a/harveyjs.md b/harveyjs.md new file mode 100644 index 000000000..b3ef32503 --- /dev/null +++ b/harveyjs.md @@ -0,0 +1,19 @@ +--- +title: Harvey.js +layout: default +--- + +### Harvey + + http://harvesthq.github.io/harvey/harvey.js + +### Usage + + Harvey.attach('(min-width: 600px)', { + setup: function () { + }, + on: function () { + }, + off: function () { + } + }) diff --git a/heroku.md b/heroku.md index 17bec4f31..930705f07 100644 --- a/heroku.md +++ b/heroku.md @@ -23,6 +23,12 @@ layout: default heroku logs -t # --tail (stream) heroku logs -s app # --source (only on app logs) +## `releases` + + heroku releases + heroku releases:info v25 + heroku rollback + ## `pg` - Postgresql # Start a database diff --git a/imagemagick.md b/imagemagick.md index b1adb2635..5b51e2354 100644 --- a/imagemagick.md +++ b/imagemagick.md @@ -3,6 +3,16 @@ title: Imagemagick layout: default --- +### Stuff + + -resize 100x40 + -flip # vertical + -flop # horizontal + -transpose # flip vertical + rotate 90deg + -transverse # flip horizontal + rotate 270deg + -trim # trim image edges + -rotate 90 + ### Resize to fit convert input.jpg -resize 80x80^ -gravity center -extent 80x80 icon.png diff --git a/inkscape.md b/inkscape.md new file mode 100644 index 000000000..a63306185 --- /dev/null +++ b/inkscape.md @@ -0,0 +1,25 @@ +--- +title: Inkscape +layout: default +--- + +### All + + - = - Zoom in/out + 3 4 - Zoom to selection / drawing + 5 6 - Zoom to page / page width + +### Select tool (F1) + + [ ] - Rotate + +### Edit path (F2) + + Ctrl - constraint + +Dragging an anchor handle + + ctrl - snap to 15 degrees + alt - ? + +### Bezier (Shift F6) diff --git a/javascript-arrays.md b/javascript-arrays.md index 0ee8ab212..e1985405b 100644 --- a/javascript-arrays.md +++ b/javascript-arrays.md @@ -15,6 +15,7 @@ layout: default array.slice(1) //=> [b,c,d,e] array.slice(1,2) //=> [b] + // Destructive re = array.splice(1) // re = [b,c,d,e] array == [a] re = array.splice(1,2) // re = [b,c] array == [a,d,e] diff --git a/js-model.md b/js-model.md new file mode 100644 index 000000000..5dc4b07bc --- /dev/null +++ b/js-model.md @@ -0,0 +1,60 @@ +--- +title: Js-Model +layout: default +--- + + Project = Model "project", -> + @extend + findByTitle: (title) -> ... + + @include + markAsDone: -> ... + + # ActiveRecord::Base.include_root_in_json = false + }); + + project = Project.find(1) + project = Project.findByTitle("hello") + + project.markAsDone() + +### Persistence + + Project "hi", -> + @persistence Model.REST, "/projects" + @persistence Model.localStorage + + Project.load -> + // loaded + +### Attrs + + project = new Project(name: "Hello") + + project.attr('name', "Hey") + project.attr('name') + + project.save() + project.destroy() + +### Collection + + Food.add(egg) + Food.all() + Food.select (food) -> ... + Food.first() + + Food.find(id) + +### Events + + Project.bind "add", (obj) -> + Project.bind "remove", (obj) -> + + # Instances + project.bind "update", -> + project.bind "destroy", -> + + project.trigger "turn_blue" + +http://benpickles.github.io/js-model/ diff --git a/ledger.md b/ledger.md new file mode 100644 index 000000000..e953d566f --- /dev/null +++ b/ledger.md @@ -0,0 +1,228 @@ +--- +title: Ledger CLI +layout: default +--- + +### Queries + + # any/all matches + ledger bal Rent Transportation # any + ledger bal Income and Job # all + ledger bal Expenses and not (Drinks or Food) + + # what did I spend on most? (--sorted) + ledger reg Expenses -S amount + + # how much do I have now? + ledger bal ^Assets ^Liabilities + + # how much did I have at this date? (--end) + ledger bal -e 01/15 ^Assets ^Liabilities + + # how much did I spend and earn this month? + ledger bal ^Expenses ^Income --invert + + # what did I spend my Mastercard on? (--period, --begin, --end) + # ..list transactions in account "Mastercard" for this date. + ledger reg mastercard + ledger reg mastercard -p "january" + ledger reg mastercard -b 01/25 -e 01/31 + + # what did I do yesterday? + # ..list transactions on this day + ledger reg -p 01/26 + + # how much was spent on Expenses:Grocery? + ledger reg grocery + ledger reg grocery --weekly + ledger reg grocery --monthly + + # how much was spent over the course of 3 days? (totalled) + ledger reg -b 01/25 -e 01/27 --subtotal + ledger reg -b 01/25 -e 01/27 --subtotal grocery + +### Format + + 2013/01/03 * Rent for January + Expenses:Rent $600.00 + Assets:Savings + + * = cleared + ! = pending + +### Secondary dates + + 2008/01/01=2008/01/14 Client invoice ; estimated date you'll be paid + +### Balance assertions + + 2008/01/01 * KFC + Expenses:Food $20 + Assets:Cash $-20 = $500 ; ensures cash is at $500 + +### Balance assignment + + 2008/01/01 * Cash balance + Assets:Cash = $500 + Equity:Adjustments + + 2008/01/01 * KFC + Expenses:Food $20 + Assets:Cash = $500 ; figures out what's needed to make it $500 + +### Payables + + 2008/04/25 * Rent + (Assets:Checking) -$200 + Expenses:Rent + +### Commodities + + ; cost per item + 2010/05/31 * Market + Assets:Fridge 35 apples @ $0.42 + Assets:Cash + + ; total cost + 2010/05/31 * Market + Assets:Fridge 35 apples @@ $14.70 + Assets:Cash + + ; fixed lot prices + 2010/05/31 * Gas + Expenses:Gasoline 11 GAL {=$2.299} + + +### Budgeting + + ~ Monthly + Expenses:Rent $500 + Expenses:Food $100 + Expenses $40 ; everything else + Assets + + ~ Yearly + + ; ledger bal --budget Expenses + ; ledger bal --unbudgeted Expenses + +### Comments + + ; line comment + # also line comment + % also line comment + | also line comment + * also line comment + +CLI interface +------------- + +### Examples + + $ ledger bal # show balance + $ ledger reg grocery # show entries for grocery + $ ledger print # show entries + + $ ledger bal assets # check if im broke + + $2000 Assets + $1400 Savings + $600 Cash + + $ ledger bal -b 2013/01/01 -e 2013/01/31 + +### Periods + + [interval] [begin] [end] + + interval: + every day|week|month|quarter|year + every N days|weeks|... + daily|weekly|... + begin: + from + end: + to + spec: + 2004 + 2004/10/1 + + $ ledger bal|reg --period "until aug" + $ ledger bal|reg --period "last oct" + $ ledger bal|reg --period "every week" + +### Register + + $ ledger reg + -D, --daily + -W, --weekly + -M, --monthly + --quarterly + -Y, --yearly + -s, --subtotal + --start-of-week monday + + -S, --sort date + -S, --sort amount + +### Filters + + -b, --begin DATE + -e, --end DATE + + -d EXPR # only transactions matching EXPR (`-d payee =~ /pioneer/`) + + -C, --cleared # only cleared transactions (with *) + -U, --uncleared # only uncleared (no *) + --pending # only pending (with !) + + -R, --real # ignore virtual postings (eg: "(Cash) $-400") + -L, --actual # no automated postings (eg: "= /^Income/") + + --aux-date # use aux dates as if it were the primary dates + + -r, --related # show the other side + # "reg -r savings" shows where it comes from) + +### Display + + -n, --collapse # [register] collapse entries + # [balance] no grand total + -s, --subtotal # [balance] show sub-accounts + # [other] show subtotals + +### Effective dates + +Say you're in business. If you bill a customer, you can enter something like + + 2008/01/01=2008/01/14 Client invoice ; estimated date you'll be paid + Assets:Accounts Receivable $100.00 + Income: Client name + +Then, when you receive the payment, you change it to + + 2008/01/01=2008/01/15 Client invoice ; actual date money received + Assets:Accounts Receivable $100.00 + Income: Client name + +### CSV format + + date, ?, desc, account, currency, amt, pending/cleared, ? + "2013/09/02","","things", "Assets:Cash","P","-2000","*","" + "2013/09/02","","things", "Liabilities:Card","P","-200","*","" + "2013/09/02","","things", "Expenses:Things","P","2200","*","" + "2013/09/04","","stuff", "Assets:Cash","P","-20","*","" + "2013/09/04","","stuff", "Expneses:Others","P","20","*","" + +### Commodity + + commodity $ + note American Dollars + format $1,000.00 + nomarket + default + +### See + + * http://ledger-cli.org/3.0/doc/ledger3.html + * https://gist.github.com/agaviria/3317397 diff --git a/minitest.md b/minitest.md index bffe39291..b7369fe5b 100644 --- a/minitest.md +++ b/minitest.md @@ -18,8 +18,9 @@ layout: default end end -### Specs +### Specs (.must/.wont) + .must_be :==, 0 .must_equal b .must_be_close_to 2.99999 .must_be_same_as b @@ -41,9 +42,74 @@ layout: default proc { ... }.must_raise exception proc { ... }.must_throw sym -Wont is the inverse of must: - a.must_equal b - a.wont_equal b +### Unit::TestCase + class TestHipster < MiniTest::Unit::TestCase + def setup + @subject = ["silly hats", "skinny jeans"] + end + def teardown + @hipster.destroy! + end + + def test_for_helvetica_font + assert_equal "helvetica!", @hipster.preferred_font + end + + def test_not_mainstream + refute @hipster.mainstream? + end + end + +### Assertions + + assert + assert_block { ... } + assert_empty + assert_equal 2, @size + assert_in_delta @size, 1, 1 + assert_in_epsilon + assert_includes @list, "item" + assert_instance_of Array, @list + assert_kind_of Enumerable, @list + assert_match @str, /regex/ + assert_nil + assert_operator @n, :==, 0 + assert_output + assert_raises + assert_respond_to + assert_same + assert_send + assert_silent + assert_throws + +### MiniTest::Mock + +A simple and clean mock system. There two essential methods at our disposal: expect and verify. + + require 'minitest/autorun' + + describe Twipster, "Make every tweet a hipster tweet." do + before do + @twitter = MiniTest::Mock.new + @twipster = Twipster.new(@twitter) + end + + it "should append a #lolhipster hashtag and update Twitter with our status" do + tweet = "Skyrim? Too mainstream." + @twitter.expect :update, true, ["#{tweet} #lolhipster"] + @twipster.submit(tweet) + assert @twitter.verify # verifies tweet and hashtag was passed to `@twitter.update` + end + end + +### Reporters + + gem 'minitest-reporters' + + require 'minitest/reporters' + Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new + + [Default, Spec, Progress, RubyMate, RubyMine, JUnit] diff --git a/modella.md b/modella.md new file mode 100644 index 000000000..6d6d290eb --- /dev/null +++ b/modella.md @@ -0,0 +1,82 @@ +--- +title: Modella +layout: default +--- + +### Basic + + + User = Modella('User') + + .attr('name') + .attr('email', { required: true }) + .use(require('modella-validators') + + .validator (u) -> + u.error('username', 'is required') unless u.has('username') + + + user + .name() + .name('John') + .set(name: 'John') + + .has('name') //=> true + .isNew() + .isValid() + + .save (err) -> + .remove (err) -> + .removed + .model // === User + +### Events + + Model.emit('event', [data...]) + record.emit('event', [data...]) + +### List of events + + user + .on 'save', -> + .on 'create', -> + .on 'saving', (data, done) -> done() + + .on 'remove', -> + .on 'removing', (data, done) -> done() + + .on 'valid', -> + .on 'invalid', -> + + .on 'change', -> + .on 'change email', -> + + .on 'initializing', (instance, attrs) -> + .on 'initialize', -> + + .on 'error', -> failed to save model + + .on 'setting', (instance, attrs) -> # on Model#set() + .on 'attr', -> # new attr via Model.attr() + +### Plugins + + MyPlugin = -> + return (Model) -> + + Model.method = ... + Model.prototype.method = ... + Model.attr(...) + + Model + +### Memory + + User + .all (err, users) -> + .find id, (err, user) -> + + .remove -> + .save -> + .update -> + diff --git a/nock.md b/nock.md new file mode 100644 index 000000000..e30229e49 --- /dev/null +++ b/nock.md @@ -0,0 +1,22 @@ +--- +title: Nock +layout: default +--- + +### Nock + + scope = nock('http://foo.com') + scope = nock('http://foo.com', { allowUnmocked: true }) + + nock('http://foo.com') + .get('/user') + .reply(200, { id: 1234 }) + + +### Filtering + + nock('http://foo.com') + .filteringPath(/[&\?]token=[^&]*/g, '') + .get('/user') + + # catches "/user?token=..." as well diff --git a/nodejs.md b/nodejs.md index 71f87590f..c5aec6fed 100644 --- a/nodejs.md +++ b/nodejs.md @@ -61,15 +61,18 @@ layout: default ### Streams - process.stdin.resume(); /* paused by default */ - process.stdin.setEncoding('utf8'); - - process.stdin.on('data', function(chunk) { ... }); - process.stdin.on('end', function() { ... }); - process.stdout.write('...'); process.stderr.write('...'); + function readStdin(fn) { + process.stdin.resume(); /* paused by default */ + process.stdin.setEncoding('utf8'); + + var data = ''; + process.stdin.on('data', function(chunk) { data += chunk.toString(); }); + process.stdin.on('end', function() { fn(null, data); }); + } + ### stuff process.argv; //=> ['node', 'file.js', 'one', 'two'] @@ -125,7 +128,7 @@ layout: default process.stdout.write(util.inspect(objekt, false, Infinity, true) + '\n'); -## Spawn +## Spawn - passthru the in/out var spawn = require('child_process').spawn; var proc = spawn(bin, argv, { stdio: 'inherit' }); @@ -137,6 +140,11 @@ layout: default // also { stdio: [process.stdin, process.stderr, process.stdout] } + proc.stdout.on('data', function (data) { + }); + proc.stderr.on('data', function (data) { + }); + [all]: http://nodejs.org/api/all.html [path]: http://nodejs.org/api/path.html [process]: http://nodejs.org/api/process.html diff --git a/npm.md b/npm.md index ff2cd13a4..ab8a83f3e 100644 --- a/npm.md +++ b/npm.md @@ -4,4 +4,27 @@ layout: default --- npm install - npm owner add rstacruz PACKAGENAME + npm shrinkwrap + +### Adding owners + + # Add someone as an owner + npm owner add USERNAME PACKAGENAME + + # list packages + npm ls + + # Remove duplicates down the dep tree + npm dedupe + + # Adds warning to those that install a package of old versions + npm deprecate PACKAGE@"< 0.2.0" "critical bug fixed in v0.2.0" + + # Add a package as a git submodule + npm submodule PACKAGE + + # update all packages, or selected packages + npm update [-g] PACKAGE + + # Check for outdated packages + npm outdated [PACKAGE] diff --git a/plantuml.md b/plantuml.md new file mode 100644 index 000000000..d2543900b --- /dev/null +++ b/plantuml.md @@ -0,0 +1,95 @@ +--- +title: PlantUML +layout: default +--- + +### Format + + @startuml + Car : drive() + Dog : bark() + @enduml + + # plantuml file.uml && open file.png + +## Classes + + * http://plantuml.sourceforge.net/classes.html + +### Methods + + Car : drive() + +### Methods (alt) + + class Car { + String make + year : Integer + void drive() + + -private() + #protected() + ~package private() + +public() + + {static} String id + {abstract} void methods() + } + +### Lines + + class Car { + These are separated by lines. + The next line is a dotted line + .. + Next is a double-stroke + == + Next is a plain line + -- + Next is a strong line + __ + You can make headers with it + .. header .. + } + +### Associations + + Car <|-- SmallCar # extension + Car *-- Engine # composition + Cars o-- Car # aggregation + Car <|.. SmallCar # dotted line (use .. instead of --) + Car <|--* Car + + -left-> + -right-> + +### Relations + + Driver - Car : drives > + Car -- Owner : < owns + Car *-- Wheel : has 4 > + +### Notes + + class Car { + } + note left: Something something + + note top of Car : This is a car. + +### Namespaces + + namespace Client { + class Driver { + } + } + + Car -- Client.Driver : owns > + + +## Activities + + (*) --> "First Activity" + -->[You can put also labels] "Second Activity" + --> (*) + diff --git a/premailer.md b/premailer.md new file mode 100644 index 000000000..ca3f28d87 --- /dev/null +++ b/premailer.md @@ -0,0 +1,14 @@ +--- +title: Premailer +layout: default +--- + + + -premailer-width + Available on table, th and td elements + -premailer-height + Available on table, tr, th and td elements + -premailer-cellpadding + Available on table elements + -premailer-cellspacing + Available on table elements diff --git a/ractive.md b/ractive.md new file mode 100644 index 000000000..389996c2c --- /dev/null +++ b/ractive.md @@ -0,0 +1,129 @@ +--- +title: Ractive.js +layout: default +vim: ft=javascript +--- + +### Initialization + + new Ractive({ + el: $('..'), + el: '#box', + template: '...', // required + + // callbacks + init: function() // on instanciate + complete: function() // on finish animations + + // objs + data: { ... } + partials: { ... } // global: Ractive.partials + transitions: { ... } // global: Ractive.transitions + components: { ... } + adaptors: [ ... ] + + // options + magic: false + modifyArrays: true + twoway: true + noIntro: true // true = disable transition on initial render + lazy: false // false = use keyevents, true = use change/blur + append: false // false = overwrite element, true = append + debug: false + sanitize: false + }) + + +http://docs.ractivejs.org/latest/initialisation-options + +### Components + + Widget = Ractive.extend({ ... }) + + ractive = new Ractive({ + el: 'main', + template: '', + components: { + widget: Widget + } + }); + +https://github.com/RactiveJS/Ractive/issues/74 +https://github.com/RactiveJS/Ractive/wiki/Components + +### Partials + + // Global partials + Ractive.partials.x = "<..>" + +### Events + + + + view.on({ + activate: function () { ... } + }); + + + view.on('sort', function (e, column) { + console.log('sorting by #{column}'); + }); + +### Observing + + view.observe("name", function (name) { + console.log("Changed name to", name); + }, { init: false }); + +### Markup + + Hello, {{name}} + Body: {{{unescaped}}} + + + {{#list:i}} +
  • {{this.name}}
  • +
  • {{name}}
  • +
  • {{.}}
  • + {{/#list}} + + {{^user}}Not logged in{{/user}} + {{#user}}Welcome, sire{{/user}} + + {{>partialName}} + + + {{#statusDogs[selected]}} + +### Transformed attributes + +This transforms the `list` attribute via a helper function called `sort()`. + + {{# sort(list, "name") :num }} +
  • {{num}} - {{name}}
  • + {{/ end. any text goes here }} + + data: { + sort: function(array, column) { return array.whatever(); } + } + +### Transitions + +
    +
    +
    + + Ractive.transitions.bump = function(t, params) { + params = t.processParams( params, { + duration: 400, + color: t.isIntro ? 'rgb(0,255,0)' : 'rgb(255,0,0)' + }); + + if (t.isIntro) { + /* enter */ + } else { + /* exit */ + } + + t.complete(); + }; diff --git a/rails-forms.md b/rails-forms.md index 802a71b28..abf85d5ad 100644 --- a/rails-forms.md +++ b/rails-forms.md @@ -6,17 +6,38 @@ layout: default ### Forms # Model: - = form_for @post do |f| + form_for @post do |f| - = form_for @post, url: { method: 'put', action: 'create' }, html: { class: 'nifty_form'} do |f| + form_for @post, + url: { method: 'put', action: 'create' }, + html: { class: 'nifty_form' } do |f| + f.label :first_name + f.text_field :first_name + + field :multiselect, f, :first_name + +### Stuff + + f.object ### Fields - f.check_box :enabled + f.check_box :is_admin f.text_field :title - f.text_area :body, \ - :size => '60x12' + f.text_area :body, + size: '60x12' + + f.label :post, :title + f.label :post, :title, "Title" + f.label :post, :title, "Title", class: "title" + f.label(:post, :terms) { "Accept terms" } + #=> + + radio_button("post", "category", "rails") + radio_button("post", "category", "java") + #=> ### Select dropdowns @@ -32,4 +53,15 @@ layout: default ### The rest f.submit "Create" + f.hidden_field + +### I18n + + helpers.submit.create = "Create a %{model}" + helpers.submit.update = "Confirm changes to %{model}" + + helpers.submit.article.create = "Publish article" + helpers.submit.article.update = "Update article" + + helpers.label.post.body = "Write your body text here" diff --git a/rails-gems.md b/rails-gems.md new file mode 100644 index 000000000..ea914c746 --- /dev/null +++ b/rails-gems.md @@ -0,0 +1,26 @@ +--- +title: Rails gems +layout: default +--- + +### Rico's preferred rails gems + +Development: + + gem 'spring' # code reloading + gem 'letter_opener' + gem 'better_errors' + gem 'meta-tags' + gem 'guard-rspec' + +Prod: + + gem 'kaminari' # pagination + gem 'devise' + gem 'meta-tags', require: 'meta_tags' + gem 'friendly_id' + gem 'bourbon' + gem 'neat' + gem 'turbolinks' + gem 'nkss_rails' + gem 'jquery-turbolinks' diff --git a/rails-i18n.md b/rails-i18n.md new file mode 100644 index 000000000..a3c6d7846 --- /dev/null +++ b/rails-i18n.md @@ -0,0 +1,55 @@ +--- +title: Rails i18n +layout: default +--- + +### Basics + + t('my.messages.hello') + + t(:hello, scope: 'my.messages') + t(:hello, scope: [:my, :messages]) + + t('my.messages.hello', default: "Hello") + +### Plural + + I18n.backend.store_translations :en, inbox: { + one: 'one message', + other: '%{count} messages' + } + I18n.translate :inbox, count: 1 # => 'one message' + I18n.translate :inbox, count: 2 # => '2 messages' + +### ActiveRecord + + activerecord.attributes.user.name + + t 'blank', scope: + activerecord.errors.models.[model_name].attributes.[attribute_name] + activerecord.errors.models.[model_name] + activerecord.errors.messages + errors.attributes.[attribute_name] + errors.messages + + helpers.submit.[model]: + create: "Create a %{model}" + update: "Update %{model}" + + activerecord.errors.models.venue.attributes.name.blank = "Please enter a name." + + confirmation - :confirmation + acceptance - :accepted + presence - :blank + length - :too_short (%{count}) + length - :too_long (%{count}) + length - :wrong_length (%{count}) + uniqueness - :taken + format - :invalid + numericality - :not_a_number + + activerecord.errors.template.header: + one: "1 error prohibited this %{model} from being saved" + +### Reference + * http://guides.rubyonrails.org/i18n.html diff --git a/rails-rspec.md b/rails-rspec.md new file mode 100644 index 000000000..7bfbcbf28 --- /dev/null +++ b/rails-rspec.md @@ -0,0 +1,80 @@ +--- +title: Rspec-rails +layout: default +--- + +### Require + + require 'spec_helper' + +### Controller tests + + # spec/controllers/* + describe ItemsController do + it "works" do + get :index + expect(response).to be_success + expect(response.status).to eq(200) + expect(response).to render_template("index") + end + + it "loads all of the posts into @posts" do + post1, post2 = Post.create!, Post.create! + get :index + + expect(assigns(:posts)).to match_array([post1, post2]) + end + end + +### Request specs + + # spec/features/* + describe "Foo tests", type: :request do + include RequestHelpers + + it "should work" do + visit "/" + expect(page).to have_content "Hello" + expect(page).to have_selector "h1", text: "Welcome" + end + end + +### View specs + + # spec/views/* + it "renders _event partial for each event" do + assign(:events, [stub_model(Event), stub_model(Event)]) + render + expect(view).to render_template(:partial => "_event", :count => 2) + end + +### Routes + + # spec/routes/* + describe "routing to profiles" do + it "routes /profile/:username to profile#show for username" do + expect(get: "/profiles/jsmith").to route_to( + :controller => "profiles", + :action => "show", + :username => "jsmith" + ) + end + + it "does not expose a list of profiles" do + expect(:get => "/profiles").not_to be_routable + end + end + +### Helpers + + # spec/helpers/* + describe EventsHelper do + describe "#link_to_event" do + it "displays the title, and formatted date" do + event = Event.new("Ruby Kaigi", Date.new(2010, 8, 27)) + # helper is an instance of ActionView::Base configured with the + # EventsHelper and all of Rails' built-in helpers + expect(helper.link_to_event).to match /Ruby Kaigi, 27 Aug, 2010/ + end + end + end diff --git a/rails-tricks.md b/rails-tricks.md index 26850182e..8cb518340 100644 --- a/rails-tricks.md +++ b/rails-tricks.md @@ -8,3 +8,6 @@ in config/environments/development.rb: # Source maps for Sass config.sass.debug_info = true config.sass.line_comments = false + + # Don't break apart + config.assets.debug = false diff --git a/regexp.md b/regexp.md new file mode 100644 index 000000000..155fa3632 --- /dev/null +++ b/regexp.md @@ -0,0 +1,13 @@ +--- +title: Regexp +layout: default +--- + + (?P...) + (?:invisible group) + + (?!negative look-ahead) + (?=positive look-ahead) + (? +<%= f.input :password, required: false %> +<%= f.input :remember_me, as: :boolean %> +<%= f.button :submit, "Sign in" %> + +simple_form_for @x, + wrapper: :small diff --git a/spine.md b/spine.md new file mode 100644 index 000000000..b35a69460 --- /dev/null +++ b/spine.md @@ -0,0 +1,183 @@ +--- +title: Spine +layout: default +vim: ft=python +--- + +## Models + + class User extends Spine.Model + @configure "User", "name", "address" + + fullName: -> + [@first, @last].join ' ' + +### JavaScript + + // Subclassing + User = Spine.Model.sub() + +### Class methods + + .configure 'modelname', attributes... + + # Inheritance + .include(Module) + .extend(Module) + + .create(name: "John") + + .count() + + # Events + .on 'refresh change', (user) -> ... + .trigger 'event' + + .change (user) -> ... # same as on('change') + .fetch (user) -> ... # same as on('fetch') + + # JSON + .toJSON() # all records + .fromJSON(json) # from json string + .fromForm(el) + + # Data + .records # Hash of instances + .attributes # array of attributes (from .configure) + + # Convenience + .toString() #=> "User" + + # Find by ID + .exists(1) + .find(1) # throws error + + # Find by something + .select (u) u.name == 'bob' + .findByAttribute 'name', 'bob' + .findAllByAttribute 'name', 'bob' + + .all() + .slice(6, 13) # cloned copies of instances + + # Iterating + .each (user) -> + + # Ends + .first() + .last() + + # Deleting + .deleteAll() + .destroyAll() + .destroyAll({ ..options.. }) + .destroy(2) + +### Instance methods + + user = new User(); + + user + .isNew() + .exists() + + # Validation + .isValid() + .validate() # validate = (-> "Name required" unless @name) + + .attributes() # hash of attr values + .eql(other) # equality check + + # Update + .load(attrs) + .reload() + .fromForm(form) + .updateAttribute("name", "john") + .updateAttributes(name: "John") + + # Event + .on 'event', -> ... + .trigger 'event' + + # Retrieve + .toJSON() + + # Persistence + .save() + + .destroy() + .dup() # clone as unsaved + +### Mixins + + class User extends Spine.Model + @include MyModule + @extend MyModule + +### Events + + .on 'create' + .on 'update' + .on 'destory' + + .on 'save' # create / update + .on 'change' # create / update / destroy + + .on 'refresh' + .on 'error' # validation error + +## Ajax + + class User extends Spine.Model + @extend Spine.Model.Ajax + + @url: '/users' + @url: -> '/users' + scope: '2013' + +### Using + + User.fetch() + user = new User() + + user.url() #=> "/users" + user.url('bands') #=> "/users/bands" + + user.scope = 'admin' + user.url() #=> "/admin/users" + +### Host + + Spine.Model.host = 'http://endpoint' + +### Ajax mapping + + read → GET /collection + create → POST /collection (201 created) + update → PUT /collection/id + destroy → DELETE /collection/id + +### Associations + + class Photo extends Spine.Model + @belongsTo 'album', 'Album' # window['Album'] + @belongsTo 'album', 'models/album' # via require.js + + class Album + @hasMany 'photos', 'models/photo' + + album.photos().all() + album.photos().create(name: "Vacation") + album.photos().find(id) + + photo = Photo.create(album: album) + photo.album() + photo.album_id + + +### See + + * http://spinejs.com/api/index + * http://spinejs.com/api/models + * http://spinejs.com/docs/ajax +* http://spinejs.com/docs/relations diff --git a/tabular.md b/tabular.md new file mode 100644 index 000000000..d684cf0fe --- /dev/null +++ b/tabular.md @@ -0,0 +1,39 @@ +--- +title: Tabular +layout: default +--- + +### Examples + +:Tab /, + + hello , there + hi , you + +:Tab /,/r0 + + hello,there + hi, you + +:Tab /,/r1c1l0 + + # the separator counts as a column + # [r]ight align, [1] space, [c]enter align the comma, [1] space, + # [l]eft align, [0] spaces + hello , etc + hi , etc + +`:Tab /^[^,]*\zs,/r0` + + abc,hello + c,hi there + a,yo + + + +### Specifiers + + l|r|cN # left-right-center, with N spaces padding (l0) + r1c1l0 # multiple specifiers (one per column) + # the separator counts as a column + diff --git a/ubuntu.md b/ubuntu.md index 367e9cf34..47f482b97 100644 --- a/ubuntu.md +++ b/ubuntu.md @@ -14,3 +14,6 @@ layout: default ### Apt archives path /var/cache/apt/archives + +### List services + service --status-all diff --git a/unicode.txt b/unicode.txt index 38c7e451d..c0acaccdc 100644 --- a/unicode.txt +++ b/unicode.txt @@ -1,21 +1,82 @@ - ▲▼▶ +• \u2022 +· \u00b7 +┄ \u2504 +— \u2014 (mdash) +– \u2013 (ndash) - ⬅⬆⬇ +◦ \u25e6 circle +✈' \u2708 airplane +❄ \u2744 snowflake +⚑ \u2691 flag +☯ \u262f yinyang +♞ \u265e horse +☀ \u2600 rays - ◢ ◣ ◤ ◥ - - : «» XOR ‹›, (), [], •, ⌘, ⌥, ▲▼, ▸▹, ◇ XOR ◆, ◐◑◒◓ ◢ ◣ ◤ ◥, ★ ☆ , ♠♥♣♦, ⚐⚑, ✂ +× times + +★ star +☆ star2 + +⚐ \u2690 flag +⚑ \u2691 flag + +✓ \u2713 check +✕ \u2715 +✗ \u2717 x mark +✘ \u2718 x mark bold +❏ \u274f checkbox + +Spinners: + ◜◠◝◞◡◟ + ❘❙❚ + +Triangles: + ▲▼▶ + +⬅ \u2b05 +⬆ \u2b06 +⬇ \u2b07 + +◢ +◣ +◤ +◥ + +« +» +‹ +› +• +⌘ +⌥ + +▸ \u25b8 +▹ + +◇ \u25c7 +◆ + +◐ +◑ +◒ +◓ - ࣾ home ࣾ - ℹ information ℹ - ♡ heart ♡ - ⚙ cog or gear ⚙ - ⚿ key ⚿ - ✉ envelope ✉ - ✎ pencil ✎ - ✓ check or tick mark ✓ - ❌ cross mark ❌ - 💬 speech balloon 💬 +♠ +♥ +♣ +♦ -✈' + +✂ scissors +ℹ information ℹ +♡ heart ♡ +⚙ cog or gear ⚙ +✉ envelope ✉ +✎ pencil ✎ +✓ check or tick mark ✓ + +"x".charCodeAt(0) +"x".charCodeAt(0).toString(16) + +http://www.danshort.com/HTMLentities/index.php?w=dingb diff --git a/vagrant.md b/vagrant.md index be051ee6a..094748821 100644 --- a/vagrant.md +++ b/vagrant.md @@ -27,6 +27,6 @@ To stop, use one of the following: $ vagrant ssh # then: sudo shutdown -h now $ vagrant suspend - $ vagrant destroy + $ vagrant destroy # !! diff --git a/vagrantfile.md b/vagrantfile.md new file mode 100644 index 000000000..cb0f08416 --- /dev/null +++ b/vagrantfile.md @@ -0,0 +1,115 @@ + # -*- mode: ruby -*- + # vi: set ft=ruby : + + Vagrant.configure("2") do |config| + # All Vagrant configuration is done here. The most common configuration + # options are documented and commented below. For a complete reference, + # please see the online documentation at vagrantup.com. + + # Every Vagrant virtual environment requires a box to build off of. + config.vm.box = "precise64" + + # The url from where the 'config.vm.box' box will be fetched if it + # doesn't already exist on the user's system. + # config.vm.box_url = "http://domain.com/path/to/above.box" + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # config.vm.network :forwarded_port, guest: 80, host: 8080 + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network :private_network, ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network :public_network + + # If true, then any SSH connections made will enable agent forwarding. + # Default value: false + # config.ssh.forward_agent = true + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + # config.vm.provider :virtualbox do |vb| + # # Don't boot with headless mode + # vb.gui = true + # + # # Use VBoxManage to customize the VM. For example to change memory: + # vb.customize ["modifyvm", :id, "--memory", "1024"] + # end + # + # View the documentation for the provider you're using for more + # information on available options. + + # Enable provisioning with Puppet stand alone. Puppet manifests + # are contained in a directory path relative to this Vagrantfile. + # You will need to create the manifests directory and a manifest in + # the file precise64.pp in the manifests_path directory. + # + # An example Puppet manifest to provision the message of the day: + # + # # group { "puppet": + # # ensure => "present", + # # } + # # + # # File { owner => 0, group => 0, mode => 0644 } + # # + # # file { '/etc/motd': + # # content => "Welcome to your Vagrant-built virtual machine! + # # Managed by Puppet.\n" + # # } + # + # config.vm.provision :puppet do |puppet| + # puppet.manifests_path = "manifests" + # puppet.manifest_file = "init.pp" + # end + + # Enable provisioning with chef solo, specifying a cookbooks path, roles + # path, and data_bags path (all relative to this Vagrantfile), and adding + # some recipes and/or roles. + # + # config.vm.provision :chef_solo do |chef| + # chef.cookbooks_path = "../my-recipes/cookbooks" + # chef.roles_path = "../my-recipes/roles" + # chef.data_bags_path = "../my-recipes/data_bags" + # chef.add_recipe "mysql" + # chef.add_role "web" + # + # # You may also specify custom JSON attributes: + # chef.json = { :mysql_password => "foo" } + # end + + # Enable provisioning with chef server, specifying the chef server URL, + # and the path to the validation key (relative to this Vagrantfile). + # + # The Opscode Platform uses HTTPS. Substitute your organization for + # ORGNAME in the URL and validation key. + # + # If you have your own Chef Server, use the appropriate URL, which may be + # HTTP instead of HTTPS depending on your configuration. Also change the + # validation key to validation.pem. + # + # config.vm.provision :chef_client do |chef| + # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME" + # chef.validation_key_path = "ORGNAME-validator.pem" + # end + # + # If you're using the Opscode platform, your validator client is + # ORGNAME-validator, replacing ORGNAME with your organization name. + # + # If you have your own Chef Server, the default validation client name is + # chef-validator, unless you changed the configuration. + # + # chef.validation_client_name = "ORGNAME-validator" + end diff --git a/vim.md b/vim.md index 4cfd02213..12121ce16 100644 --- a/vim.md +++ b/vim.md @@ -28,6 +28,12 @@ Motions a[ ( { < # A [], (), or {} block a' " ` # A quoted string + [( [{ [< # previous ( or { or < + ]) # next + + [m # previous method start + [M # previous method end + Example: yip # Yank inner paragraph @@ -118,3 +124,21 @@ Marks syn region inBold concealends matchgroup=bTag start="" end="" hi inBold gui=bold hi bTag guifg=blue + +### Syntax + + syn match :name ":regex" :flags + + syn region Comment start="/\*" end="\*/" + syn region String start=+"+ end=+"+ skip=+\\"+ + + syn cluster :name contains=:n1,:n2,:n3... + + flags: + keepend + oneline + nextgroup= + contains= + contained + + hi def link markdownH1 htmlH1 diff --git a/yaml.md b/yaml.md new file mode 100644 index 000000000..bcbc74aac --- /dev/null +++ b/yaml.md @@ -0,0 +1,16 @@ +--- +title: Yaml +layout: default +--- + + Multiline: | + hello + world + + Inheritance: &defaults + a: 2 + b: 3 + + Inherit: + <<: *defaults + b: 4