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
s = "Hello world!" | |
# => "Hello world!" | |
s[6..-2] = "pukeface" | |
# => "pukeface" | |
s | |
# => "Hello pukeface!" |
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
# Today I discovered what was to me a new Ruby syntax feature. | |
# I can't even blame my ignorance on the relative newness of | |
# Ruby 1.9 — works just fine in 1.8 as well. | |
def print_args(*args) | |
puts args.inspect | |
end | |
print_args "foo", "bar" | |
# => ["foo", "bar"] |
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
# The best little rvmrc to solve those annoying debates about whether or not | |
# .rvmrc should be checked in. | |
# Check this file in as .rvmrc. Any project member who desires different | |
# settings simply creates a .rvmrc_override file, which will be used if present. | |
# You'll want to add .rvmrc_override to your .gitignore. | |
local DEFAULT='rvm 1.9.2@gemset_name --verbose --create' | |
[ -f .rvmrc_override ] && source .rvmrc_override || $DEFAULT |
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
# Managing potentially messy input from a free-form text input that's supposed to represent currency. | |
# | |
# Acceptable: | |
# 1 | |
# 12 | |
# 123 | |
# 1234 | |
# 1234.56 | |
# $1 | |
# $12 |
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
function ppjson { | |
node -e " | |
require('fs').readFile( | |
'$1', | |
function(err,data) { | |
if (err) { | |
console.error(err); | |
process.exit(1); | |
} | |
console.log( |
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
curl http://www.example.com/resource.json | node -e 'ε="";θ=process;β=θ.stdin;γ=JSON;β.on("data",function(τ){ε+=τ}),β.on("end",function(){θ.stdout.write(γ.stringify(γ.parse(ε),γ.χ,2))}),β.resume();' > pretty_printed_resource.json |
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
error: refusing to create funny ref 'refs/master' remotely |
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
# for those times you want to bubble an exception up, but want to put it in a different exception class | |
module Kernel | |
def raise_as(exception_class) | |
raise if $!.nil? | |
raise exception_class, $!.message, $!.backtrace | |
end | |
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
#!/usr/bin/env node | |
var flatJSON = ''; | |
process.stdin.on('data', function(data) { | |
flatJSON = flatJSON + data; | |
}); | |
process.stdin.on('end', function() { | |
prettyJSON = JSON.stringify( JSON.parse(flatJSON), null, 2 ) | |
console.log(prettyJSON); |
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
/^[a-z0-9_À-ÖØ-öø-ÿĀ-ɏɓ-ɔɖ-ɗəɛɣɨɯɲʉʋʻ̀-ͯḀ-ỿЀ-ӿԀ-ԧⷠ-ⷿꙀ-֑ꚟ-ֿׁ-ׂׄ-ׇׅא-תװ-״-ﬨשׁ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﭏؐ-ؚؠ-ٟٮ-ۓە-ۜ۞-۪ۨ-ۯۺ-ۼۿݐ-ݿࢠࢢ-ࢬࣤ-ࣾﭐ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼก-ฺเ-๎ᄀ-ᇿ-ㆅꥠ-가-ힰ-ᄀ-ᅵァ-ヺー-ヾヲ-゚ー0-9A-Za-zぁ-ゖ゙-ゞ㐀-䶿一-鿿꜀-뜿띀-렟-﨟〃々〻]*[a-z_À-ÖØ-öø-ÿĀ-ɏɓ-ɔɖ-ɗəɛɣɨɯɲʉʋʻ̀-ͯḀ-ỿЀ-ӿԀ-ԧⷠ-ⷿꙀ-֑ꚟ-ֿׁ-ׂׄ-ׇׅא-תװ-״-ﬨשׁ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﭏؐ-ؚؠ-ٟٮ-ۓە-ۜ۞-۪ۨ-ۯۺ-ۼۿݐ-ݿࢠࢢ-ࢬࣤ-ࣾﭐ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼก-ฺเ-๎ᄀ-ᇿ-ㆅꥠ-가-ힰ-ᄀ-ᅵァ-ヺー-ヾヲ-゚ー0-9A-Za-zぁ-ゖ゙-ゞ㐀-䶿一-鿿꜀-뜿띀-렟-﨟〃々〻][a-z0-9_À-ÖØ-öø-ÿĀ-ɏɓ-ɔɖ-ɗəɛɣɨɯɲʉʋʻ̀-ͯḀ-ỿЀ-ӿԀ-ԧⷠ-ⷿꙀ-֑ꚟ-ֿׁ-ׂׄ-ׇׅא-תװ-״-ﬨשׁ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﭏؐ-ؚؠ-ٟٮ-ۓە-ۜ۞-۪ۨ-ۯۺ-ۼۿݐ-ݿࢠࢢ-ࢬࣤ-ࣾﭐ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼก-ฺเ-๎ᄀ-ᇿ-ㆅꥠ-가-ힰ-ᄀ-ᅵァ-ヺー-ヾヲ-゚ー0-9A-Za-zぁ-ゖ゙-ゞ㐀-䶿一-鿿꜀-뜿띀-렟-﨟〃々〻]+$/ |