From 85cc0fe827679e312694839475173f4df61eb089 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Fri, 16 Mar 2012 14:14:31 +0800 Subject: [PATCH] Hello. --- Etc/PHP_Kohana.ctxt | 78 +++ Etc/Rails_2.ctxt | 104 ++++ Gemfile | 4 + Gemfile.lock | 41 ++ Protonfile | 12 + _layouts/default.html | 17 + _prettify.scss | 44 ++ bash.md | 181 ++++++ brew.md | 30 + capybara.md | 95 +++ cinema4d.md | 2 + config.ru | 26 + devise.md | 126 ++++ figlets.txt | 1293 +++++++++++++++++++++++++++++++++++++++++ fitness.md | 22 + heroku.md | 29 + html-css.md | 27 + html.md | 18 + index.haml | 10 + ios.md | 11 + jquery.md | 51 ++ linux.md | 4 + makefile.md | 26 + markdown.md | 14 + osx.md | 23 + passenger.md | 11 + rails-models.md | 293 ++++++++++ rails-plugins.md | 133 +++++ rails-routes.md | 172 ++++++ rails.md | 129 ++++ rdoc.md | 28 + rst.md | 51 ++ sequel.rdoc | 386 ++++++++++++ style.sass | 93 +++ textile.md | 61 ++ tig.md | 32 + tmux.md | 51 ++ ubuntu.md | 13 + unicode.txt | 19 + vim.md | 36 ++ zsh.md | 20 + 41 files changed, 3816 insertions(+) create mode 100644 Etc/PHP_Kohana.ctxt create mode 100644 Etc/Rails_2.ctxt create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 Protonfile create mode 100644 _layouts/default.html create mode 100644 _prettify.scss create mode 100644 bash.md create mode 100644 brew.md create mode 100644 capybara.md create mode 100644 cinema4d.md create mode 100644 config.ru create mode 100644 devise.md create mode 100644 figlets.txt create mode 100644 fitness.md create mode 100644 heroku.md create mode 100644 html-css.md create mode 100644 html.md create mode 100644 index.haml create mode 100644 ios.md create mode 100644 jquery.md create mode 100644 linux.md create mode 100644 makefile.md create mode 100644 markdown.md create mode 100644 osx.md create mode 100644 passenger.md create mode 100644 rails-models.md create mode 100644 rails-plugins.md create mode 100644 rails-routes.md create mode 100644 rails.md create mode 100644 rdoc.md create mode 100644 rst.md create mode 100644 sequel.rdoc create mode 100644 style.sass create mode 100644 textile.md create mode 100644 tig.md create mode 100644 tmux.md create mode 100644 ubuntu.md create mode 100644 unicode.txt create mode 100644 vim.md create mode 100644 zsh.md diff --git a/Etc/PHP_Kohana.ctxt b/Etc/PHP_Kohana.ctxt new file mode 100644 index 000000000..733f81ae7 --- /dev/null +++ b/Etc/PHP_Kohana.ctxt @@ -0,0 +1,78 @@ +# Installing +wget "http://kohanaphp.com/download?modules%5Bauth%5D=Auth&languages%5Ben_US%5D=en_US&format=zip" -O k.zip &&\ +unzip -q k.zip && rm k.zip &&\ +mv Kohana_*/* . && rm -rf Kohana_* &&\ +rm -f "Kohana License.html" &&\ +# htaccess +cat example.htaccess | sed 's/RewriteBase .*/RewriteBase \//g' > .htaccess && rm example.htaccess &&\ +echo Done! Go and edit application/config/config.php and change the site stuff. + +# Public HTML +mkdir -p public_html &&\ +mv index.html public_html &&\ +mv .htaccess public_html &&\ +echo Done. Now edit index.html's paths + +Git ignore +(echo \*.swo; echo \*.swp; echo .DS_Store; echo Thumbs.db; echo \*~; echo application/logs; echo application/cache ) > .gitignore &&\ + +# Database +$config['default'] = array +( + 'benchmark' => TRUE, + 'persistent' => FALSE, + 'connection' => array + ( + 'type' => 'mysql', + 'user' => 'leet', // set to db user name + 'pass' => 'l33t', // set to db user password + 'host' => 'localhost', + 'port' => FALSE, + 'socket' => FALSE, + 'database' => 'leetdb' // set to db name + ), + 'character_set' => 'utf8', + 'table_prefix' => '', + 'object' => TRUE, + 'cache' => FALSE, + 'escape' => TRUE +); + + +// ORM model +class Post_Model extends ORM { + protected $has_one = array('user'); // has_many, belong_to, has_one, has_and_belongs_to_many +} + +// ORM +$post = ORM::factory('post', 1); +$post->name = "Post name"; +$post->save(); +foreach ($post->categories as $category) +{ + echo $category->name; +} + +// Find (returns even if no row is found) +$o = ORM::factory('article')->find(1); +$o = ORM::factory('article')->where('title', $title)->find(); +if (!$o->loaded) { die('Not found'); } +echo $o->title; + +// Find_all +$o = ORM::factory('article')->find_all(); +foreach ($o as $article) { echo $article->title; } + +// ->$saved +// ->$changed[] +// ->$object_name (Blog_Post_Model => "blog_post") +// ->$primary_key ('id') +// ->$primary_val ('username') - more userfriendly identifier +// ->$table_name +// ->$ignored_columns = array('whatever') +// ->$table_columns = array('id', 'username') +// ->$sorting = array('last_login' => 'desc') -- default sorting + +// + + diff --git a/Etc/Rails_2.ctxt b/Etc/Rails_2.ctxt new file mode 100644 index 000000000..4a3eaa213 --- /dev/null +++ b/Etc/Rails_2.ctxt @@ -0,0 +1,104 @@ +# Debug +logger.debug "xx" + +# Controller stuff +class MyController < ApplicationController::Base +controller.response.body + + # Filters + before_filter :require_login # Looks for require_login method + before_filter MyFilter # Looks for MyFilter class + before_filter { |ct| head(400) if ct.params["stop_action"] } + around_filter :catch_exceptions + after_filter :xx + + layout "admin_area" # Looks for the view file + layout "admin_area", :except => [ :rss, :whatever ] + layout :foo # Looks for private function foo + + private + def whatever ... + +class MyFilter + def self.filter(controller, &block) + +# Model + +belongs_to :user +validates_presence_of :user +default_scope :order => 'id DESC' +named_scope :today, :conditions = "created_at x" +named_scope :today, lambda {{ :conditions = [ "created_at between ? and ?", 1.hour.ago.utc, 300.seconds.ago.utc ] }} +# Then you can call feed.today + +# Controller methods +render :action => 'help', :layout => 'help' +render :text => 'so and so' +render :status => :created, :location => post_url(post) # With HTTP headers +redirect_to :action => 'index' +render :partial => 'product', :collection => @products, :as => :item, :spacer_template => "product_ruler" +return head(:method_not_allowed) +head :created, :location => '...' + +url_for :controller => 'posts', :action => 'recent' + +location = request.env["SERVER_ADDR"] + +# For views +auto_discovery_link_tag(:rss, {:action => "feed"}, {:title => "RSS Feed"}) +javascript_include_tag "foo" +stylesheet_link_tag +image_tag + +# Ruby stuff! +# Defining a class method (not a typo) +Fixnum.instance_eval { def ten; 10; end } +Fixnum.ten # => 10 + +# Defining an instance method +Fixnum.class_eval { def number; self; end } +7.number #=> 7 + +# Multiple arguments, send() +class Klass + def hello(*args); "Hello " + args.join(' '); end +end +Klass.new.send :hello, "gentle", "readers" + +def can(*args) + yield if can?(*args) +end +# can(x) {...} => if can?(x) {...} + + + +# Struct +class Foo < Struct.new(:name, :email) +end + +j = Foo.new("Jason", "jason@bateman.com") +j.name = "Hi" +print j.name + + +# Struct +class Foo < Struct.new(:name, :email) +end + +j = Foo.new("Jason", "jason@bateman.com") +j.name = "Hi" +print j.name + + +# Method missing + def method_missing(method_name, *arguments) + if method_name.to_s[-1,1] == "?" + self == method_name.to_s[0..-2] + + +# Rails logger +Rails.logger.info("...") + +# To string +:hello_there.to_s + diff --git a/Gemfile b/Gemfile new file mode 100644 index 000000000..bbc8912bc --- /dev/null +++ b/Gemfile @@ -0,0 +1,4 @@ +source :rubygems + +gem "proton", "~> 0.3.4" +gem "rack-cache", "~> 1.0.0" diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 000000000..fb59032ba --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,41 @@ +GEM + remote: http://rubygems.org/ + specs: + RedCloth (4.2.8) + chunky_png (1.2.1) + compass (0.11.5) + chunky_png (~> 1.2) + fssm (>= 0.2.7) + sass (~> 3.1) + cuba (2.0.1) + rack + tilt + fssm (0.2.7) + haml (3.1.3) + hashie (1.0.0) + maruku (0.6.0) + syntax (>= 1.0.0) + proton (0.3.4) + RedCloth (~> 4.2.3) + compass (~> 0.11.1) + cuba (~> 2.0.0) + haml (~> 3.1.1) + hashie (~> 1.0.0) + maruku (~> 0.6.0) + sass (~> 3.1.1) + shake (~> 0.1) + tilt (~> 1.3.2) + rack (1.3.2) + rack-cache (1.0.2) + rack (>= 0.4) + sass (3.1.7) + shake (0.1.3) + syntax (1.0.0) + tilt (1.3.3) + +PLATFORMS + ruby + +DEPENDENCIES + proton (~> 0.3.4) + rack-cache (~> 1.0.0) diff --git a/Protonfile b/Protonfile new file mode 100644 index 000000000..566f6f641 --- /dev/null +++ b/Protonfile @@ -0,0 +1,12 @@ +# This is a Proton site. +# Install Proton (`gem install proton`) and type `proton` for help. +requirement: 0.2 + +# The folder where the site's source files are kept. +site_path: . +output_path: _output + +# Other paths: +layouts_path: _layouts +extensions_path: _extensions +partials_path: . diff --git a/_layouts/default.html b/_layouts/default.html new file mode 100644 index 000000000..6be5120f6 --- /dev/null +++ b/_layouts/default.html @@ -0,0 +1,17 @@ + + + + + + + + +

<%= page.meta.title || File.basename(page.file, '.*').capitalize %>

