Skip to content

Instantly share code, notes, and snippets.

View zhengjia's full-sized avatar

Zheng Jia zhengjia

  • Sport Ngin
  • Minneapolis
View GitHub Profile
@zhengjia
zhengjia / footnotes
Created July 26, 2010 00:56
footnote
RAILS_ROOT/config/environments/development.rb
config.gem "rails-footnotes"
environment.rb or
in an initializer do:
if defined?(Footnotes)
Footnotes::Filter.prefix = 'txmt://open?url=file://%s&line=%d&column=%d'
ruby -e "$(curl -fsS http://gist.github.com/raw/323731/install_homebrew.rb)"
@zhengjia
zhengjia / .gitignore
Created July 20, 2010 03:01
.gitignore
config/database.yml
config/s3_credentials.yml
tmp/**/*
.DS_Store
doc/api
doc/app
doc/plugins
doc/*.dot
coverage/*
db/*.sqlite3
@zhengjia
zhengjia / webrat cheatsheet
Created June 7, 2010 01:38
webrat cheatsheet
== Simulating browser events
# GET a URL, following any redirects, and making sure final page is successful
visit "/some/url"
# In general, elements can be located by their inner text, their 'title'
attribute, their 'name' attribute, and their 'id' attribute.
# They can be selected using a String, which is converted to an escaped Regexp
effectively making it a substring match, or using a Regexp.
# An exception is that using Strings for ids are compared exactly (using ==)
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=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')
@zhengjia
zhengjia / built-in web_step cheatsheet
Created June 4, 2010 00:00
built-in webrat steps for cucumber cheatsheet
Given I am on "[page_name]"
When I go to "[page_name]"
When I press "[button]"
When I follow "[link]"
When I follow "[link]" within "[parent]"
When I fill in "[field]" with "[value]"
When I fill in "[value]" for "[field]"
When I fill in the following:
| field | value |
@zhengjia
zhengjia / .bashrc
Created June 3, 2010 03:18
.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'.
HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
ROOT_BACKUP_DIR=/media/RD1000/backup
# A list of directories to back up. Put each on its own line
DIR_TO_BACKUP=`cat <<EOF
/home/j/backup-sync
/var/www
EOF`
# The rsync command with options
BACKUP_CMD='rsync -Rvurogptl'
@zhengjia
zhengjia / jquery_contents.js
Created June 2, 2010 20:02
jquery content()
$('.container').contents().filter(function() {
return this.nodeType == 3;
})
.wrap('<p></p>')
.end()
.filter('br')
.remove();
#http://api.jquery.com/contents/
#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: