Skip to content

Instantly share code, notes, and snippets.

View unders's full-sized avatar

Anders Törnqvist unders

  • Functionbox
  • Göteborg, Sweden
View GitHub Profile
@unders
unders / gist:4200
Created August 6, 2008 09:38 — forked from defunkt/gist:4169
# by bryan helmkamp with slight modification by chris wanstrath
# from http://www.brynary.com/2008/8/3/our-git-deployment-workflow
module GitCommands
extend self
def diff_staging
`git fetch`
puts `git diff origin/production origin/staging`
end
desc "Push design to spec"
task :design do
require 'yaml'
specs = YAML::load_file './spec/design.yml'
specs.each_pair do |describe, specs_array|
spec_file = File.new("./spec/#{describe.downcase.gsub(/ /, '_')}_spec.rb", 'w')
spec_file.puts <<-END
require File.dirname(__FILE__) + '/spec_helper'
describe "#{describe}" do
#!/bin/bash
VERSION="1.1"
REEV="http://rubyforge.org/frs/download.php/48623/ruby-enterprise-1.8.6-20081215.tar.gz"
REEF="ruby-enterprise-1.8.6-20081215.tar.gz"
REEFF=${REEF%".tar.gz"}
PASSENGER="2.0.6"
echo "#####################################"
echo "Welcome, let's get this party rollin'"
echo "#####################################"
#!/usr/bin/env ruby
require 'rubygems'
require 'thor'
require 'fileutils'
require 'yaml'
# module: tm
$SILENT = true
@unders
unders / hookz.rb
Created February 3, 2009 18:58 — forked from jnicklas/hookz.rb
class SomeClass
class << self
def hooks
@hooks ||= Hash.new([])
end
def add_hook(kind, &block)
self.hooks[kind] << block
end
@unders
unders / gist:58328
Created February 4, 2009 20:28 — forked from giom/gist:58005
module Sass::Script
module Functions
# substitue text in a string
# @params
# str the string to substitute text from
# reg the regexp given to sub
# rep the replacement text
def sub(str, reg, rep = '')
Sass::Script::String.new(str.to_s.sub(/#{reg.to_s}/, rep.to_s))
end
@unders
unders / gist:59087
Created February 5, 2009 23:13 — forked from rails/gist:58761
var DateHelper = {
// Takes the format of "Jan 15, 2007 15:45:00 GMT" and converts it to a relative time
// Ruby strftime: %b %d, %Y %H:%M:%S GMT
time_ago_in_words_with_parsing: function(from) {
var date = new Date;
date.setTime(Date.parse(from));
return this.time_ago_in_words(date);
},
time_ago_in_words: function(from) {
module BuilderStepHelpers
def create_model(model_name, attributes={})
send("create_#{model_name.gsub(' ','_')}",attributes)
end
end
World do |world|
world.extend BuilderStepHelpers
end
@unders
unders / gist:59100
Created February 5, 2009 23:26 — forked from rails/gist:58761
var DateHelper = {
// Takes the format of "Jan 15, 2007 15:45:00 GMT" and converts it to a relative time
// Ruby strftime: %b %d, %Y %H:%M:%S GMT
time_ago_in_words_with_parsing: function(from) {
var date = new Date;
date.setTime(Date.parse(from));
return this.time_ago_in_words(date);
},
time_ago_in_words: function(from) {
@unders
unders / gist:71647
Created February 27, 2009 19:24 — forked from rails/gist:58761
var DateHelper = {
// Takes the format of "Jan 15, 2007 15:45:00 GMT" and converts it to a relative time
// Ruby strftime: %b %d, %Y %H:%M:%S GMT
time_ago_in_words_with_parsing: function(from) {
var date = new Date;
date.setTime(Date.parse(from));
return this.time_ago_in_words(date);
},
time_ago_in_words: function(from) {