This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def make_adder(): | |
grand_total = 0 | |
def adder(to_add): | |
nonlocal grand_total | |
print("Grand total moved from: %s" % grand_total) | |
grand_total += to_add | |
print("To: %s \n" % grand_total) | |
return grand_total | |
return adder | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let args = os::args(); | |
let mut washed_args = Vec::new(); | |
for arg in args.iter() { | |
washed_args.push(arg.as_slice()) | |
} | |
match washed_args.as_slice() { | |
[_, "review", opts..] => { review(opts) } | |
_ => { usage() } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://henrik.nyh.se/2008/12/git-dirty-prompt | |
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/ | |
# username@Machine dir [master]$ # clean working directory | |
# username@Machine dir [master*]$ # dirty working directory | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/ [\1$(parse_git_dirty)]/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def screenshot | |
require 'capybara/util/save_and_open_page' | |
now = Time.now | |
p = "/#{now.strftime('%Y-%m-%d-%H-%M-%S')}-#{rand}" | |
Capybara.save_page body, "#{p}.html" | |
path = Rails.root.join("#{Capybara.save_and_open_page_path}#{p}.png").to_s | |
page.driver.render path | |
Launchy.open path | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var XML_CHAR_MAP = { | |
'<': '<', | |
'>': '>', | |
'&': '&', | |
'"': '"', | |
"'": ''' | |
}; | |
function escapeXml (s) { | |
return s.replace(/[<>&"']/g, function (ch) { |