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
[alias] | |
track = !git branch --set-upstream "$(git name-rev --name-only HEAD)" | |
# Use like: | |
# [repo](master)$ git track origin/master | |
# Branch master set up to track remote branch master from origin. |
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
# easy spec running | |
function s { | |
if grep -q -i "RSpec.configure do" spec/spec_helper.rb; then | |
# echo "rspec2!" | |
if [ -z "$*" ]; then | |
rspec -fs -c spec | |
else | |
rspec -fs -c $* | |
fi | |
else |
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
# Rails 2 and Rails 3 console | |
function rc { | |
if [ -e "./script/console" ]; then | |
./script/console $@ | |
else | |
rails console $@ | |
fi | |
} |
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
>> Gem::Requirement.new("~>3.0.0.rc").satisfied_by? Gem::Version.new("3.0.0.a") | |
=> true | |
>> Gem::Requirement.new("~>3.0.0").satisfied_by? Gem::Version.new("3.0.0.a") | |
=> true | |
>> Gem::Requirement.new("~>3.0.0.0").satisfied_by? Gem::Version.new("3.0.0.a") | |
=> true | |
>> Gem::Requirement.new("~>3.0.0.0.0").satisfied_by? Gem::Version.new("3.0.0.a") | |
=> true | |
>> Gem::Requirement.new("~>3.0.0.0.0.0").satisfied_by? Gem::Version.new("3.0.0.a") | |
=> true |
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
# [andre ~/.bash](master)$ # clean working directory | |
# [andre ~/.bash](master⚡)$ # dirty working directory | |
# [andre ~/.bash](master~2)$ # checked out revision not a branch | |
# [andre ~/.bash](branch)$ # checked out branch with same commits as master | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "⚡" | |
} | |
function parse_git_branch { |
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 | |
require 'optparse' | |
options = { | |
:verbose => false, | |
:preset => "High Profile" | |
} | |
OptionParser.new do |opt| | |
opt.banner = "Usage: HandBrakeCLIBatch [-v | -p preset] [source] [destination]" |
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
# remove ssh known host by name | |
# -n [num] removes by line number | |
function ssh-rm-host () { | |
if [ "$1" == "-n" ]; then | |
sed -i old $2d ~/.ssh/known_hosts | |
else | |
ssh-keygen -R $1 | |
fi | |
} |
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
# Ben Bleything's IRB history hacks | |
# from RubyConf 2007, 2-4 November | |
# Lists the last how_many lines of history (defaults to 50). Aliased to h. | |
def history( how_many = 50 ) | |
history_size = Readline::HISTORY.size | |
# no lines, get out of here | |
puts "No history" and return if history_size == 0 |
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
require 'uri' | |
require 'json' | |
require 'net/https' | |
# spark, a tiny Campfire library | |
# Usage: | |
# c = Spark::Campfire.new('subdomain', 'abc123') | |
# r = c.room_named "Room Name" | |
# r.say "hi there" |
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
# Unfortunately, Builder's _attr_value method is broken. :( This means that XML | |
# created with Builder could very well be invalid, have gaping security holes, | |
# or simply lose any newline characters that happen to be in attributes. Here | |
# is the original method, from xmlmarkup.rb:310: | |
# | |
# def _attr_value(value) | |
# case value | |
# when Symbol | |
# value.to_s | |
# else |