Skip to content

Instantly share code, notes, and snippets.


Zheng Jia zhengjia

  • Sport Ngin
  • Minneapolis
View GitHub Profile
View sql_log.rb
if rails_env = ENV['RAILS_ENV']
# Called after the irb session is initialized and Rails has
# been loaded (props: Mike Clark).
IRB.conf[:IRB_RC] = do
ActiveRecord::Base.logger =
ActiveRecord::Base.instance_eval { alias :[] :find }
View gist:395021
# From
# Save this as rcov.rake in lib/tasks and use rcov:all =>
# to get accurate spec/feature coverage data
# Use rcov:rspec or rcov:cucumber
# to get non-aggregated coverage reports for rspec or cucumber separately
require 'cucumber/rake/task'
require 'spec/rake/spectask'
View cucumber.yml
autospec-all: --require features --require lib --format progress features
autospec: --require features --require lib features
default: --format pretty
html: --format html --out features.html
View spec.opts
--format specdoc
--loadby mtime
zhengjia / env.rb
Created May 27, 2010
env.rb for selenium
View env.rb
ENV["RAILS_ENV"] ||= "cucumber"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
require 'cucumber/formatter/unicode'
require 'cucumber/rails/rspec'
require 'cucumber/rails/world'
require 'cucumber/rails/active_record'
require 'cucumber/web/tableish'
require 'webrat'
View rubyclosure.rb
# CLOSURES IN RUBY Paul Cantrell
# Email: username "cantrell", domain name ""
# I recommend executing this file, then reading it alongside its output.
# Alteratively, you can give yourself a sort of Ruby test by deleting all the comments,
# then trying to guess the output of the code!
# A closure is a block of code which meets three criteria:
View array_comparison.rb
#You can just use a set difference (aka minus) to see if one array includes all elements of another
not_included = [1,2,3] - (1..9).to_a
not_included # => []
not_included = [1,2,3,'A'] - (1..9).to_a
not_included # => ["A"]
#Use intersection to test if any of the one are in the other:
View jquery_contents.js
$('.container').contents().filter(function() {
return this.nodeType == 3;
# A list of directories to back up. Put each on its own line
# The rsync command with options
BACKUP_CMD='rsync -Rvurogptl'
View .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
You can’t perform that action at this time.