Skip to content

Instantly share code, notes, and snippets.

@xecutioner
xecutioner / RAILS_CHEATSHEET.md
Created April 11, 2018 04:22 — forked from mdang/RAILS_CHEATSHEET.md
Ruby on Rails Cheatsheet

Ruby on Rails Cheatsheet

Architecture

Create a new application

Install the Rails gem if you haven't done so before

@xecutioner
xecutioner / fast.rb
Created November 18, 2016 10:43 — forked from vayu-technology/fast.rb
Check network over time with fast.com + ruby
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
require 'capybara/rspec'
require 'capybara/poltergeist'
require 'csv'
require 'pry'
include Capybara::DSL
Capybara.register_driver :poltergeist do |app|
@xecutioner
xecutioner / ci_install.sh
Created May 18, 2016 11:30 — forked from ryane/ci_install.sh
A script (or just list of commands) to setup a jenkins server on Ubuntu 12.04 hosted at linode. Liberally borrowed from https://gist.github.com/whistler/3179919#file-jenkins_rails_ubuntu-sh
sudo aptitude -y install build-essential libssl-dev libreadline5 libreadline5-dev zlib1g zlib1g-dev
sudo apt-get -y install libxslt-dev libxml2-dev
sudo apt-get -y install libmysqlclient-dev ruby-dev
sudo apt-get -y install libcurl4-openssl-dev
sudo apt-get -y install imagemagick libmagickcore-dev libmagickwand-dev
sudo apt-get -y install libsqlite3-dev
sudo apt-get -y install libreadline-dev
sudo apt-get -y install git
sudo apt-get -y install libicu48
sudo apt-get -y install nodejs
@xecutioner
xecutioner / grok_vi.mdown
Created February 17, 2016 21:05 — forked from nifl/grok_vi.mdown
Your problem with Vim is that you don't grok vi.

Answer by Jim Dennis on Stack Overflow question http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118

Your problem with Vim is that you don't grok vi.

You mention cutting with yy and complain that you almost never want to cut whole lines. In fact programmers, editing source code, very often want to work on whole lines, ranges of lines and blocks of code. However, yy is only one of many way to yank text into the anonymous copy buffer (or "register" as it's called in vi).

The "Zen" of vi is that you're speaking a language. The initial y is a verb. The statement yy is a simple statement which is, essentially, an abbreviation for 0 y$:

0 go to the beginning of this line. y yank from here (up to where?)

@xecutioner
xecutioner / deploy.rb
Created January 19, 2016 05:13
private_pub capistrano tasks
namespace :private_pub do
desc "Start private_pub server"
task :start do
run "cd #{current_path};RAILS_ENV=production bundle exec rackup private_pub.ru -s thin -E production -D -P tmp/pids/private_pub.pid"
end
desc "Stop private_pub server"
task :stop do
run "cd #{current_path};if [ -f tmp/pids/private_pub.pid ] && [ -e /proc/$(cat tmp/pids/private_pub.pid) ]; then kill -9 `cat tmp/pids/private_pub.pid`; fi"
end
@xecutioner
xecutioner / rspec_model_testing_template.rb
Last active May 29, 2017 07:19 — forked from SabretWoW/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

@xecutioner
xecutioner / README.md
Created October 28, 2012 14:21 — forked from briangonzalez/README.md
img2boxshadow - a ruby script to convert images to CSS [http://codepen.io/briangonzalez/details/AvrGI#pen-details-tab]

img2boxshadow.rb

a ruby script to convert images to CSS (box-shadows)

Installation

gem install rmagick    # you'll need ImageMagick & Ruby first
gem install colormath
gem install micro-optparse