+ <%= yield %> + + + + + + + diff --git a/_prettify.scss b/_prettify.scss new file mode 100644 index 000000000..f58809f1b --- /dev/null +++ b/_prettify.scss @@ -0,0 +1,44 @@ +/* Pretty printing styles. Used with prettify.js. */ + +.str { color: #080; } +.kwd { color: #008; } +// .com { color: #607077; background: rgba(black, 0.05); padding: 1px 3px; @include border-radius(2px); } +.com { color: #7bd; text-shadow: 1px 1px 0 rgba(white, 0.3); } +.typ { color: #606; } +.lit { color: #066; } +.pun { color: #660; } +.pln { color: #000; } +.tag { color: #008; } +.atn { color: #606; } +.atv { color: #080; } +.dec { color: #606; } + +/* Specify class=linenums on a pre to get line numbering */ +ol.linenums { margin-top: 0; margin-bottom: 0 } /* IE indents via margin-left */ +li.L0, +li.L1, +li.L2, +li.L3, +li.L5, +li.L6, +li.L7, +li.L8 { list-style-type: none } +/* Alternate shading for lines */ +li.L1, +li.L3, +li.L5, +li.L7, +li.L9 { background: #eee } + +@media print { + .str { color: #060; } + .kwd { color: #006; font-weight: bold; } + .com { color: #600; font-style: italic; } + .typ { color: #404; font-weight: bold; } + .lit { color: #044; } + .pun { color: #440; } + .pln { color: #000; } + .tag { color: #006; font-weight: bold; } + .atn { color: #404; } + .atv { color: #060; } +} diff --git a/bash.md b/bash.md new file mode 100644 index 000000000..4a8a69ce1 --- /dev/null +++ b/bash.md @@ -0,0 +1,181 @@ +title: Bash +--- + +### String substitutions by patterns + + STR=/path/to/foo.c + + echo ${STR%.c} #=> "/path/to/foo" + echo ${STR%.c}.o #=> "/path/to/foo.o" + echo ${STR##*.} #=> "c" (extension) + + BASE=${SRC##*/} #=> "foo.c" (basepath) + DIR=${SRC%$BASE} #=> "/path/to" + +### Substitutions by regex + + echo ${STR/hi/hello} # Replace first match + echo ${STR//hi/hello} # Replace all matches + echo ${STR/#hi/hello} # ^hi + echo ${STR/%hi/hello} # hi$ + + echo "${STR:0:3}" # .substr(0, 3) -- position, length + echo "${STR:-3:3}" # Negative position = from the right + + echo ${#line} # Length of $line + + [ -z "$CC" ] && CC=gcc # CC ||= "gcc" assignment + ${CC:=gcc} # $CC || "gcc" + +### Loops + + for i in /etc/rc.*; do + echo $i + end + +Functions +--------- + +### Defining functions + + myfunc() { ... } + fuction myfunc { ... } + fuction myfunc() { ... } + +### Returning strings + + myfunc() { + local myresult='some value' + echo $myresult + } + + result=$(myfunc) + +### Errors + + myfunc() { return 1; } + +### Arguments + + $# # Number of arguments + $* # All args + $1 # First argument + +Ifs - files +----------- + + # File conditions + if [ -a FILE ]; then # -e exists -d directory -f file + fi # -r readable -w writeable -x executable + # -h symlink -s size > 0 + + # File comparisons + if [ FILE1 -nt FILE2 ] # -nt 1 more recent than 2 + # -ot 2 more recent than 1 + # -ef same files + +Ifs +--- + + # String + if [ -z STRING ] # empty? + if [ -n STRING ] # not empty? + + # Numeric + if [ $? -eq 0 ] # -eq -ne -lt -le -gt -ge + # $? is exit status by the way + + # Etc + if [ -o noclobber ] # if OPTIONNAME is enabled + if [ ! EXPR ] # not + if [ ONE -a TWO ] # and + if [ ONE -o TWO ] # or + + # Regex + if [[ "A" =~ "." ]] + +### Numeric comparisons + + if $(( $a < $b )) + +### Unset variables + +Assume `$FOO` is not set. Doing *this* will result in *that*: + + ${FOO:-word} # Returns word + ${FOO:+word} # Returns empty, or word if set + ${FOO:=word} # Sets parameter to word, returns word + ${FOO:?message} # Echoes message and exits + + ${FOO=word} # : is optional in all of the above + +Numeric calculations +-------------------- + + $((RANDOM%=200)) # Random number 0..200 + $((a + 200)) # $ is optional + +Arrays +------ + + Fruits[0]="Apple" + Fruits[1]="Banana" + Fruits[2]="Orange" + + # Declaring using declare -a + declare -a Fruits=('Apple' 'Banana' 'Orange') + + echo ${Fruits[0]} # Element #0 + echo ${Fruits[@]} # All elements, space-separated + echo ${#Fruits[@]} # Number of elements + echo ${#Fruits} # String length of the 1st element + echo ${#Fruits[3]} # String length of the Nth element + echo ${Fruits[@]:3:2} # Range (from position 3, length 2) + + Fruits=("${Fruits[@]}" "Watermelon") # Push + Fruits=( ${Fruits[@]/Ap*/} ) # Remove by regex match + unset Fruits[2] # Remove one item + Fruits=("${Fruits[@]}") # Duplicate + Fruits=("${Fruits[@]}" "${Veggies[@]}") # Concatenate + lines=(`cat "logfile"`) # Read from file + +Misc crap +--------- + + command -V cd #=> "cd is a function/alias/whatever" + +### Options + + set -o noclobber # Avoid overlay files (echo "hi" > foo) + set -o errexit # Used to exit upon error, avoiding cascading errors + set -o pipefail # Unveils hidden failures + set -o nounset # Exposes unset variables + +### Glob options + + set -o nullglob # Non-matching globs are removed ('*.foo' => '') + set -o failglob # Non-matching globs throw errors + set -o nocaseglob # Case insensitive globs + set -o dotglob # Wildcards match dotfiles ("*.sh" => ".foo.sh") + set -o globstar # Allow ** for recursive matches ('lib/**/*.rb' => 'lib/a/b/c.rb') + +set GLOBIGNORE as a colon-separated list of patterns to be removed from glob +matches. + +### Trap errors + + trap 'echo Error at about $LINENO' ERR + +or + + traperr() { + echo "ERROR: ${BASH_SOURCE[1]} at about ${BASH_LINENO[0]}" + } + + set -o errtrace + trap traperr ERR + +References +---------- + +* http://wiki.bash-hackers.org/ diff --git a/brew.md b/brew.md new file mode 100644 index 000000000..b152cc82e --- /dev/null +++ b/brew.md @@ -0,0 +1,30 @@ +title: Brew +--- + +Nice Homebrew packages: + + * `tig` - Git "GUI" for the console + * `mysql` + * `postgresql` + * `fmdiff` - Adaptor to use Apple's FileMerge as `diff` (`git config --global merge-tool fmdiff`) + * `cmus` - Curses-based music player + * `cclive` - Video downloader + + Not from brew: + +* `DiffMerge` - nice free merge tool for OSX + +Tmux +---- + +Install a more-recent version that supports tmux -C + + brew install https://github.com/adamv/homebrew-alt/raw/master/other/tmux-iterm2.rb + +Install the wrapper for stuff to enable OSX clipboard to work + + brew install reattach-to-user-namespace --wrap-pbcopy-and-pbpaste + +Make sure that your VIM alias uses it + + alias vim="reattach-to-user-namespace /Application/MacVim/Contents/MacOS/Vim" diff --git a/capybara.md b/capybara.md new file mode 100644 index 000000000..30f9cc34e --- /dev/null +++ b/capybara.md @@ -0,0 +1,95 @@ +Navigating +---------- + + visit articles_path + +Clicking links and buttons +-------------------------- + + click 'Link Text' + click_button + click_link + +Interacting with forms +---------------------- + + attach_file + fill_in 'First Name', :with => 'John' + check + uncheck + choose + select + unselect + +Querying +-------- + +Takes a CSS selector (or XPath if you're into that). +Translates nicely into RSpec matchers: + + page.should have_no_button("Save") + +Use should have_no_* versions with RSpec matchers b/c +should_not doesn't wait for a timeout from the driver + + page.has_content? + page.has_css? + page.has_no_content? + page.has_no_css? + page.has_no_xpath? + page.has_xpath? + page.has_link? + page.has_no_link? + page.has_button?("Update") + page.has_no_button? + page.has_field? + page.has_no_field? + page.has_checked_field? + page.has_unchecked_field? + page.has_no_table? + page.has_table? + page.has_select? + page.has_no_select? + +Finding +------- + + find + find_button + find_by_id + find_field + find_link + locate + +Scoping +------- + + within + within_fieldset + within_table + within_frame + scope_to + +Scripting +--------- + + execute_script + evaluate_script + +Debugging +--------- + + save_and_open_page + +Miscellaneous +------------- + + all + body + current_url + drag + field_labeled + source + wait_until + current_path + diff --git a/cinema4d.md b/cinema4d.md new file mode 100644 index 000000000..c144e99e1 --- /dev/null +++ b/cinema4d.md @@ -0,0 +1,2 @@ + E R T : Move/rotate/scale + P : snapping diff --git a/config.ru b/config.ru new file mode 100644 index 000000000..3625015e5 --- /dev/null +++ b/config.ru @@ -0,0 +1,26 @@ +# This file exists to make this project Rack-compatible. +# You may delete it if you're not concerned about this. + +require 'rubygems' unless defined?(::Gem) + +# Use Bundler if possible. +begin + require 'bundler' + Bundler.setup +rescue LoadError + gem 'proton', '0.3.2' +end + +# Optional: use the 'rack-cache' gem for cacheing. +if ENV['RACK_ENV'] == 'production' + begin + require 'rack/cache' + use Rack::Cache + rescue LoadError + end +end + +# Load Proton. +require 'proton/server' +Proton::Project.new File.dirname(__FILE__) +run Proton::Server diff --git a/devise.md b/devise.md new file mode 100644 index 000000000..24c731f08 --- /dev/null +++ b/devise.md @@ -0,0 +1,126 @@ +title: Devise +--- + +[Devise](https://github.com/plataformatec/devise) is a flexible authentication +gem. + +Installation +------------ + +Rails 3: Add the following to your Gemfile + + gem "devise" + gem "hpricot" + gem "ruby_parser" + +Install devise in your project + + $ rails generate devise:install + +Generate devise for your model + + $ rails generate devise MODEL + $ rake db:migrate + +(Optional) Generate devise views + + $ rails generate devise:views + +Helpers +------- + + user_signed_in? + current_user + user_session + destroy_user_session_path (Logout) + new_user_session_path (Login) + edit_user_registration_path (Edit registration) + new_user_registration_path (Register new user) + +Controller stuff +---------------- + + before_filter :authenticate_user! + +Model +----- + +### Model options + + class User < ActiveRecord::Base + devise :database_authenticatable, + :registerable, + :confirmable, + :recoverable, + :rememberable, + :trackable, + :validatable + end + +### Migration helpers + + create_table :users do |t| + t.database_authenticatable + t.confirmable + t.recoverable + t.rememberable + t.trackable + t.timestamps + end + +Routing +------- + +### Authenticated and unauthenticated routes + + unauthenticated do + root :to => 'home#index' + end + + authenticated do + root :to => 'dashboard#index' + end + +### As + as :user do + get 'sign_in', :to => 'devise/sessions#new' + end + +### Devise_for magic + + devise_for :users + + # Session routes for Authenticatable (default) + new_user_session GET /users/sign_in {:controller=>"devise/sessions", :action=>"new"} + user_session POST /users/sign_in {:controller=>"devise/sessions", :action=>"create"} + destroy_user_session GET /users/sign_out {:controller=>"devise/sessions", :action=>"destroy"} + + # Password routes for Recoverable, if User model has :recoverable configured + new_user_password GET /users/password/new(.:format) {:controller=>"devise/passwords", :action=>"new"} + edit_user_password GET /users/password/edit(.:format) {:controller=>"devise/passwords", :action=>"edit"} + user_password PUT /users/password(.:format) {:controller=>"devise/passwords", :action=>"update"} + POST /users/password(.:format) {:controller=>"devise/passwords", :action=>"create"} + + # Confirmation routes for Confirmable, if User model has :confirmable configured + new_user_confirmation GET /users/confirmation/new(.:format) {:controller=>"devise/confirmations", :action=>"new"} + user_confirmation GET /users/confirmation(.:format) {:controller=>"devise/confirmations", :action=>"show"} + POST /users/confirmation(.:format) {:controller=>"devise/confirmations", :action=>"create"} + +### Customizing devise_for + + devise_for :users, + :path => "usuarios", + :path_names => { + :sign_in => 'login', + :sign_out => 'logout', + :password => 'secret', + :confirmation => 'verification', + :unlock => 'unblock', + :registration => 'register', + :sign_up => 'cmon_let_me_in' } + +Test helpers +------------ + + sign_in @user + sign_out @user diff --git a/figlets.txt b/figlets.txt new file mode 100644 index 000000000..d5780b6b2 --- /dev/null +++ b/figlets.txt @@ -0,0 +1,1293 @@ + **** ** + */// * /** +/ /* /** + *** ***** ****** + /// *///// **///** + * /* /** /** +/ **** //****** + //// ////// + +### ### + # # # # + ## # ### + # # # # +### ### + + + ____ + // // ( ) __ ___ ___ / __ // ( ) ___ + //__ // / / // ) ) //___) ) // ) ) // ) ) // / / // ) ) // / / + ) ) // / / // / / // // / / // / / // / / ((___/ / // / / +((___/ / // / / // / / ((____ ((___/ / ((___/ / // / / ( ( ((___( ( + + + + ___ + //___) ) + // +((____ + o + <|> + / > + o__ __o/ __o__ \o__ __o o__ __o \o__ __o o__ __o/ + /v | /> \ | |> /v v\ | v\ /v | + /> / \ o/ / \ < > /> <\ / \ <\ /> / \ + \ \o/ <| \o/ \ / \o/ / \ \o/ + o | \\ | o o | o o | + <\__ / \ _\o__ / \ __/> <\__ / \ + + + + o o + <|> _<|>_ + < > + | o __o__ + o__/_ <|> /> \ + | / \ o/ + | \o/ <| + o | \\ + <\__ / \ _\o__<< ><< +><< ><< >< +><< ><< >< ><<<><< ><< ><<< >< ><<< ><< +><< ><< ><< ><< ><< ><< ><< ><< < ><<><< ><< >< ><< +><< ><<><< ><< ><< ><< ><< ><< >< ><<><< ><< ><<<<< ><< +><< ><<><< ><< ><< ><< ><< >< >< ><><<><< ><< >< +><< ><< ><< ><<<><<< ><< ><< ><<< ><<<><<><<< ><<<< + +d8888b. .d8b. .d8888. d888888b .o88b. +88 `8D d8' `8b 88' YP `88' d8P Y8 +88oooY' 88ooo88 `8bo. 88 8P +88~~~b. 88~~~88 `Y8b. 88 8b +88 8D 88 88 db 8D .88. Y8b d8 +Y8888P' YP YP `8888Y' Y888888P `Y88P' + + + _ . . + \ ___ ___ | | + |/ \ .' ` | | + | ` |----' | | + `___,' `.___, /\__ /\__ + + _ _ +| | (_) +| |__ _ __ _ +| '_ \| |/ _` | +| |_) | | (_| | +|_.__/|_|\__, | + __/ | + |___/ +______________________________________________ + _ + / , / , / ` +---/__--------__----__---/__--------__--_/__-- + / ) / / ) / ' / ) / /___) / +_(___/_/___(___/_(___ _/___/_/___(___ _/______ + / + (_ / +01100010 01101001 01101110 01100001 01110010 01111001 + +_| _| _| +_|_|_| _| _|_| _|_|_| _| _| +_| _| _| _| _| _| _|_| +_| _| _| _| _| _| _| _| +_|_|_| _| _|_| _|_|_| _| _| + + + +8 888888888o 8 888888888o. ,o888888o. .8. +8 8888 `88. 8 8888 `88. . 8888 `88. .888. +8 8888 `88 8 8888 `88 ,8 8888 `8b :88888. +8 8888 ,88 8 8888 ,88 88 8888 `8b . `88888. +8 8888. ,88' 8 8888. ,88' 88 8888 88 .8. `88888. +8 8888888888 8 888888888P' 88 8888 88 .8`8. `88888. +8 8888 `88. 8 8888`8b 88 8888 ,8P .8' `8. `88888. +8 8888 88 8 8888 `8b. `8 8888 ,8P .8' `8. `88888. +8 8888 ,88' 8 8888 `8b. ` 8888 ,88' .888888888. `88888. +8 888888888P 8 8888 `88. `8888888P' .8' `8. `88888. + +8 888888888o. `8.`888b ,8' .8. `8.`8888. ,8' +8 8888 `^888. `8.`888b ,8' .888. `8.`8888. ,8' +8 8888 `88. `8.`888b ,8' :88888. `8.`8888. ,8' +8 8888 `88 `8.`888b .b ,8' . `88888. `8.`8888.,8' +8 8888 88 `8.`888b 88b ,8' .8. `88888. `8.`88888' +8 8888 88 `8.`888b .`888b,8' .8`8. `88888. `8. 8888 +8 8888 ,88 `8.`888b8.`8888' .8' `8. `88888. `8 8888 +8 8888 ,88' `8.`888`8.`88' .8' `8. `88888. 8 8888 +8 8888 ,o88P' `8.`8' `8,`' .888888888. `88888. 8 8888 +8 888888888P' `8.` `8' .8' `8. `88888. 8 8888 + _ _ _ _ _ _ + / \ / \ / \ / \ / \ / \ +( b | u | b | b | l | e ) + \_/ \_/ \_/ \_/ \_/ \_/ + ____ __ __ __ ____ _ _ ____ __ ____ +( _ \( )( )( ) ( _ \( )_( )( ___) /__\ ( _ \ + ) _ < )(__)( )(__ ) _ < ) _ ( )__) /(__)\ )(_) ) +(____/(______)(____)(____/(_) (_)(____)(__)(__)(____/ + + ### / + ### #/ + ## ## + ## ## + ## ## + /### /### ## /### /### ## /## ## #### + / ### / / ### / ## / ### / / ### / ## / ### ## ### / + / ###/ / ###/ ## / ###/ / ###/ ##/ ### ## ###/ +## ## ## ## ## ## ## ## ## ## ## ## +## ## ## ## ## ## ## ## ## ## ## ## +## ## ## ## ## ## ## ## ## ## ## ## +## ## ## ## ## ## ## ## ## ## ## ## +### / ## /# ## ## ## ## ## ## ## ## ## n + ######/ ####/ ## ### / ######## ####### ## ## ######### u + ##### ### ## ##/ ### ### ###### ## ## #### ### m + ### ## / ### b + #### ### ## / ##### ### e + /###### /# ## / /####### /# r + / ###/ ## / / ###/ 2 + + *** + *** * + ** *** + ** * + ** *** **** + **** **** ** *** **** **** **** * **** + * *** * * *** * ** *** * *** * ** **** * *** * + * **** * **** ** ** * **** ** * **** +** ** ** ** ** ** ** ** ** ** +** ** ** ** ** ** ** ** ** ** +** ** ** ** ** ** ** ** ** ** +** ** ** ** ** ** ** ** ** ** +*** * ** ** ** ** ** ** *** ** ** + ******* ***** ** *** * *** * ******** *** ***** ** + ***** *** ** *** *** *** *** *** ** + *** + **** *** + ******* ** + * **** + + + * + ** + ** + ** + **** ** ** **** + * *** * ** *** ** *** * + * **** ** * *** ** **** +** ** *** *** ** ** +** ** ** ** ** ** +** ** ** ** ** ** +** ** ** ** ** ** +** ** ** ** ** ** +******* ** ** ********* +****** ** ** **** *** +** ** ** *** +** * ***** *** +** * ******** ** + ** * * **** + * + + _// _//_// + _// _//_// + _/// _// _/_/ _/_// _/// _// _//_// _// + _// _// _// _// _// / _// _// _// _//_// _// +_// _// _// _// _// _/ _//_// _// _//_/_// + _// _// _// _// _/ _/ _/_//_// _// _//_// _// + _/// _// _/// _// _/// _/// _// _///_///_// _// + + __ __ +.----.| |--.--.--.-----.| |--.--.--. +| __|| | | | || <| | | +|____||__|__|_____|__|__||__|__|___ | + |_____| + O)) O)) + O) O)) O)) + O))) O)) O)) O)) O)))) O)O) O) O)) O)) O)) + O)) O)) O)) O)) O)) O))O)) O)) O)) O)) O)) O)) +O)) O)) O))O)) O)) O)) O))) O)) O)) O)) O)O)) + O)) O)) O)) O)) O)) O)) O)) O)) O)) O)) O)) O)) + O))) O)) O))O))) O))O)) O)) O)) O)) O)))O)) O)) + + 888 888 + 888 888 + 888 888 + .d8888b .d88b. 888 .d88b. .d8888b .d8888b 8888b. 888 +d88P" d88""88b888d88""88b88K 88K "88b888 +888 888 888888888 888"Y8888b."Y8888b..d888888888 +Y88b. Y88..88P888Y88..88P X88 X88888 888888 + "Y8888P "Y88P" 888 "Y88P" 88888P' 88888P'"Y888888888 + + + + +eeee eeeee eeeeeee eeeee e e eeeee eeee eeeee +8 8 8 88 8 8 8 8 8 8 8 8 8 8 8 +8e 8 8 8e 8 8 8eee8 8e 8 8e 8eee 8eee8e +88 8 8 88 8 8 88 88 8 88 88 88 8 +88e8 8eee8 88 8 8 88 88ee8 88 88ee 88 8 + + , + _. _ ._ -+- _ __ __ _. +(_.(_)[ ) | (/,_) _) (_] + +..%%%%....%%%%...%%..%%..%%%%%%..%%%%%....%%%%....%%%%...%%%%%%. +.%%..%%..%%..%%..%%%.%%....%%....%%..%%..%%..%%..%%........%%... +.%%......%%..%%..%%.%%%....%%....%%%%%...%%%%%%...%%%%.....%%... +.%%..%%..%%..%%..%%..%%....%%....%%..%%..%%..%%......%%....%%... +..%%%%....%%%%...%%..%%....%%....%%..%%..%%..%%...%%%%.....%%... +................................................................ + .,-::::: ... .::::::. . : ::: .,-::::: +,;;;'````' .;;;;;;;. ;;;` ` ;;,. ;;; ;;;,;;;'````' +[[[ ,[[ \[[,'[==/[[[[,[[[[, ,[[[[, [[[[[[ +$$$ $$$, $$$ ''' $$$$$$$$$"$$$ $$$$$$ +`88bo,__,o,"888,_ _,88P 88b dP888 Y88" 888o888`88bo,__,o, + "YUMMMMMP" "YMMMMMP" "YMmMY" MMM M' "MMMMMM "YUMMMMMP" + .,-::::: ... .::::::. . : ::: ::: . .,:::::: +,;;;'````' .;;;;;;;. ;;;` ` ;;,. ;;; ;;; ;;; .;;,.;;;;'''' +[[[ ,[[ \[[,'[==/[[[[,[[[[, ,[[[[, [[[ [[[[[/' [[cccc +$$$ $$$, $$$ ''' $$$$$$$$$"$$$ $$$_$$$$, $$"""" +`88bo,__,o,"888,_ _,88P 88b dP888 Y88" 888o888"888"88o, 888oo,__ + "YUMMMMMP" "YMMMMMP" "YMmMY" MMM M' "MMMMMM MMM "MMP" """"YUMMM + __ ____ ____ __ __ _____ ___ ____ ___ + / ]| \ / T| T__T T| | / \ | \ | \ + / / | D )Y o || | | || __jY Y| D )| \ + / / | / | || | | || l_ | O || / | D Y +/ \_ | \ | _ |l ` ' !| _] | || \ | | +\ || . Y| | | \ / | T l !| . Y| | + \____jl__j\_jl__j__j \_/\_/ l__j \___/ l__j\_jl_____j + + __ __ __ +.----.----|__.----| |--.-----| |_ +| __| _| | __| <| -__| _| +|____|__| |__|____|__|__|_____|____| + + + + + + + _. . . __ _ o, __ +(__(_/_/ (_/_)_<_\/| . \/ ._>| . \| . \/ ._>| '_> +\___||_| | _/\___.| _/| _/\___.|_| + |_| |_| |_| + whistl +X XX +X XX +X XX +X XX +X XX +X .X + +dwhistled + +################## +##[`'`']###\`~'/## +###|::|####(o o)## +###|::|#####\ / \# +#############"#### + __ __ + _/ _|||()/ _| _ || +/o\ ] | ]|| ]o\|/ \| ] +\(L| L|L|L|\_/L_n|L| + + +eftipiti + + _ _ _ _ _ + ,'_)( ) (_) ( ) ( ) + ___ | | | | _ __ ___ | |_ ___ | | +( o_)( _)( _)( )( _)( o )( o \( o )( _) + \( /_\ /_\ /_\/_\ \_/ /___/ \_/ /_\ + + _ + __ ,'_7/7 ()/7 _ /7() __ +,'o//_7 /_7/7/_7,'o| ///7,',' +|_(// // //// |_,7//// \_\ + + |"| _ . . # # # # + _|_|_ _|_|_ ()_() . .:::. # #..# # + (o o) (o o) (o o) :(o o): . # #O #) # +ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--`o'--Ooo-ooO--(_)--Ooo-o#O-#(_#--#oo- + | _ _ _ _ + |.===. o' \,=./ `o o' \,=./ `o + {}o o{} (o o) (o o) +ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo- + __ _ o _ + __ )L`)L _ __ _ _ ___ )L __ __ +(('(( (( (( \(((/'((_( (( (('(| + + _______ _______ _________ _______ +( ____ \( ____ )\__ __/( ____ \ +| ( \/| ( )| ) ( | ( \/ +| (__ | (____)| | | | | +| __) | _____) | | | | +| ( | ( | | | | +| (____/\| ) ___) (___| (____/\ +(_______/|/ \_______/(_______/ + + .|'; ||` + || || +'||' .|''|, `||''|, .|''|| .|''|, '||''| + || ||..|| || || || || ||..|| || +.||. `|... .|| ||. `|..||. `|... .||. + + + /~\ | +-|-/~\| ||/~\~|~/~\|~~\(~ + | \_/ \_/|| | \_/|__/_) + | + .. s + oec : < .z@8"` :8 + @88888 .u . !@88E .88 x. . + 8"*88% .d88B :@8c u '888E u :888ooo .@88k z88u + 8b. ="8888f8888r us888u. 888E u@8NL -*8888888 ~"8888 ^8888 + u888888> 4888>'88" .@88 "8888" 888E`"88*" 8888 8888 888R + 8888R 4888> ' 9888 9888 888E .dN. 8888 8888 888R + 8888P 4888> 9888 9888 888E~8888 8888 8888 888R + *888> .d888L .+ 9888 9888 888E '888& .8888Lu= 8888 ,888B . + 4888 ^"8888*" 9888 9888 888E 9888. ^%888* "8888Y 8888" + '888 "Y" "888*""888" '"888*" 4888" 'Y" `Y" 'YP + 88R ^Y" ^Y' "" "" + 88> + 48 + '8 + + + .u . + .d88B :@8c +="8888f8888r + 4888>'88" + 4888> ' + 4888> + .d888L .+ + ^"8888*" + "Y" + + + + + .--. +: .-' +: `;.-..-..---. .---. .-..-. +: : : :; :`-'_.'`-'_.': :; : +:_; `.__.'`.___;`.___;`._. ; + .-. : + `._.' +__ _____ _____ ___ ___ __ __ + ) ____) ) ( ) ( \ ___) ( ( ) ) + / / __ / \ / \ | (__ \ \/ / +( ( ( \ ( ) ( ) | __) \ / + \ \__) ) \ / \ / | ( ) / +__) (____) (_____) (___/ \______/ (_____ + + , ,, + _ || || ' + / \\ /'\\ =||= ||/\\ \\ _-_ +|| || || || || || || || || +|| || || || || || || || || +\\_-| \\,/ \\, \\ |/ \\ \\,/ + / \ _/ +'----` + ___ ____ __ ___ ____ ____ _ _ __ + / __)( _ \ / _\ / __)( __)( __)/ )( \( ) +( (_ \ ) // \( (__ ) _) ) _) ) \/ (/ (_/\ + \___/(__\_)\_/\_/ \___)(____)(__) \____/\____/ +.eeeeee..eeeeeee...eeeeee..eeeeeee..eee.eeeeee.eeeeeee..eeeeeeeee. +@@@@@@@@:@@@@@@@@:@@@@@@@@:@@@@@@@@:@@@:@@@@@@:@@@@@@@@:@@@@@@@@@: +%%%------%%%--%%%-%%%--%%%-%%%--%%%-%%%-%%%----%%%--%%%----%%%---- +&&&++++++&&&&&&&++&&&&&&&&+&&&++&&&+&&&+&&&&&++&&&++&&&++++&&&++++ +|||*||||*||||||***||||||||*|||**|||*|||*|||||**|||**|||****|||**** +!!!==!!!=!!!=!!!==!!!==!!!=!!!==!!!=!!!=!!!====!!!==!!!====!!!==== +::::::::#:::##:::#:::##:::#::::::::#:::#::::::#:::##:::####:::#### +@......@@...@@...@...@@...@.......@@...@......@...@@...@@@@...@@@@ + + _____ _____.__ __ .__ + ________________ _/ ____\/ ____\__|/ |_|__| + / ___\_ __ \__ \\ __\\ __\| \ __\ | + / /_/ > | \// __ \| | | | | || | | | + \___ /|__| (____ /__| |__| |__||__| |__| +/_____/ \/ +68 65 78 + + /' /' /' /' + /' /' /' /' + /'__ ____ /' /' . . , , ____ ____ _____,/' + /' ) /' )--/' /' /' /| |/ / /' )--/' )--/' /' + /' /' /' /' /' /' /' /' | /| /' /' /' /' /' /' /' +/' /(__(___,/' (__(__(___,/(___|/' |/(__(___,/' (___,/' (___,/(__ + /' + / /' + (___,/' + + , , + __ _ _ _/_ _ +_(_/ (_(/___(_(__(_(_ + + + ___ ___ ___ ___ + ___ /\ \ /\ \ /\__\ /\ \ + /\ \ /::\ \ /::\ \ /::| | /::\ \ + \:\ \ /:/\ \ \ /:/\:\ \ /:|:| | /:/\:\ \ + /::\__\ _\:\~\ \ \ /:/ \:\ \ /:/|:|__|__ /::\~\:\ \ + __/:/\/__/ /\ \:\ \ \__\ /:/__/ \:\__\ /:/ |::::\__\ /:/\:\ \:\__\ + /\/:/ / \:\ \:\ \/__/ \:\ \ /:/ / \/__/~~/:/ / \:\~\:\ \/__/ + \::/__/ \:\ \:\__\ \:\ /:/ / /:/ / \:\ \:\__\ + \:\__\ \:\/:/ / \:\/:/ / /:/ / \:\ \/__/ + \/__/ \::/ / \::/ / /:/ / \:\__\ + \/__/ \/__/ \/__/ \/__/ + ___ ___ ___ + /\ \ /\ \ ___ /\ \ + \:\ \ /::\ \ /\ \ /::\ \ + \:\ \ /:/\:\ \ \:\ \ /:/\:\ \ + /::\ \ /::\~\:\ \ /::\__\ /:/ \:\ \ + /:/\:\__\ /:/\:\ \:\__\ __/:/\/__/ /:/__/ \:\__\ + /:/ \/__/ \/_|::\/:/ / /\/:/ / \:\ \ \/__/ + /:/ / |:|::/ / \::/__/ \:\ \ + \/__/ |:|\/__/ \:\__\ \:\ \ + |:| | \/__/ \:\__\ + \|__| \/__/ + ___ ___ ___ ___ + /\__\ /\ \ /\ \ /\__\ + ___ /:/ _/_ /::\ \ |::\ \ /:/ _/_ + /\__\ /:/ /\ \ /:/\:\ \ |:|:\ \ /:/ /\__\ + /:/__/ /:/ /::\ \ /:/ \:\ \ __|:|\:\ \ /:/ /:/ _/_ + /::\ \ /:/_/:/\:\__\ /:/__/ \:\__\ /::::|_\:\__\ /:/_/:/ /\__\ + \/\:\ \__ \:\/:/ /:/ / \:\ \ /:/ / \:\~~\ \/__/ \:\/:/ /:/ / + ~~\:\/\__\ \::/ /:/ / \:\ /:/ / \:\ \ \::/_/:/ / + \::/ / \/_/:/ / \:\/:/ / \:\ \ \:\/:/ / + /:/ / /:/ / \::/ / \:\__\ \::/ / + \/__/ \/__/ \/__/ \/__/ \/__/ + ___ ___ + /\ \ /\__\ + ___ /::\ \ ___ /:/ / + /\__\ /:/\:\__\ /\__\ /:/ / + /:/ / /:/ /:/ / /:/__/ /:/ / ___ + /:/__/ /:/_/:/__/___ /::\ \ /:/__/ /\__\ + /::\ \ \:\/:::::/ / \/\:\ \__ \:\ \ /:/ / + /:/\:\ \ \::/~~/~~~~ ~~\:\/\__\ \:\ /:/ / + \/__\:\ \ \:\~~\ \::/ / \:\/:/ / + \:\__\ \:\__\ /:/ / \::/ / + \/__/ \/__/ \/__/ \/__/ + ___ ___ ___ ___ + ___ / /\ / /\ /__/\ / /\ + / /\ / /:/_ / /::\ | |::\ / /:/_ + / /:/ / /:/ /\ / /:/\:\ | |:|:\ / /:/ /\ + /__/::\ / /:/ /::\ / /:/ \:\ __|__|:|\:\ / /:/ /:/_ + \__\/\:\__ /__/:/ /:/\:\ /__/:/ \__\:\ /__/::::| \:\ /__/:/ /:/ /\ + \ \:\/\ \ \:\/:/~/:/ \ \:\ / /:/ \ \:\~~\__\/ \ \:\/:/ /:/ + \__\::/ \ \::/ /:/ \ \:\ /:/ \ \:\ \ \::/ /:/ + /__/:/ \__\/ /:/ \ \:\/:/ \ \:\ \ \:\/:/ + \__\/ /__/:/ \ \::/ \ \:\ \ \::/ + \__\/ \__\/ \__\/ \__\/ + ___ ___ + ___ / /\ ___ / /\ + / /\ / /::\ / /\ / /:/ + / /:/ / /:/\:\ / /:/ / /:/ + / /:/ / /:/~/:/ /__/::\ / /:/ ___ + / /::\ /__/:/ /:/___ \__\/\:\__ /__/:/ / /\ + /__/:/\:\ \ \:\/:::::/ \ \:\/\ \ \:\ / /:/ + \__\/ \:\ \ \::/~~~~ \__\::/ \ \:\ /:/ + \ \:\ \ \:\ /__/:/ \ \:\/:/ + \__\/ \ \:\ \__\/ \ \::/ + \__\/ \__\/ + ___ ___ ___ ___ + ___ / /\ / /\ / /\ / /\ + /__/\ / /::\ / /::\ / /::| / /::\ + \__\:\ /__/:/\:\ / /:/\:\ / /:|:| / /:/\:\ + / /::\ _\_ \:\ \:\ / /:/ \:\ / /:/|:|__ / /::\ \:\ + __/ /:/\/ /__/\ \:\ \:\ /__/:/ \__\:\ /__/:/_|::::\ /__/:/\:\ \:\ + /__/\/:/~~ \ \:\ \:\_\/ \ \:\ / /:/ \__\/ /~~/:/ \ \:\ \:\_\/ + \ \::/ \ \:\_\:\ \ \:\ /:/ / /:/ \ \:\ \:\ + \ \:\ \ \:\/:/ \ \:\/:/ / /:/ \ \:\_\/ + \__\/ \ \::/ \ \::/ /__/:/ \ \:\ + \__\/ \__\/ \__\/ \__\/ + ___ ___ + ___ / /\ ___ / /\ + /__/\ / /::\ /__/\ / /::\ + \ \:\ / /:/\:\ \__\:\ / /:/\:\ + \__\:\ / /::\ \:\ / /::\ / /:/ \:\ + / /::\ /__/:/\:\_\:\ __/ /:/\/ /__/:/ \ \:\ + / /:/\:\ \__\/~|::\/:/ /__/\/:/~~ \ \:\ \__\/ + / /:/__\/ | |:|::/ \ \::/ \ \:\ + /__/:/ | |:|\/ \ \:\ \ \:\ + \__\/ |__|:|~ \__\/ \ \:\ + \__\| \__\/ + + '_/_ /'_ +/ /(/(/( + + _ _ _ + | |_(_)_ ____ _(_) + | __| | '__\ \ / / | + | |_| | | \ V /| | + \__|_|_| \_/ |_| + + + o o + +o8 .oPYo. .oooo. ooYoYo. o8 odYo. .oPYo. + 8 .oooo8 .dP 8' 8 8 8 8' `8 8oooo8 + 8 8 8 oP' 8 8 8 8 8 8 8. + 8 `YooP8 `Yooo' 8 8 8 8 8 8 `Yooo' +:8 :.....::.....:..:..:..:....::..:.....: +oP :::::::::::::::::::::::::::::::::::::: +..::::::::::::::::::::::::::::::::::::::: + + __ __.______ _______ _ _ _ _______ ___ ______ ______ _______ + \ \ / /|____ |____ .| | | | | |____ |_ |____ |____ |. __ | + \ V / _ | | | || | | | | | | | | | | | _ | || | | | + ___\ \ | | |_| | || |/ /_/ / | | | | | || | |_|| | | | + |______| | | | ||_______/ |_| |_| |_|| | |_| |_| + |_| |_| |_| + # # # # ###### + ###### # ### ####### # ### ###### # ### + # #### # # #### # #### ########## + # # # # # # # # # + # # ########## # # # ## +########## # # # ########## # ## + ####### # ####### ####### ## + +# +# ### +#### +# +# +# + ####### + +'|| '|| + || .. || ... .... .. ... + || .' ||' || '' .|| || || + ||'|. || | .|' || || || +.||. ||. '|...' '|..'|' .||. ||. + + +|Am3 + ___ __ __ +/\_ \ /'__`\ /\ \ +\//\ \ __ _ __ _ __ __ __/\_\L\ \ \_\ \ + \ \ \ /'__`\ /\`'__\/\`'__\/\ \/\ \/_/_\_<_ /'_` \ + \_\ \_/\ \L\.\_\ \ \/ \ \ \/ \ \ \_\ \/\ \L\ \/\ \L\ \ + /\____\ \__/.\_\\ \_\ \ \_\ \/`____ \ \____/\ \___,_\ + \/____/\/__/\/_/ \/_/ \/_/ `/___/> \/___/ \/__,_ / + /\___/ + \/__/ + + | | + + - -| + | | | | + - - - + + + _/ + _/ _/_/ _/_/_/ _/_/_/ + _/ _/_/_/_/ _/ _/ _/ _/ + _/ _/ _/ _/ _/ _/ +_/ _/_/_/ _/_/_/ _/ _/ + + +lll tt tt +lll eee tt tt eee rr rr sss +lll ee e tttt tttt ee e rrr r s +lll eeeee tt tt eeeee rr sss +lll eeeee tttt tttt eeeee rr s + sss +.-. .-..-..-..-..-..-..-. +| |__ | || .` || || | > < +`----'`-'`-'`-'`----''-'`-` + +:| :| +:| ,::\ .::/ :|_/ :~~/ :::| /::| :::\ ,::\ :\/| :~~/ +:| `::/ `::\ :|~\ :::, :| \::| :|:| `::/ :::| :::, + ,.:/ + | | +/=\=\ /=| /=| /= = /=| +| | | \=| \=| | | \=| + + + +.::: .:: .:: .:: .: .::: .:: .:: .:: .:: .:: + .:: .: .:: .:: .:: .:: .: .:: .:: .:: .: .:: .: .:: + .:: .: .::.:: .:: .:: .: .:: .:: .::.::::: .::.::::: .:: + .:: .: .::.:: .:: .:: .::.:: .:: .::.: .: +.::: .: .:: .:: .:::.::: .:: .::.:: .:::: .:::: + .::: + /~\ +|/~\ /~\ /~~|\/-|-/~\| ||/~\ +| | |\__|/\ | \_/ \_/|| + + |/ _ + ||\ _| | |/ + + +._ _ o._ o +| | ||| || + + _ + __ _ ___ __ _ __ _(_) ___ __ _ + |__` |/ _ \__` |__` | |/ _ ' _` | + | | (_) | | | | | | | | | | | + |_|\___/ |_| |_|_|_| |_| |_| + +mnemonic +-- --- .-. ... . + +# # ### #### # # ### # # +## ## # # # # # # # # # # +# # # # # # #### # # # # # +# # # # # # # # # # # +# # ### #### # ### ### + + ""|""| |""||""|'\/ + | ' |_|| ' | _\ + | | + oo .8888b + 88 " +88d888b. .d8888b. 88d888b. .d8888b. dP dP dP 88aaa .d8888b. +88' `88 88' `88 88' `88 88' `"" 88 88 88 88888888 88 88' `88 +88 88 88. .88 88 88 88. ... 88. .88 88 88 88. .88 +dP dP `88888P8 dP dP `88888P' `8888P88 88 dP `88888P8 + .88 88 + d8888P dP + + +88d888b. .d8888b. dP dP +88' `88 88' `"" 88 88 +88 88 88. ... 88. .88 +dP dP `88888P' `8888P88 + .88 + d8888P + oo + +88d888b. .d8888b. 88d888b. .d8888b. dP dP dP dP dP 88d888b. +88' `88 88' `88 88' `88 88' `"" 88 88 88 88888888 88 88 88' `88 +88 88 88. .88 88 88 88. ... 88. .88 88 88. .88 88 88 +dP dP `88888P8 dP dP `88888P' `8888P88 88 `88888P' dP dP +ooooooooooooooooooooooooooooooooooooo~~~~.88~88~ooooooooooooooooooooooooooo + d8888P dP + dP dP oo dP + 88 88 88 +.d888b88 .d8888b. 88d888b. 88 dP 88d888b. .d8888b. .d888b88 +88' `88 88ooood8 88' `88 88 88 88' `88 88ooood8 88' `88 +88. .88 88. ... 88 88 88 88 88 88. ... 88. .88 +`88888P8 `88888P' dP dP dP dP dP `88888P' `88888P8 +oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo + + oo + +88d888b. .d8888b. 88d888b. .d8888b. dP dP dP +88' `88 88' `88 88' `88 88' `"" 88 88 88 +88 88 88. .88 88 88 88. ... 88. .88 88 +dP dP `88888P8 dP dP `88888P' `8888P88 88 + .88 88 + d8888P dP + {__ + {_ {__ +{__ {__ {_ {__ {_ {__ {__ {__ {____ + {__ {__{__{_ {__ {_ {__ {__ {_ {__ {__ + {__ {__{__{_ {__{_ {__ {__{_____ {__ {___ + {__ {__{__{__ {__ {__ {__ {__{_ {__ +{___ {__{__{__ {__ {___ {____ {__ {__ + {__ {__ + + + + _ _____ _ _ ___ ___ ___ _ __ +| |/ ( | \ / ) _ \/ __) __) |/ / +| / / | | \ v / |_) > _)> _)| < +|__/ \_) | || __/\___)___)_|\_\ + | || | + |_||_| + + + + gg + "" + ,ggg,,ggg, ggg gg ,g, ,gggg, ,gggggg, gg gg,gggg, + ,8" "8P" "8, d8"Yb 88bg,8'8, dP" "Yb dP""""8I 88 I8P" "Yb + I8 8I 8I dP I8 8I ,8' Yb i8' ,8' 8I 88 I8' ,8i +,dP 8I Yb,,dP I8, ,8I,8'_ 8) ,d8,_ _,dP Y8,_,88,_,I8 _ ,d8' +8P' 8I `Y88" "Y8P" P' "YY8P8PP""Y8888PP8P `Y88P""Y8PI8 YY88888P + I8 + I8 + I8 + I8 + I8 + I8 + + I8 + I8 +88888888 + I8 + I8 + I8 + ,I8, + ,d88b, + 8P""Y8 + + + + + + + ooooooo + ooooooo o888 888o +888 888 888888888 +888 888 888o o888 + 88ooo88 88ooo88 + +157 143 164 141 154 + + ___ __ _ _ __ ___ + / _ \ / _` | '__/ _ \ +| (_) | (_| | | | __/ + \___/ \__, |_| \___| + |___/ +_________________ooooo__ +_ooooo___oooo__oo____oo_ +oo___oo_oo___o_______oo_ +oo___oo___oo_______ooo__ +oo___oo_o___oo___ooo____ +_ooooo___oooo__oooooooo_ +________________________ + + + + ____ ____ _ _ _ ____ +(____) (____)(_) ( ) (_)(____) +(_)_(_)( )_( )(_)_(_)_(_)(_)_(_) +(____) (__)_) (__) (__) (____) +(_) (_) +(_) (_) + /^^ + /^^ +/^ /^^ /^^ /^^ /^^ /^^ /^^^^ +/^ /^^ /^ /^^ /^^ /^^ /^^ /^^ /^^ +/^ /^^/^^^^^ /^^/^^ /^^ /^/^^ /^^^ +/^^ /^^ /^ /^^ /^^ /^^ /^^ /^^ +/^^ /^^^^ /^^ /^^^/^^ /^^/^^ /^^ +/^^ + o o o + O O O + O O o + o o O +.oOo. .oOo. OoOo. OoOo. o .oOo. .oOo +O o OooO' O o O o O OooO' `Ooo. +o O O o O o O o O O +oOoO' `OoO' `OoO' `OoO' Oo `OoO' `OoO' +O +o' + + _ _ _ _ _ _ + /_//_'/_//_//_'/ +/ / / + +@@@@@@@ @@@@@@ @@@ @@@@@@ @@@@@@ @@@ @@@ +@@@@@@@@ @@@@@@@@ @@@ @@@@@@@ @@@@@@@@ @@@@ @@@ +@@! @@@ @@! @@@ @@! !@@ @@! @@@ @@!@!@@@ +!@! @!@ !@! @!@ !@! !@! !@! @!@ !@!!@!@! +@!@@!@! @!@ !@! !!@ !!@@!! @!@ !@! @!@ !!@! +!!@!!! !@! !!! !!! !!@!!! !@! !!! !@! !!! +!!: !!: !!! !!: !:! !!: !!! !!: !!! +:!: :!: !:! :!: !:! :!: !:! :!: !:! + :: ::::: :: :: :::: :: ::::: :: :: :: + : : : : : :: : : : : : :: : + + ___ ___ + /'___)/'___) + _ _ _ _ | (__ | (__ _ _ +( '_`\ ( ) ( )| ,__)| ,__)( ) ( ) +| (_) )| (_) || | | | | (_) | +| ,__/'`\___/'(_) (_) `\__, | +| | ( )_| | +(_) `\___/' + ^ ^ ^ ^ ^ ^ ^ + /p\ /y\ /r\ /a\ /m\ /i\ /d\ +<___><___><___><___><___><___><___> + + _ _ + ___ ___ ___| |_ ___ ___ ___| |___ ___ +| _| -_| _| _| .'| | . | | -_|_ -| +|_| |___|___|_| |__,|_|_|_ |_|___|___| + |___| +______________________________________________________________ +/~~~~~~~\__/~~~~~~~~\_/~~\_______/~~~~\_/~~~~~~~~\_/~~~~~~~~\_ +/~~\__/~~\_/~~\_______/~~\________/~~\__/~~\_______/~~\_______ +/~~~~~~~\__/~~~~~~\___/~~\________/~~\__/~~~~~~\___/~~~~~~\___ +/~~\__/~~\_/~~\_______/~~\________/~~\__/~~\_______/~~\_______ +/~~\__/~~\_/~~~~~~~~\_/~~~~~~~~\_/~~~~\_/~~~~~~~~\_/~~\_______ +______________________________________________________________ +\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ +//////// \\///////// \/// \\\\\\\///// \///////// \///////// \\/////// \ +/// \\/// \/// \\\\\\\/// \\\\\\\\/// \\/// \\\\\\\/// \\\\\\\/// \/// \ +//////// \\/////// \\\/// \\\\\\\\/// \\/////// \\\/////// \\\\\\/// \\\ +/// \\/// \/// \\\\\\\/// \\\\\\\\/// \\/// \\\\\\\/// \\\\\\\\/// \\\\\ +/// \\/// \///////// \///////// \///// \///////// \/// \\\\\\\//////// \ +\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ +======================= +======================= +======================= +======================= += = ==== === = = += = == = == = = += ======= === == += ======= ====== == += ======= = ==== === += ======== ===== === +======================= + + +oooo d8b .ooooo. ooo. .oo. .oo. .oooo. ooo. .oo. +`888""8P d88' `88b `888P"Y88bP"Y88b `P )88b `888P"Y88b + 888 888 888 888 888 888 .oP"888 888 888 + 888 888 888 888 888 888 d8( 888 888 888 +d888b `Y8bod8P' o888o o888o o888o `Y888""8o o888o o888o + + + +ebg13 + _ _ + | | | | + ____ ___ _ _ ____ __| |_____ __| | + / ___) _ \| | | | _ \ / _ | ___ |/ _ | +| | | |_| | |_| | | | ( (_| | ____( (_| | +|_| \___/|____/|_| |_|\____|_____)\____| + + dMMMMb .aMMMb dMP dMP dMP .aMMMb dMMMMb .aMMMb .aMMMb dMMMMb + dMP.dMP dMP"dMP dMP dMP dMP dMP"dMP dMP dMP dMP"VMP dMP"dMP dMP.dMP + dMMMMK" dMP dMP dMP dMP dMP dMMMMMP dMP dMP dMP dMMMMMP dMMMMP" + dMP"AMF dMP.aMP dMP.dMP.dMP dMP dMP dMP dMP dMP.aMP dMP dMP dMP +dMP dMP VMMMP" VMMMPVMMP" dMP dMP dMP dMP VMMMP" dMP dMP dMP + + +888,8, e88 88e 8P d8P 8P d8P e88 88e +888 " d888 888b P d8P P d8P d888 888b +888 Y888 888P d8P d d8P d Y888 888P +888 "88 88" d8P d8 d8P d8 "88 88" + + + + + +|\ |\ | |~\ | +|/ | | `| |_| | +|\ | | |` ||| |\ + @@@@@@ @@@@@@@ @@@ @@@@@@ @@@@@@ @@@@@@@ + !@@ @@! @@@ @@! @@! @@@ @@! @@@ @@! @@@ + !@@!! @!@!@!@ @!! @!@ !@! @!@ !@! @!@ !@! + !:! !!: !!! !!: !!: !!! !!: !!! !!: !!! + ::.: : :: : :: : ::.: : : :. : : :. : :: : : + + + o + , __ ,_ _ _|_ +/ \_/ / | | |/ \_| + \/ \___/ |_/|_/|__/ |_/ + /| + \| + ___ ___ ___ __ ___ __ __ ___ +/ __)( _)( ,) ( )( _) / _) ( ) ( ,\ +\__ \ ) _) ) \ )( ) _)( (_ /__\ ) _/ +(___/(___)(_)\_)(__)(_) \__)(_)(_)(_) + | | + __| __ \ _` | _` | _ \\ \ \ / +\__ \ | | | ( | ( | ( |\ \ \ / +____/_| |_|\__,_|\__,_|\___/ \_/\_/ + + _|_ |- +_\||()|`|_ + + __ __ + _____/ /___ _____ / /_ + / ___/ / __ `/ __ \/ __/ + (__ ) / /_/ / / / / /_ +/____/_/\__,_/_/ /_/\__/ + + #| #| H| + #HH|#| H| #H| +##H| #| #| #HH|##HH| + H|#| #|## H|## +##H| #H|#H|#HH| #HH| + + _ + // _/_ + _ // _ _. __ o _ / +/_)_ 75.101.163.44 + => 75.101.145.87 + => 174.129.212.2 + + # Subdomains + .mydomain.com. (CNAME) + => proxy.heroku.com + +## Wildcard domains + + heroku addons:add wildcard_domains + + *.yourdomain.com => heroku.com diff --git a/html-css.md b/html-css.md new file mode 100644 index 000000000..eef7f9e6b --- /dev/null +++ b/html-css.md @@ -0,0 +1,27 @@ +### CSS - Selectors + + .class { + } + +### CSS - Font styling + + font-family: Arial; + font-size: 12pt; + line-height: 150%; + color: #aa3322; + +### CSS - Font styling + + // Bold + font-weight: bold; + font-weight: normal; + + // Italic + font-style: italic; + font-style: normal; + + // Underline + text-decoration: underline; + text-decoration: none; + + diff --git a/html.md b/html.md new file mode 100644 index 000000000..300df70e2 --- /dev/null +++ b/html.md @@ -0,0 +1,18 @@ +title: HTML +--- + +### H5BP HTML tag + + + + + + + +### iPhone viewport + + + +### Google jQuery + + diff --git a/index.haml b/index.haml new file mode 100644 index 000000000..36a3259a3 --- /dev/null +++ b/index.haml @@ -0,0 +1,10 @@ +title: Cheat sheets +--- +%ul.pages + - Dir['./*.*'].each do |p| + - name = File.basename(p, '.*') + - ext = File.extname(p) + - next if %w[.sass .scss].include?(ext) || %w[config Gemfile index].include?(name) || name[0] == '_' + - url = name + ".html" + %li + %a{href: url}= name diff --git a/ios.md b/ios.md new file mode 100644 index 000000000..f3d133978 --- /dev/null +++ b/ios.md @@ -0,0 +1,11 @@ +Path to Installous downloads: + + /private/var/mobile/Documents/Installous/Downloads + +Multiple Exchange accounts: + + scp root@iphone.local:/private/var/mobile/Library/Preferences/com.apple.accountsettings.plist . + +Ringtone conversion using ffmpeg: + + ffmpeg -i foo.mp3 -ac 1 -ab 128000 -f mp4 -acodec libfaac -y target.m4r diff --git a/jquery.md b/jquery.md new file mode 100644 index 000000000..4192b53d1 --- /dev/null +++ b/jquery.md @@ -0,0 +1,51 @@ +title: jQuery +--- + +### Extending selectors + + // $(":inline") + $.expr[':'].inline = function(a) { + return $(a).css('display') === 'inline'; + }; + +### Extend CSS properties + + $.cssHooks.someCSSProp = { + get: function(elem, computed, extra) { + }, + set: function(elem, value) { + } + }; + + // Disable "px" + $.cssNumber["someCSSProp"] = true; + +### fn.animate() hooks + + $.fn.step.someWhatever = function(fx) { + // ... + } + +### Mobile events + +For support for `tap`, `swipe`, `swipeLeft`, et al, use +[jquery.mobile.event.js][m]. Be sure to set `$.support.touch` first. + +To get `$.support.touch` (and family), use this from +[jquery.mobile.support.js][s]: + + $.extend($.support, { + orientation: "orientation" in window && "onorientationchange" in window, + touch: "ontouchend" in document, + cssTransitions: "WebKitTransitionEvent" in window, + pushState: "pushState" in history && "replaceState" in history, + mediaquery: $.mobile.media( "only all" ), + cssPseudoElement: !!propExists( "content" ), + touchOverflow: !!propExists( "overflowScrolling" ), + boxShadow: !!propExists( "boxShadow" ) && !bb, + scrollTop: ( "pageXOffset" in window || "scrollTop" in document.documentElement || "scrollTop" in fakeBody[ 0 ] ) && !webos && !operamini, + dynamicBaseTag: baseTagTest() + }); + +[m]:https://github.com/jquery/jquery-mobile/blob/master/js/jquery.mobile.event.js +[s]:https://github.com/jquery/jquery-mobile/blob/master/js/jquery.mobile.support.js diff --git a/linux.md b/linux.md new file mode 100644 index 000000000..635f560dc --- /dev/null +++ b/linux.md @@ -0,0 +1,4 @@ +### Mounting a RAM drive + + $ mount -t tmpfs -o size=5G,nr_inodes=5k,mode=700 tmpfs /tmp + diff --git a/makefile.md b/makefile.md new file mode 100644 index 000000000..0343060f3 --- /dev/null +++ b/makefile.md @@ -0,0 +1,26 @@ +### Safe assignment + + prefix ?= /usr/local + +### Cool stuff + + gitdir ?= $(shell git --exec-path) + gitver ?= $(word 3,$(shell git --version)) + +### Substitutions + + $(SOURCE:.cpp=.o) + $(patsubst %.cpp, %.c, $(SOURCES)) + +### Building files + + %.o: %.c + ffmpeg -i $< > $@ # Input and output + foo $^ + +### Default task + + default: + @echo "hello." + @false + diff --git a/markdown.md b/markdown.md new file mode 100644 index 000000000..3771868f3 --- /dev/null +++ b/markdown.md @@ -0,0 +1,14 @@ +title: Markdown +---- + +## Markdown + + # h1 + ### h3 + + [link](http://google.com) + + [link][google] + [google]: http://google.com + + ![Image alt text](/path/to/img.jpg) diff --git a/osx.md b/osx.md new file mode 100644 index 000000000..03a27e004 --- /dev/null +++ b/osx.md @@ -0,0 +1,23 @@ +Locations of startup items +-------------------------- + + /System/Library/LaunchAgents/ + /System/Library/LaunchDaemons/ + /Library/LaunchAgents/ + /Library/LaunchDaemons/ + +Hide desktop icons +------------------ + + defaults write com.apple.finder CreateDesktop -bool false + killall Finder + +Auto-hide other windows on dock switch +-------------------------------------- + + defaults write com.apple.dock single-app -bool TRUE + killall Dock + + defaults delete com.apple.dock single-app + killall Dock + diff --git a/passenger.md b/passenger.md new file mode 100644 index 000000000..c31aede46 --- /dev/null +++ b/passenger.md @@ -0,0 +1,11 @@ +title: Phusion Passenger +--- + + server { + listen 80; + server_name www.yourhost.com; + root /somewhere/public; # <--- be sure to point to 'public'! + passenger_enabled on; + autoindex on; # Show directory listings + } + diff --git a/rails-models.md b/rails-models.md new file mode 100644 index 000000000..964ad7fad --- /dev/null +++ b/rails-models.md @@ -0,0 +1,293 @@ +title: Rails Models +---- + +### Generating models + + $ rails g model User + +### Associations + + belongs_to + has_one + has_many + has_many :through + has_one :through + has_and_belongs_to_many + + belongs_to :author, + class_name: 'User', + dependent: :destroy // delete this + +### Has many + + belongs_to :parent, :foreign_key => 'parent_id' class_name: 'Folder' + has_many :folders, :foreign_key => 'parent_id', class_name: 'Folder' + + has_many :comments, :order => "posted_on" + has_many :comments, :include => :author + has_many :people, :class_name => "Person" + has_many :people, :conditions => "deleted = 0" + has_many :tracks, :order => "position" + has_many :comments, :dependent => :nullify + has_many :comments, :dependent => :destroy + has_many :tags, :as => :taggable + has_many :reports, :readonly => true + has_many :subscribers, :through => :subscriptions, class_name: "User", :source => :user + has_many :subscribers, :finder_sql => + 'SELECT DISTINCT people.* ' + + 'FROM people p, post_subscriptions ps ' + + 'WHERE ps.post_id = #{id} AND ps.person_id = p.id ' + + 'ORDER BY p.first_name' + +### Many-to-many + +If you have a join model: + + class Programmer < ActiveRecord::Base + has_many :assignments + has_many :projects, :through => :assignments + end + + class Project < ActiveRecord::Base + has_many :assignments + has_many :programmers, :through => :assignments + end + + class Assignment + belongs_to :project + belongs_to :programmer + end + +Or HABTM: + + has_and_belongs_to_many :projects + has_and_belongs_to_many :projects, :include => [ :milestones, :manager ] + has_and_belongs_to_many :nations, :class_name => "Country" + has_and_belongs_to_many :categories, :join_table => "prods_cats" + has_and_belongs_to_many :categories, :readonly => true + has_and_belongs_to_many :active_projects, :join_table => 'developers_projects', :delete_sql => + "DELETE FROM developers_projects WHERE active=1 AND developer_id = #{id} AND project_id = #{record.id}" + +### Polymorphic associations + + class Post + has_many :attachments, :as => :parent + end + + class Image + belongs_to :parent, :polymorphic => true + end + +And in migrations: + + create_table :images do + t.references :post, :polymorphic => true + end + +Migrations +---------- + +### Run migrations + + $ rake db:migrate + +### Migrations + + create_table :users do |t| + t.string :name + t.text :description + + t.primary_key :id + t.string + t.text + t.integer + t.float + t.decimal + t.datetime + t.timestamp + t.time + t.date + t.binary + t.boolean + end + + options: + :null (boolean) + :limit (integer) + :default + :precision (integer) + :scale (integer) + +### Tasks + + create_table + change_table + drop_table + add_column + change_column + rename_column + remove_column + add_index + remove_index + +### Associations + + t.references :category # kinda same as t.integer :category_id + + # Can have different types + t.references :category, polymorphic: true + +### Add/remove columns + + $ rails generate migration RemovePartNumberFromProducts part_number:string + + class RemovePartNumberFromProducts < ActiveRecord::Migration + def up + remove_column :products, :part_number + end + + def down + add_column :products, :part_number, :string + end + end + +Validation +---------- + + class Person < ActiveRecord::Base + + # Checkboxes +   validates :terms_of_service, :acceptance => true + + # Validate associated records +   has_many :books +   validates_associated :books + + # Confirmation (like passwords) + validates :email, :confirmation => true + + # Format + validates :legacy_code, :format => { + :with => /\A[a-zA-Z]+\z/, + :message => "Only letters allowed" + } + + # Length + validates :name, :length => { :minimum => 2 } + validates :bio, :length => { :maximum => 500 } + validates :password, :length => { :in => 6..20 } + validates :number, :length => { :is => 6 } + + # Length (full enchalada) + validates :content, :length => { + :minimum => 300, + :maximum => 400, + :tokenizer => lambda { |str| str.scan(/\w+/) }, + :too_short => "must have at least %{count} words", + :too_long => "must have at most %{count} words" + } + end + + # Numeric + validates :points, :numericality => true + validates :games_played, :numericality => { :only_integer => true } + + # Non empty +   validates :name, :presence => true + + # Multiple + validate :login, :email, :presence => true + end + +### Custom validations + + class Person < ActiveRecord::Base + validate :foo_cant_be_nil + + def foo_cant_be_nil + errors.add(:foo, 'cant be nil') if foo.nil? + end + end + +API +--- + + items = Model.find_by_email(email) + items = Model.where(first_name: "Harvey") + + item = Model.find(id) + + item.serialize_hash + item.new_record? + + item.create # Same an #new then #save + item.create! # Same as above, but raises an Exception + + item.save + item.save! # Same as above, but raises an Exception + + item.update + item.update_attributes + item.update_attributes! + + item.valid? + item.invalid? + + +http://guides.rubyonrails.org/active_record_validations_callbacks.html + +### Mass updates + + # Updates person id 15 + Person.update 15, name: "John", age: 24 + Person.update [1,2], [{name: "John"}, {name: "foo"}] + +### Joining + + Student.joins(:schools).where(:schools => { :type => 'public' }) + Student.joins(:schools).where('schools.type' => 'public' ) + +### Serialize + + class User < ActiveRecord::Base + serialize :preferences + end + + user = User.create(:preferences => { "background" => "black", "display" => large }) + +You can also specify a class option as the second parameter that’ll raise an +exception if a serialized object is retrieved as a descendant of a class not in +the hierarchy. + + class User < ActiveRecord::Base + serialize :preferences, Hash + end + + user = User.create(:preferences => %w( one two three )) + User.find(user.id).preferences # raises SerializationTypeMismatch + +Overriding accessors +-------------------- + + class Song < ActiveRecord::Base + # Uses an integer of seconds to hold the length of the song + + def length=(minutes) + write_attribute(:length, minutes.to_i * 60) + end + + def length + read_attribute(:length) / 60 + end + end + + * http://api.rubyonrails.org/classes/ActiveRecord/Base.html + +Callbacks +--------- + + after_create + after_initialize + after_validation + after_save + after_commit diff --git a/rails-plugins.md b/rails-plugins.md new file mode 100644 index 000000000..e62927405 --- /dev/null +++ b/rails-plugins.md @@ -0,0 +1,133 @@ +Generate a plugin +----------------- + +Generate a Rails Engine plugin: + + rails plugin new myplugin --skip-bundle --full + +Initializers +------------ + +* [Rails::Railtie](http://edgeapi.rubyonrails.org/classes/Rails/Railtie.html) +* [EngineYard blog + post](http://www.engineyard.com/blog/2010/extending-rails-3-with-railties/) + +Subclass Railtie and provide an `initializer` method. + + module NewPlugin + class Railtie < Rails::Railtie + initializer "newplugin.initialize" do |app| + + # subscribe to all rails notifications: controllers, AR, etc. + ActiveSupport::Notifications.subscribe do |*args| + event = ActiveSupport::Notifications::Event.new(*args) + puts "Got notification: #{event.inspect}" + end + + end + end + end + +Custom routes +------------- + +* [ActionDispatch::Routing::Mapper](http://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper.html) + +To create custom `routes.rb` keywords: + + # # routes.rb: + # myplugin_for x + # + class ActionDispatch::Routing + class Mapper + def myplugin_for(*x) + end + end + end + +Example with a block: + + # authenticated do + # resources :users + # end + # + def authenticated + constraint = lambda { |request| request... } + + constraints(constraint) { yield } + end + +Custom generators +----------------- + +* [Guide: generators](http://guides.rubyonrails.org/generators.html) +* [ActiveRecord::Generators::Base](http://api.rubyonrails.org/classes/ActiveRecord/Generators/Base.html) + +### Basic + + # rails g initializer + # lib/generators/initializer_generator.rb + class InitializerGenerator < Rails::Generators::Base + def create_initializer_file + create_file "config/initializers/initializer.rb", "# Add initialization content here" + end + end + + * Extend `Rails::Generators::Base`. + * Each public method in the generator is executed when a generator is invoked. + +### Generating a generator + + $ rails generate generator initializer + +### NamedBase + +Use `NamedBase` instead if you want to take an argument. It will be available as +`file_name`. + + class InitializerGenerator < Rails::Generators::Base + def lol + puts file_name + end + end + +### More + + class InitializerGenerator < Rails::Generators::NamedBase + # +   source_root File.expand_path("../templates", __FILE__) + desc "Description goes here." + end + +### Generators lookup + +When invoking `rails g XXX`: + + * [rails/]generators/XXX/XXX_generator.rb + * [rails/]generators/XXX_generator.rb + +When invoking `rails g XXX:YYY`: + + * [rails/]generators/XXX/YYY_generator.rb + +ActiveModel 'acts as' +--------------------- + + # yaffle/lib/yaffle/acts_as_yaffle.rb + module Yaffle + module ActsAsYaffle + extend ActiveSupport::Concern + + included do + end + + module ClassMethods + def acts_as_yaffle(options = {}) + # your code will go here + end + end + end + end + + ActiveRecord::Base.send :include, Yaffle::ActsAsYaffle + diff --git a/rails-routes.md b/rails-routes.md new file mode 100644 index 000000000..6b5d52603 --- /dev/null +++ b/rails-routes.md @@ -0,0 +1,172 @@ +mapping +------------- + +[Guides/Routing](http://guides.rubyonrails.org/routing.html) + +[ActionDispatch::Routing::Mapper](Rhttp://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper.html) +(See included modules) + +### Multiple resources + + resources :books + # PhotosController: + # index => GET /photos + # new => GET /photos/new + # create => POST /photos/new + # show => GET /photos/:id + # edit => GET /photos/:id/edit + # update => PUT /photos/:id + # delete => DELETE /photos/:id + # + # Helpers: + # new_book_path + # book_path(id) + # edit_book_path(id) + # + + resources :photos do + member { get 'preview' } # /photo/1/preview + get 'preview', on: :member # (..same as the first) + collection { get 'search' } # /photos/search + end + +### Single resource + + resource :coder + + # CodersController: + # new => GET /coder/new + # create => POST /coder/new + # show => GET /coder + # edit => GET /coder/edit + # update => PUT /coder + # delete => DELETE /coder + +### Matching + + match 'photo/:id' => 'photos#show' # /photo/what-is-it + match 'photo/:id', id: /[0-9]+/ # /photo/0192 + match 'photo/:id' => 'photos#show', constraints: { id: /[0-9]+/ } + match 'photo/:id', via: :get + match 'photo/:id', via: [:get, :post] + + match 'photo/*path' => 'photos#unknown' # /photo/what/ever + + # params[:format] == 'jpg' + match 'photos/:id' => 'photos#show', :defaults => { :format => 'jpg' } + +### Redirection + + match '/stories' => redirect('/posts') + match '/stories/:name' => redirect('/posts/%{name}') + +### Named + + # logout_path + match 'exit' => 'sessions#destroy', as: :logout + +### Constraints + + match '/', constraints: { subdomain: 'admin' } + + # admin.site.com/admin/photos + namespace 'admin' do + constraints subdomain: 'admin' do + resources :photos + end + end + +### Custom constraints + + class BlacklistConstraint + def initialize + @ips = Blacklist.retrieve_ips + end + + def matches?(request) + @ips.include?(request.remote_ip) + end + end + + TwitterClone::Application.routes.draw do + match "*path" => "blacklist#index", + :constraints => BlacklistConstraint.new + end + +### Scopes + + scope 'admin', constraints: { subdomain: 'admin' } do + resources ... + end + +### Rack middleware + + # Yes, Sprockets is middleware + match '/application.js' => Sprockets + +### Route helpers + + projects_path # /projects + projects_url # http://site.com/projects + + +### Default help text + + # The priority is based upon order of creation: + # first created -> highest priority. + + # Sample of regular route: + match 'products/:id' => 'catalog#view' + + # Keep in mind you can assign values other than :controller and :action + + # Sample of named route: + match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase + + # This route can be invoked with purchase_url(:id => product.id) + + # Sample resource route (maps HTTP verbs to controller actions automatically): + resources :products + + # Sample resource route with options: + resources :products do + member do + get 'short' + post 'toggle' + end + + collection do + get 'sold' + end + end + + # Sample resource route with sub-resources: + resources :products do + resources :comments, :sales + resource :seller + end + + # Sample resource route with more complex sub-resources + resources :products do + resources :comments + resources :sales do + get 'recent', :on => :collection + end + end + + # Sample resource route within a namespace: + namespace :admin do + # Directs /admin/products/* to Admin::ProductsController + # (app/controllers/admin/products_controller.rb) + resources :products + end + + # You can have the root of your site routed with "root" + # just remember to delete public/index.html. + root :to => 'welcome#index' + + # See how all your routes lay out with "rake routes" + + # This is a legacy wild controller route that's not recommended for RESTful applications. + # Note: This route will make all actions in every controller accessible via GET requests. + match ':controller(/:action(/:id(.:format)))' diff --git a/rails.md b/rails.md new file mode 100644 index 000000000..bf584d00d --- /dev/null +++ b/rails.md @@ -0,0 +1,129 @@ +Helpers +------- + + class ApplicationController + helper_method :logged_in? + + def logged_in? + "Something" + end + end + +### CSS/JS packages + + stylesheet_link_tag :monkey + javascript_link_tag :monkey + +### Forms + + # http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html + + - form_for @person do |f| + = f.label :first_name + = f.label :first_name, "First name" + = f.text_field :first_name + + = f.label :last_name> + = f.text_field :last_name> + + - fields_for @person.permission do |fields| + = fields.checkbox :admin + + -# name="person[admin]" + - fields_for :person, @client do |fields| + = fields.checkbox :admin + + = f.submit + + # Also: check_box, email_field, fields_for + # file_field, hidden_field, label, number_field, password_field + # radio_button, range_field, search_field, telephonen_field, + # text_area, text_field, url_field + +Controllers +----------- + +http://apidock.com/rails/ActionController/Base + + class ProjectsController + layout 'project' # Actually defaults to `projects` based + # on the controller name + + def save + end + + def edit + end + end + +### Before filter + + class ApplicationController < ActionController::Base + before_filter :validate, only: [:save, :edit] + before_filter :ensure_auth, except: [:logout] + + before_filter :require_login + + private + + def require_login + unless logged_in? + flash[:error] = "You must be logged in to access this section" + redirect_to new_login_url # halts request cycle + end + end + end + +### Default URL optinos + + class ApplicationController < ActionController::Base + # The options parameter is the hash passed in to 'url_for' + def default_url_options(options) + {:locale => I18n.locale} + end + end + +### Hashes + + session[:what] + flash[:notice] = "Your session expired" + params[:id] + +### XML and JSON + + class UsersController < ApplicationController + def index + @users = User.all + respond_to do |format| + format.html # index.html.erb + format.xml { render :xml => @users} + format.json { render :json => @users} + end + end + end + +### Redirection + + redirect_to action: 'show', id: @entry.id + redirect_to root_url # a path + +### Render + + render nothing: true + render template: 'products/show' + render action: 'something' # same as `file: 'my/something'` + # Renders the template only, does not execute + # the action + +Layouts +------- + + # app/views/layouts/application.html.erb + <%= content_for?(:content) ? yield :content : yield %> + + # app/views/layouts/news.html.erb + <% content_for :content do %> + ... + <% end %> + <% render template: :'layouts/application' %> + diff --git a/rdoc.md b/rdoc.md new file mode 100644 index 000000000..9e7e5b705 --- /dev/null +++ b/rdoc.md @@ -0,0 +1,28 @@ +title: Rdoc +---- + +### Basic RDoc format + + # Foo. + # + # @example + # + # y + # g + # + # @param [String] param_name The xx and xx. + # + # @see http://url.com + # + # @return [true] if so + # + # == Definition lists + # + # list:: hi. + # +foo+:: parameterized + # + # == Definition lists + # [foo] also + # [bar] like this + +http://rdoc.rubyforge.org/RDoc/Markup.html diff --git a/rst.md b/rst.md new file mode 100644 index 000000000..c1162d420 --- /dev/null +++ b/rst.md @@ -0,0 +1,51 @@ +title: ReStructuredText +--- + +### Comments + + .. @theme 2010 + .. include:: ../themes/2010/common.rst + .. contents:: + .. |substitute| replace:: replacement name + +### Headings + + Heading + ======= + + .. class:: brief + + Hello there. |substitute| **This is bold** + + + - Bullet list with a link_ (or `link with words`_) + - Yes + + .. _link: http://link.org + +### PDF page break + + .. raw:: pdf + + PageBreak oneColumn + +### Link targets + + Internal link target_. + + .. _target: + + This is where _target will end up in. + +### Tables (?) + + .. class:: hash-table + + .. list-table:: + + * - :key:`Weekly work hours:` + - :val:`50 hours` + * - :key:`Cost per hour:` + - :val:`PhP 1,500/hour` + * - :key:`Weekly rate:` + - :val:`PhP 75,000/week` diff --git a/sequel.rdoc b/sequel.rdoc new file mode 100644 index 000000000..b6faea7ac --- /dev/null +++ b/sequel.rdoc @@ -0,0 +1,386 @@ +title: Sequel +---- + += Cheat Sheet + +== Open a database + + require 'rubygems' + require 'sequel' + + DB = Sequel.sqlite('my_blog.db') + DB = Sequel.connect('postgres://user:password@localhost/my_db') + DB = Sequel.postgres('my_db', :user => 'user', :password => 'password', :host => 'localhost') + DB = Sequel.ado('mydb') + +== Open an SQLite memory database + +Without a filename argument, the sqlite adapter will setup a new sqlite database in memory. + + DB = Sequel.sqlite + +== Logging SQL statements + + require 'logger' + DB = Sequel.sqlite '', :loggers => [Logger.new($stdout)] + # or + DB.loggers << Logger.new(...) + +== Using raw SQL + + DB.run "CREATE TABLE users (name VARCHAR(255) NOT NULL, age INT(3) NOT NULL)" + dataset = DB["SELECT age FROM users WHERE name = ?", name] + dataset.map(:age) + DB.fetch("SELECT name FROM users") do |row| + p row[:name] + end + +== Create a dataset + + dataset = DB[:items] + dataset = DB.from(:items) + +== Most dataset methods are chainable + + dataset = DB[:managers].where(:salary => 5000..10000).order(:name, :department) + +== Insert rows + + dataset.insert(:name => 'Sharon', :grade => 50) + +== Retrieve rows + + dataset.each{|r| p r} + dataset.all # => [{...}, {...}, ...] + dataset.first # => {...} + +== Update/Delete rows + + dataset.filter(~:active).delete + dataset.filter('price < ?', 100).update(:active => true) + +== Datasets are Enumerable + + dataset.map{|r| r[:name]} + dataset.map(:name) # same as above + + dataset.inject(0){|sum, r| sum + r[:value]} + dataset.sum(:value) # same as above + +== Filtering (see also doc/dataset_filtering.rdoc) + +=== Equality + + dataset.filter(:name => 'abc') + dataset.filter('name = ?', 'abc') + +=== Inequality + + dataset.filter{value > 100} + dataset.exclude{value <= 100} + +=== Inclusion + + dataset.filter(:value => 50..100) + dataset.where{(value >= 50) & (value <= 100)} + + dataset.where('value IN ?', [50,75,100]) + dataset.where(:value=>[50,75,100]) + + dataset.where(:id=>other_dataset.select(:other_id)) + +=== Subselects as scalar values + + dataset.where('price > (SELECT avg(price) + 100 FROM table)') + dataset.filter{price > dataset.select(avg(price) + 100)} + +=== LIKE/Regexp + + DB[:items].filter(:name.like('AL%')) + DB[:items].filter(:name => /^AL/) + +=== AND/OR/NOT + + DB[:items].filter{(x > 5) & (y > 10)}.sql + # SELECT * FROM items WHERE ((x > 5) AND (y > 10)) + + DB[:items].filter({:x => 1, :y => 2}.sql_or & ~{:z => 3}).sql + # SELECT * FROM items WHERE (((x = 1) OR (y = 2)) AND (z != 3)) + +=== Mathematical operators + + DB[:items].filter((:x + :y) > :z).sql + # SELECT * FROM items WHERE ((x + y) > z) + + DB[:items].filter{price - 100 < avg(price)}.sql + # SELECT * FROM items WHERE ((price - 100) < avg(price)) + +== Ordering + + dataset.order(:kind) + dataset.reverse_order(:kind) + dataset.order(:kind.desc, :name) + +== Limit/Offset + + dataset.limit(30) # LIMIT 30 + dataset.limit(30, 10) # LIMIT 30 OFFSET 10 + +== Joins + + DB[:items].left_outer_join(:categories, :id => :category_id).sql + # SELECT * FROM items LEFT OUTER JOIN categories ON categories.id = items.category_id + + DB[:items].join(:categories, :id => :category_id).join(:groups, :id => :items__group_id) + # SELECT * FROM items INNER JOIN categories ON categories.id = items.category_id INNER JOIN groups ON groups.id = items.group_id + +== Aggregate functions methods + + dataset.count #=> record count + dataset.max(:price) + dataset.min(:price) + dataset.avg(:price) + dataset.sum(:stock) + + dataset.group_and_count(:category) + dataset.group(:category).select(:category, :AVG.sql_function(:price)) + +== SQL Functions / Literals + + dataset.update(:updated_at => :NOW.sql_function) + dataset.update(:updated_at => 'NOW()'.lit) + + dataset.update(:updated_at => "DateValue('1/1/2001')".lit) + dataset.update(:updated_at => :DateValue.sql_function('1/1/2001')) + +== Schema Manipulation + + DB.create_table :items do + primary_key :id + String :name, :unique => true, :null => false + TrueClass :active, :default => true + foreign_key :category_id, :categories + DateTime :created_at + + index :created_at + end + + DB.drop_table :items + + DB.create_table :test do + String :zipcode + enum :system, :elements => ['mac', 'linux', 'windows'] + end + +== Aliasing + + DB[:items].select(:name.as(:item_name)) + DB[:items].select(:name___item_name) + DB[:items___items_table].select(:items_table__name___item_name) + # SELECT items_table.name AS item_name FROM items AS items_table + +== Transactions + + DB.transaction do + dataset.insert(:first_name => 'Inigo', :last_name => 'Montoya') + dataset.insert(:first_name => 'Farm', :last_name => 'Boy') + end # Either both are inserted or neither are inserted + +Database#transaction is re-entrant: + + DB.transaction do # BEGIN issued only here + DB.transaction + dataset << {:first_name => 'Inigo', :last_name => 'Montoya'} + end + end # COMMIT issued only here + +Transactions are aborted if an error is raised: + + DB.transaction do + raise "some error occurred" + end # ROLLBACK issued and the error is re-raised + +Transactions can also be aborted by raising Sequel::Rollback: + + DB.transaction do + raise(Sequel::Rollback) if something_bad_happened + end # ROLLBACK issued and no error raised + +Savepoints can be used if the database supports it: + + DB.transaction do + dataset << {:first_name => 'Farm', :last_name => 'Boy'} # Inserted + DB.transaction(:savepoint=>true) # This savepoint is rolled back + dataset << {:first_name => 'Inigo', :last_name => 'Montoya'} # Not inserted + raise(Sequel::Rollback) if something_bad_happened + end + dataset << {:first_name => 'Prince', :last_name => 'Humperdink'} # Inserted + end + +== Miscellaneous: + + dataset.sql # "SELECT * FROM items" + dataset.delete_sql # "DELETE FROM items" + dataset.where(:name => 'sequel').exists # "EXISTS ( SELECT * FROM items WHERE name = 'sequel' )" + dataset.columns #=> array of columns in the result set, does a SELECT + DB.schema(:items) => [[:id, {:type=>:integer, ...}], [:name, {:type=>:string, ...}], ...] + +---------------------------------------------------------------------------------------------------------------------------------------------------------------- + +== Documents + + http://sequel.rubyforge.org/rdoc/files/doc/association_basics_rdoc.html + http://sequel.rubyforge.org/rdoc/classes/Sequel/Schema/Generator.html + http://sequel.rubyforge.org/rdoc/files/doc/validations_rdoc.html + http://sequel.rubyforge.org/rdoc/classes/Sequel/Model.html + +== Alter table + + database.alter_table :deals do + add_column :name, String + drop_column :column_name + rename_column :from, :to + + add_constraint :valid_name, :name.like('A%') + drop_constraint :constraint + + add_full_text_index :body + add_spacial_index [columns] + + add_index :price + drop_index :index + + add_foreign_key :artist_id, :table + add_primary_key :id + add_unique_constraint [columns] + set_column_allow_null :foo, false + set_column_default :title, '' + + set_column_type :price, 'char(10)' + end + +== Model associations + + class Deal < Sequel::Model + + # Us (left) <=> Them (right) + many_to_many :images, + left_id: :deal_id, + right_id: :image_id, + join_table: :image_links + + one_to_many :files, + key: :deal_id, + class: :DataFile, + + many_to_one :parent, class: self + one_to_many :children, key: :parent_id, class: self + + one_to_many :gold_albums, class: :Album do |ds| + ds.filter { copies_sold > 50000 } + end + +Provided by many_to_many + + Deal[1].images + Deal[1].add_image + Deal[1].remove_image + Deal[1].remove_all_images + +== Validations + + def validate + super + errors.add(:name, 'cannot be empty') if !name || name.empty? + + validates_presence [:title, :site] + validates_unique :name + validates_format /\Ahttps?:\/\//, :website, :message=>'is not a valid URL' + validates_includes %w(a b c), :type + validates_integer :rating + validates_numeric :number + validates_type String, [:title, :description] + + validates_integer :rating if new? + + # options: :message =>, :allow_nil =>, :allow_blank =>, + # :allow_missing =>, + + validates_exact_length 17, :isbn + validates_min_length 3, :name + validates_max_length 100, :name + validates_length_range 3..100, :name + + # Setter override + def filename=(name) + @values[:filename] = name + end + end + end + + deal.errors + +== Model stuff + + deal = Deal[1] + deal.changed_columns + deal.destory # Calls hooks + deal.delete # No hooks + deal.exists? + deal.new? + deal.hash # Only uniques + deal.keys #=> [:id, :name] + deal.modified! + deal.modified? + + deal.lock! + +== Callbacks + + before_create + after_create + + before_validation + after_validation + before_save + before_update + UPDATE QUERY + after_update + after_save + + before_destroy + DELETE QUERY + after_destroy + +== Schema + + class Deal < Sequel::Model + set_schema do + primary_key :id + primary_key [:id, :title] + String :name, primary_key: true + + String :title + Numeric :price + DateTime :expires + + unique :whatever + check(:price) { num > 0 } + + foreign_key :artist_id + String :artist_name, key: :id + + index :title + index [:artist_id, :name] + full_text_index :title + + # String, Integer, Fixnum, Bignum, Float, Numeric, BigDecimal, + # Date, DateTime, Time, File, TrueClass, FalseClass + end + end + +== Unrestrict primary key + + Category.create id: 'travel' # error + Category.unrestrict_primary_key + Category.create id: 'travel' # ok diff --git a/style.sass b/style.sass new file mode 100644 index 000000000..d43690137 --- /dev/null +++ b/style.sass @@ -0,0 +1,93 @@ +@import 'compass/css3' + +body + font-family: 'pt sans', sans-serif + font-size: 14px + line-height: 1.5 + +html + background: #505060 + +body + width: 800px + margin: 20px auto + padding: 20px + +border-radius(2px) + +box-shadow(0 2px 3px rgba(black, 0.2)) + background: #fafafa + color: #333 + +p, ul, ol, pre + margin: 15px 0 + +h1, h2, h3, h4, h5, h6 + margin: 40px 0 15px 0 + +h1 + font-family: georgia, serif + text-align: center + font-size: 24pt + color: #aaa + font-style: italic + font-weight: normal + margin: 10px 0 + padding: 10px 0 + border-bottom: dotted 1px #ddd + border-top: dotted 1px #ddd + +h2, h3 + color: #88a + font-size: 1.5em + border-bottom: solid 1px #ddd + padding-bottom: 3px + +h3 + font-size: 1.3em + +pre, code + font-family: monaco, monospace + font-size: 12px + color: #444 + +pre + line-height: 1.6 + background: #f7f7f2 + padding: 10px 35px + +box-shadow(inset 0 0 5px rgba(black, 0.1)) + overflow-x: auto + + margin-left: -20px + margin-right: -20px + +h2+pre, h3+pre + border-top: solid 2px #c0c0dd + margin-top: -16px + +ul.pages + &, li + margin: 0 + padding: 0 + list-style-type: none + + & + overflow: hidden + margin: 40px 0 + + li + width: 20% + float: left + + a + display: block + text-decoration: none + padding: 2px 5px + +border-radius(3px) + + a:hover + background: #eee + + li:first-letter + text-transform: uppercase + + +@import '_prettify' diff --git a/textile.md b/textile.md new file mode 100644 index 000000000..51447b91b --- /dev/null +++ b/textile.md @@ -0,0 +1,61 @@ +title: Textile +--- + +### Pre blocks + +
+    I am very serious. -- this will get escaped.
+    
+ +### Line breaks + + Line breaks. + Just break the lines. + +### Entities + + one(TM), two(R), three(C). + +### Inlines + + _em_ *strong* __bold-italic__. ??citation??. + @code@. -strikehtrough-. +insertion+. + %span%. %{color:red}formatting%. + "Hypertext":index.html + "Text link":link + + [link]http://link.com + + !image.jpg! + !image.jpg(title text)! + !image.jpg!:link.html + + !>right.jpg! + +### Horizontal line + + -- + +### Blocks + + h1. Header 1 + + h2. Header 2 + + bq. Blockquote + + p(classname). Class. + + p(#id). ID. + +### Lists + + ## ordered list + + * unordered list + +### Footnotes + + Footnotes[1]. + + fn1. Something. diff --git a/tig.md b/tig.md new file mode 100644 index 000000000..074bad5b2 --- /dev/null +++ b/tig.md @@ -0,0 +1,32 @@ +Tig shortcuts +------------- + +Invocation + + tig blame FILE + tig master # Show a branch + tig test..master # Show difference between two bracnhes + tig FILE # Show history of file + tig v0.0.3:README # Show contents of file in a specific revision + +All views +--------- + + * `^N` - Next on parent view + * `^P` - Previous on parent view + +`m` - Main view + * `D` - Toggle between date display modes + * `A` - Toggle between author display modes + * `C` - Cherry pick a commit + +`S` - Stage view + + * `u` - Stage/unstage file or chunk + * `!` - Revert file or chunk + * `C` - Commit + * `M` - Merge + +`H` - Branch view + + * `i` - Change sort header diff --git a/tmux.md b/tmux.md new file mode 100644 index 000000000..9afe85430 --- /dev/null +++ b/tmux.md @@ -0,0 +1,51 @@ +title: tmux Terminal Multiplexer +--- + +### Commands + + $ tmux + -u # UTF8 mode + -S ~/.tmux.socket + + $ tmux attach + +### Help + + C-b ? + +### Scrolling + + C-b [ # Enter scroll mode then press up and down + +### Copy/paste + + C-b [ # 1. Enter scroll mode first. + Space # 2. Start selecting and move around. + Enter # 3. Press enter to copy. + C-b ] # Paste + +### Panes + + C-b v # vert + C-b n # horiz + C-b hkjl # navigation + C-b HJKL # resize + C-b o # next window + C-b x # close pane + + C-b { or } # move windows around + +### Windows + + C-b c # New window + C-b 1 # Go to window 1 + +### Detach/attach + + C-b d # detatch + C-b ( ) # Switch through sessions + $ tmux attach + +### Niceties + + C-b t # Time diff --git a/ubuntu.md b/ubuntu.md new file mode 100644 index 000000000..2adf3d7a2 --- /dev/null +++ b/ubuntu.md @@ -0,0 +1,13 @@ +title: Ubuntu/Debian +---- + +### Aptitude stuff + + aptitude search mysql # Look for something + dpkg -S `which tsclient` # What package does it belong to? + dpkg -L aria2c # What does this package provide? + dpkg -i *.deb # Install a deb file + +### Apt archives path + + /var/cache/apt/archives diff --git a/unicode.txt b/unicode.txt new file mode 100644 index 000000000..57bfcf6db --- /dev/null +++ b/unicode.txt @@ -0,0 +1,19 @@ + ▲▼▶ + + ⬅⬆⬇ + + ◢ ◣ ◤ ◥ + + : «» XOR ‹›, (), [], •, ⌘, ⌥, ▲▼, ▸▹, ◇ XOR ◆, ◐◑◒◓ ◢ ◣ ◤ ◥, ★ ☆ , ♠♥♣♦, ⚐⚑, ✂ + + + ࣾ home ࣾ + ℹ information ℹ + ♡ heart ♡ + ⚙ cog or gear ⚙ + ⚿ key ⚿ + ✉ envelope ✉ + ✎ pencil ✎ + ✓ check or tick mark ✓ + ❌ cross mark ❌ + 💬 speech balloon 💬 diff --git a/vim.md b/vim.md new file mode 100644 index 000000000..bb26bdd4f --- /dev/null +++ b/vim.md @@ -0,0 +1,36 @@ +title: vim +---- + + . - repeat last command + ]p - paste under the current indentation level + + +Motions +------- + + vip - Select paragraph + vipipipip - Select more + + ap - a paragraph + ip - inner paragraph + + {a,i}p - Paragraph + {a,i}w - Word + {a,i}s - Sentence + + ab - A block [( + aB - A block in [{ + at - A XML tag block + a[ ( { < - A [], (), or {} block + a' " ` - A quoted string + + +Example: + + yip - Yank inner paragraph + yap - Yank paragraph (including newline) + +SCSS! +----- + + va{= - reindent block diff --git a/zsh.md b/zsh.md new file mode 100644 index 000000000..a34df6501 --- /dev/null +++ b/zsh.md @@ -0,0 +1,20 @@ +title: ZSH +--- + +### Stuff + + !! Last command (sudo !!) + + !* Last command's parameters (vim !*) + !^ Last command's first parameter + !$ Last command's last parameter + + !?ls Command and params of last `ls` command (sudo !?mv) + !?ls?:* Params of last `ls` command + + *(m0) Last modified today + *(m-4) Last modified <4 days ago + +### Change default shell + + chsh -s `which zsh`