- Some utilities:
sudo apt-get install vim tmux git- Copy/paste from the command line:
sudo apt-get install xclip| #! /bin/bash | |
| ### BEGIN INIT INFO | |
| # Provides: unicorn | |
| # Required-Start: $local_fs $remote_fs $network $syslog | |
| # Required-Stop: $local_fs $remote_fs $network $syslog | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: 0 1 6 | |
| # Short-Description: starts the unicorn web server | |
| # Description: starts unicorn |
| # as we’re going to use Unicorn as the application server | |
| # we’re not going to use common sockets | |
| # but Unix sockets for faster communication | |
| upstream shop { | |
| # fail_timeout=0 means we always retry an upstream even if it failed | |
| # to return a good HTTP response (in case the Unicorn master nukes a | |
| # single worker for timing out). | |
| # for UNIX domain socket setups: | |
| server unix:/tmp/shop.socket fail_timeout=0; |
| require 'rubygems' | |
| require 'erb' | |
| require 'sinatra' | |
| require 'dropbox' | |
| configure do | |
| enable :sessions | |
| end | |
| def authed? |
| # for more info: https://gist.github.com/1120938 |
| require 'rubygems' | |
| require 'test/unit' | |
| require 'em-http' | |
| require 'vcr' | |
| VCR.config do |c| | |
| c.cassette_library_dir = 'fixtures/vcr_cassettes' | |
| c.http_stubbing_library = :webmock | |
| end |
| # encoding: utf-8 | |
| $:.unshift(File.expand_path('./lib', ENV['rvm_path'])) | |
| require 'rvm/capistrano' | |
| set :application, "hirefireapp" | |
| set :repository, "[email protected]:meskyanichi/myapp.git" | |
| set :branch, "develop" | |
| set :rvm_ruby_string, "1.9.2" |
| =Navigating= | |
| visit('/projects') | |
| visit(post_comments_path(post)) | |
| =Clicking links and buttons= | |
| click_link('id-of-link') | |
| click_link('Link Text') | |
| click_button('Save') | |
| click('Link Text') # Click either a link or a button | |
| click('Button Value') |
| # A small DSL for helping parsing documents using Nokogiri::XML::Reader. The | |
| # XML Reader is a good way to move a cursor through a (large) XML document fast, | |
| # but is not as cumbersome as writing a full SAX document handler. Read about | |
| # it here: http://nokogiri.org/Nokogiri/XML/Reader.html | |
| # | |
| # Just pass the reader in this parser and specificy the nodes that you are interested | |
| # in in a block. You can just parse every node or only look inside certain nodes. | |
| # | |
| # A small example: | |
| # |
| WITH table_scans as ( | |
| SELECT relid, | |
| tables.idx_scan + tables.seq_scan as all_scans, | |
| ( tables.n_tup_ins + tables.n_tup_upd + tables.n_tup_del ) as writes, | |
| pg_relation_size(relid) as table_size | |
| FROM pg_stat_user_tables as tables | |
| ), | |
| all_writes as ( | |
| SELECT sum(writes) as total_writes | |
| FROM table_scans |