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://henrik.nyh.se/2008/12/git-dirty-prompt | |
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/ | |
# <machine> 16:44:41 (0) [master*] >>> # dirty working directory | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/ [\1$(parse_git_dirty)]/" | |
} |
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 set(x) | |
Thread.current[:x] = x | |
end | |
def say | |
puts "#{Thread.current.object_id} #{Thread.current[:x].inspect}" | |
end | |
set 'ok' | |
say |
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
# Use like this: | |
# ruby ~/src/ext/rails/railties/bin/rails APP -m ~/src/misc/mabrails.rb | |
inside('vendor') do | |
run 'ln -s ~/src/ext/rails rails' | |
end | |
file '.gitignore', <<END_IGNORE | |
.*.swp | |
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
# feature: | |
# Then I should see the following records: | |
# |row1|thing| | |
# |row2|other thing| | |
# step definition: | |
Then /^I should see the following records:$/ do |records| | |
records.rows.each do |row| | |
row.each do |value| | |
unless value.blank? |
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
<?xml version="1.0" encoding="utf-8"?> | |
<Project ToolsVersion="3.5" DefaultTargets="Verify" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<Import Project="SomeProject.csproj" /> | |
<ItemGroup> | |
<ShouldBeIncluded Include="**/*.cs" Exclude="@(Compile)" /> | |
</ItemGroup> | |
<Target Name="Verify"> | |
<Error Text="The following cs files are on disk, but not in the csproj: @(ShouldBeIncluded)" Condition="'@(ShouldBeIncluded)' != ''" /> |
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
# To run this script, you need to install ruby, rubygems, the httparty gem, | |
# and any of the json gems. | |
require 'rubygems' | |
require 'httparty' | |
require 'json' | |
require 'pp' | |
class CouchDb | |
include HTTParty | |
format :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
# From http://www.indy500.com/images/news/2009/2009_Indianapolis_500_Unofficial_Box_Score.pdf | |
# final place, start position, name | |
results = <<END_RESULTS | |
1,1,Helio Castroneves | |
2,18,Dan Wheldon | |
3,10,Danica Patrick | |
4,24,Townsend Bell | |
5,9,Will Power | |
6,5,Scott Dixon | |
7,3,Dario Franchitti |
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 Thing | |
# ... | |
def take(v) | |
@current_mode.call(v) | |
@current_mode = Accumulating | |
end | |
end | |
class Accumulating |
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
# Takes an OPML file from google reader and spits out a set of <li>s for | |
# each unique blog in the list, sorted by name, with the tags in ()s. | |
require 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
def get_tag(opml_node) | |
if opml_node.nil? | |
nil | |
elsif opml_node['htmlUrl'].nil? |
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
# This is a really simple Sinatra extension to make it easy to use compass. | |
# Its configuration isn't all that great, but its usage is: | |
# | |
# require 'sinatra/compass' | |
# get "/main.css" do | |
# compass :main | |
# end | |
require 'sinatra/base' |
OlderNewer