This file contains hidden or 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 ruby1.9 | |
# encoding: UTF-8 | |
# rb-yconvert by Caio Chassot | |
# because yconvert by Steven Frank is PHP and this cannot stand. | |
# http://stevenf.com/downloads/yconvert.php.txt | |
# | |
# Converts Yojimbo's export format for password and serial number | |
# records into CSV. | |
# |
This file contains hidden or 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
i, f = 1, 100 | |
i.upto(f) { |n| puts \ | |
[[3, "Fizz"], [5, "Buzz"]].map { |d, s| | |
s if n % d == 0 }.join.sub(/^$/, n.to_s) } |
This file contains hidden or 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 ruby1.9 | |
# encoding: UTF-8 | |
############################################################################### | |
#### The quiz: turn this hash… ################################################ | |
############################################################################### | |
def initial_hash | |
{ 'child.name' => "a", | |
'child.surname' => "b", |
This file contains hidden or 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
# #### email-init | |
# Caio Chassot....: 18.4% ================== | |
# Jonas Wisser....: 6.8% ======= | |
# Paul Ward.......: 4.7% ===== | |
# Gavin Eadie.....: 4.0% ==== | |
# Jesper..........: 3.7% ==== | |
# Michael Ströck..: 3.6% ==== | |
# Faisal N Jawdat.: 3.4% === | |
# Mo McRoberts....: 3.3% === | |
# Brent Simmons...: 3.1% === |
This file contains hidden or 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
# Previous versions of this gist brought to you by major OCD. | |
# I now leave you with my pick. | |
git branch | ack -o '(?<=^\* ).*' |
This file contains hidden or 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 bash | |
if [ $# -lt 1 ]; then | |
echo "Usage: `basename $0` <destination_ssh_connection_arguments>" | |
echo "Adds your public keys to a remote server." | |
exit | |
fi | |
ssh $@ " | |
mkdir -p ~/.ssh |
This file contains hidden or 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
# Allows gnu du to accept bsd's du -d option by wrapping | |
# gdu and translating -d to --max-depth before calling it. | |
# Useful on linux and solaris | |
du --help 2>&1 | grep -q -- '-d depth' || du () { | |
args=`echo "$@" | perl -pe 's/(-\w*)d(\d+)\b/$1 --max-depth=$2/'` | |
gnu_du=`which gdu du 2>/dev/null | head -1` | |
"$gnu_du" $args | |
} | |
egem () { $EDITOR $(dirname `gem which $@`)/..; } # opens a gem directory in $EDITOR |
This file contains hidden or 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
$ ack --no-sql --ignore-dir=vendor -l '&\S+?;' | xargs \ | |
ruby1.9 -rhtmlentities -pi -e '$_ = HTMLEntities.new.decode($_)' |
This file contains hidden or 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 ruby -pi | |
# | |
# Copyright © 2010 Caio Chassot | |
# Licensed under the WTFPL <http://sam.zoy.org/wtfpl/COPYING> | |
# | |
# File Trim. (Vertical and Right trim.) | |
# Command receives file paths as arguments. Modifies them in-place. | |
# - removes trailing spaces on every line; | |
# - removes leading and trailing empty lines; | |
# - ensures files end with a line feed. |
This file contains hidden or 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 ruby1.9 | |
# encoding: UTF-8 | |
# Copyright © 2009 Caio Chassot | |
# Licensed under the WTFPL | |
def alternation(*s); s.map(&Regexp.method(:escape)).join("|") end | |
# All input is read here. | |
LINES = $stdin.readlines | |
IS_SELECTION = ENV.key?("TM_SELECTED_TEXT") |