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'); + //