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 / 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 / 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 / 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 / .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
ruby -e "$(curl -fsS http://gist.github.com/raw/323731/install_homebrew.rb)"
@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'
@zhengjia
zhengjia / crossdomain.xml
Created August 23, 2010 21:58
crossdomain.xml
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>
require 'rubygems'
IRB.conf[:AUTO_INDENT] = false
IRB.conf[:USE_READLINE] = true
class Object
# easy way to list an object's methods without clutter
def local_methods
(methods - Object.instance_methods).sort
end
end
def a
puts 'a'
end
ma = method :a
mma=ma.to_proc
mmma = Kernel.send :define_method ,:new_method, &mma
mmma2 = Kernel.send :define_method ,:new_method2, mma
new_method
new_method2
git config --global core.excludesfile ~/.git_global_ignore