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 scream(s) | |
s.upcase | |
end | |
s = scream(<<-TEXT.gsub('z', 's')).gsub('EE', 'I') | |
Theez eez a lot of text. | |
Not really, but eet could be. | |
TEXT |
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://rubular.com/r/UMTb5KhY8A | |
DATE=/\d{4}-\d{2}-\d{2}/ | |
ZONE=/Z|[-+]\d{2}(?::\d{2})?/ | |
TIME=/\d{2}(?::\d{2}(?::\d{2}(?:\.\d+)?)?)?/ | |
TIME_WITH_ZONE=/#{TIME}(?:#{ZONE})?/ | |
ISO8601_FORMAT=/^(#{DATE})(?:T(#{TIME_WITH_ZONE}))?$/ | |
ISO8601_FORMAT.match('2008-08-30T01:45:36.100Z') # => #<MatchData "2008-08-30T01:45:36.100Z" 1:"2008-08-30" 2:"01:45:36.100Z"> |
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
tmush-first-window() { | |
session_name=$1 | |
window_name=$2 | |
cmd=$3 | |
work_dir=$4 | |
start_window=$window_name | |
if [[ "$work_dir" != "" ]]; then | |
cd "$work_dir" |
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
# Make with double space instead tabs. | |
spake () { | |
cat Makefile | sed 's/ /\t/g' > Spakefile | |
make -f Spakefile $@ | |
rm Spakefile | |
} |
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
# dog = cat || less | |
dog () { | |
a=$(</dev/stdin) | |
echo $a | $((($(echo $a | wc -l) < $LINES)) && echo cat || echo less) | |
} |
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
class Fixnum | |
def +@ | |
2 | |
end | |
def -@ # !> method redefined; discarding old -@ | |
-2 | |
end | |
def +(o) # !> method redefined; discarding old + |
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 scream(s) | |
s.upcase | |
end | |
array = %w[i scream u scream we all scream for icecream] | |
## "On" the object | |
array.map(&:upcase) | |
# => ["I", "SCREAM", "U", "SCREAM", "WE", "ALL", "SCREAM", "FOR", "ICECREAM"] | |
array.map { |c| c.method(:upcase).call } |
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
# Lots of colors | |
export PS1='\[\033[00;32m\]\u\[\033[01m\]@\[\033[00;36m\]\h\[\033[01m\]:\[\033[00;35m\]\w\[\033[00m\]\[\033[01;33m\]`git branch 2>/dev/null|cut -f2 -d\* -s`\[\033[00m\]\$ ' | |
# Branch name colored yellow | |
export PS1='\u@\h:\w\[\033[00m\]\[\033[01;33m\]`git branch 2>/dev/null|cut -f2 -d\* -s`\[\033[00m\]\$ ' | |
# No colors | |
export PS1='\u@\h:\w`git branch 2>/dev/null|cut -f2 -d\* -s`\$ ' |
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
# Signing an OAuth request | |
# Hannes Tydén, hannes@soundcloud.com, 2009-07-14 | |
# Updated at 2009-09-03 to support OAuth 1.0a | |
# This is designed to be executed in an editor evaluating expressions and outputting the result inline. | |
# The spec: | |
# http://oauth.net/core/1.0#signing_process | |
# Read more: |
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
controller = returning(ControllerClass.new()) { |c| c.send(:assign_shortcuts, ActionController::TestRequest.new, ActionController::TestResponse.new): c.send(:initialize_current_url) } |
OlderNewer