Skip to content

Instantly share code, notes, and snippets.

View spraints's full-sized avatar
🦦

Matt Burke spraints

🦦
View GitHub Profile
@spraints
spraints / .bashrc
Created December 4, 2008 21:44 — forked from henrik/.bashrc
# 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)]/"
}
def set(x)
Thread.current[:x] = x
end
def say
puts "#{Thread.current.object_id} #{Thread.current[:x].inspect}"
end
set 'ok'
say
# 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
# 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?
@spraints
spraints / VerifyAllSourceFilesAreIncluded.proj
Created April 28, 2009 22:34
Finds .cs files that aren't included in a .csproj file.
<?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)' != ''" />
# 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
# 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
class Thing
# ...
def take(v)
@current_mode.call(v)
@current_mode = Accumulating
end
end
class Accumulating
# 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 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'