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 Client | |
def self.post(&block) | |
data = DslData.new | |
Dsl.new(data).instance_eval(&block) | |
# build request with data from dsl calls | |
# and execute request | |
puts "Making a request to #{data.url} with headers #{data.headers}" | |
response = "response" # this would be your http response | |
if rand > 0.5 # response.success? |
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 a_1 | |
{ a: 1 } if condition_1 | |
end | |
def a_2 | |
{ a: 2 } if condition_2 | |
end | |
def a_3 | |
{ a: 3 } |
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 Enumerator::Lazy | |
def each(*) | |
super | |
self | |
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
require 'money' | |
require 'json' | |
Money.use_i18n = false | |
class Money | |
def to_json(*) | |
to_s | |
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
def describe(inhabitant) | |
if inhabitant == "sophie" | |
puts 'gender: female' | |
puts 'height: 145' | |
else | |
if inhabitant == "paul" | |
puts 'gender: male' | |
puts 'height: 145' | |
else | |
if inhabitant == "dawn" |
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
puts "Hello World" |
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
#!/bin/sh | |
file "$1" | grep -q "text" | |
if [ $? -ne 0 ]; then | |
/usr/bin/open $1 | |
else | |
/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl $1:$2 | |
fi |
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 xterm-256color based TERMINFO that adds the escape sequences for italic. | |
# | |
# Install: | |
# | |
# tic xterm-256color-italic.terminfo | |
# | |
# Usage: | |
# | |
# export TERM=xterm-256color-italic | |
# |
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
#!/bin/sh | |
set -e | |
usage() { | |
echo "usage: git-extract.sh commit output-directory" | |
} | |
extract() { | |
FILES=`git diff-tree --oneline --no-commit-id --name-only -r $1` | |
for file in $FILES |
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
#!/bin/bash | |
# Run using: bash <(curl -s https://raw.github.com/gist/1363753) | |
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem | |
curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem | |
gem install linecache19-0.5.13.gem ruby-debug-base19-0.11.26.gem -- --with-ruby-include=$rvm_path/src/ruby-1.9.3-p0/ | |
rm linecache19-0.5.13.gem | |
rm ruby-debug-base19-0.11.26.gem | |
bundle update ruby-debug19 |
NewerOlder