Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
sql = 'look "quotes," a \backslash, and #{:interpolation}'
puts instance_eval(%("#{sql.gsub(/[\\"]/,'\\\\\\&')}"))
Feature: test
Scenario: test
When I run the suite
Then the method should be callable
@tpope
tpope / blank_context.rb
Created December 12, 2008 07:27 — forked from nakajima/blank_context.rb
Now free of pesky instance_ methods!
module Kernel
def blank_context(*args, &block)
ivars = args.extract_options!
args.push(/^__/)
klass = Class.new do
instance_methods.each do |m|
undef_method(m) unless args.any? { |pattern| m =~ pattern }
end
hcd() {
cd "$HASHROCKET_DIR/$1"
}
if [ -n "$BASH_VERSION" ]; then
_hcd()
{
local cur projects
[ -r "$HASHROCKET_DIR" ] || return 0
let g:ack = "ack -H"
function! s:ack(cmd,args)
let grepprg_bak = &grepprg
try
let &grepprg = g:ack
silent execute a:cmd . ' ' . a:args
finally
let &grepprg = grepprg_bak
endtry
" hashrocket.vim
" vim:set ft=vim et tw=78 sw=2:
if $HASHROCKET_DIR == '' && expand('<sfile>') =~# '/ops/hashrocket\.vim$'
let $HASHROCKET_DIR = expand('<sfile>')[0 : -20]
endif
if $HASHROCKET_DIR == '' && filereadable(expand('~/.bashrc'))
let $HASHROCKET_DIR = expand(matchstr("\n".join(readfile(expand('~/.bashrc')),"\n")."\n",'\n\%(export\)\=\s*HASHROCKET_DIR="\=\zs.\{-\}\ze"\=\n'))
endif
if $HASHROCKET_DIR == ''
@tpope
tpope / env.rb
Created September 2, 2009 21:27
# Enable Webrat's Selenium mode if one or more scenarios is tagged @selenium
Webrat.configure do |config|
config.mode = :rails
ObjectSpace.each_object(Cucumber::Ast::Features) do |features|
config.mode = :selenium if features.tag_count('selenium').nonzero?
end
end
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
When /^(.*) in the "([^\"]*)" section$/ do |action, title|
within "//*[(h1|h2|h3|h4|h5|h6|legend|caption)/descendant-or-self::*[contains(text(), '#{title}')]]" do
When action
end
end
When /^(.*) in the "([^\"]*)" row$/ do |action, title|
within "//*[(th|td)/descendant-or-self::*[contains(text(), '#{title}')]]" do
When action
end
def mask _;_[6..-5]='*'.*_.size-10;_;end