Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

#recursively require all files in directory (and subdirectories)
Dir["#{File.dirname(__FILE__)}/squat/**/*.rb"].each {|file| require file }
#recursively require all files in directory but skip paths that match a pattern
Dir["#{File.dirname(__FILE__)}/squat/**/*.rb"].each do |file|
require file unless file =~ /\/model\//
end
svn stat | grep "^\?" | awk '{print $2}' | xargs svn add
@skorks
skorks / integertoenglish.rb
Created November 3, 2010 11:53
converting integers to english
#!/usr/bin/env ruby
NTW = {
1 => "one",
2 => "two",
3 => "three",
4 => "four",
5 => "five",
6 => "six",
7 => "seven",
@skorks
skorks / integertobetterenglish.rb
Created November 4, 2010 11:36
how integer to english would look if english was more consistent and sane when it comes to naming numbers
#!/usr/bin/env ruby
NTW = {
1 => "one",
2 => "two",
3 => "three",
4 => "four",
5 => "five",
6 => "six",
7 => "seven",
@skorks
skorks / gist:812210
Created February 5, 2011 04:38
git prompt showing branch and dirty state
#put this in .bashrc
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo " *"
}
export PS1='[\u@\h \W\[\e[1;35m\]$(__git_ps1 " (%s$(parse_git_dirty))")\[\e[0;39m\]]\$ '
@skorks
skorks / subset_sum_dynamic.rb
Created February 26, 2011 14:32
Solving the subset sum problem via dynamic programming
require 'terminal-table/import'
class SubsetSumMatrix
class << self
def create_empty_for(array)
matrix = []
header = [nil] + build_header_from(array)
matrix << header
array.each_with_index do |element,i|
row = header.collect{|value| 'F'}
@skorks
skorks / deploy.rake
Created July 8, 2011 07:43 — forked from jbarnette/deploy.rake
Heroku deploy via rake
# Hoptoad integration example.
task "deploy:before" => "isolate:dotgems" do
if /\.gems/ =~ `git status`
abort "Changed gems. Commit '.gems' and deploy again."
end
ENV["TO"] = Deploy.env
end
@skorks
skorks / asset_tag_helper.rb
Created July 8, 2011 09:16 — forked from matthewtodd/asset_tag_helper.rb
Rails + Sass + Asset Fingerprints + Heroku
# Ensure AssetTagHelper has been loaded before we try to monkey-patch it.
require 'action_view/helpers/asset_tag_helper'
module ActionView::Helpers::AssetTagHelper
# Insert the asset id in the filename, rather than in the query string. In
# addition to looking nicer, this also keeps any other static file handlers
# from preempting our Rack::StaticCache middleware, since these
# version-numbered files don't actually exist on disk.
def rewrite_asset_path(source)
source.insert source.rindex('.'), "-#{rails_asset_id(source)}"
@skorks
skorks / gist:1881521
Created February 22, 2012 04:50
My irbrc file
#!/usr/bin/env ruby
#need irbtools gem isntalled for all these to be pulled in
#need irbtools-more gem isntalled for all these to be pulled in
#you probably want these in rvm global gemset so it get pulled into all the rubies
require 'rubygems' unless defined? Gem # only needed in 1.8
require 'irbtools/configure'
Irbtools.remove_library(:hirb)
Irbtools.remove_library(:boson)
Irbtools.remove_library(:wirb)
{
":type": "application/vnd.playup.extension+json",
":uid": "tile.photo.featured.1",
":display": {
":self": "http://www.zombo.com/tileupdates.json",
":type": "application/vnd.playup.display.feature.photo+json",
"summary": "Photo Feature\nLorem ipsum dolor sit amet, consectetur adipisicing elit",
"image": "http://www.footballfedvic.com.au/uploads/pics/BoxHill_South_Emily_Web.jpg",
"footer_title": "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.",
"footer_subtitle": "Where sport gets social",