Skip to content

Instantly share code, notes, and snippets.

View archfear's full-sized avatar

Dan Dofter archfear

  • BrightHire
  • San Francisco, CA
View GitHub Profile
@archfear
archfear / archfear.rb
Created February 3, 2009 10:38
Template which configures a generic Rails app with Shoulda, Factory Girl, HAML, etc while commiting each step into git.
# Template which configures a generic Rails app with Shoulda, Factory Girl,
# HAML, etc while commiting each step into git.
#
# Make sure you have Rails 2.3rc1 or greater installed and run:
# rails -d mysql -m http://gist.github.com/raw/57458/06345c42a92048e699af3140ccd28bbcd8915bc5/archfear.rb my_app
# Helper methods
def environment(data = nil, options = {}, &block)
options = { :sentinel => 'Rails::Initializer.run do |config|' }.merge(options)
@archfear
archfear / gist:59328
Created February 6, 2009 10:42 — 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) {
class Test::Unit::TestCase
def self.should_have_before_filter(expected_method, options = {})
should_have_filter('before', expected_method, options)
end
def self.should_have_after_filter(expected_method, options = {})
should_have_filter('after', expected_method, options)
end
##
# test/spec/mini 2
# http://gist.github.com/25455
# chris@ozmm.org
# file:lib/test/spec/mini.rb
#
def context(*args, &block)
return super unless (name = args.first) && block
require 'test/unit'
klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
# Dan Croak, February 2008
# updated by Dan Dofter, February 2010
VIEWS_DIR = "#{RAILS_ROOT}/app/views"
CSS_DIR = "#{RAILS_ROOT}/public/stylesheets"
SASS_DIR = "#{VIEWS_DIR}/stylesheets"
def convert_css_to_sass(css_file)
if css_file =~ /^(.*)(\.css)$/
basename = $1
file 'Gemfile', <<-GEMS
source 'http://gemcutter.org'
gem "rails", "3.0.0.beta3"
gem "bson_ext"
gem "mongoid", "2.0.0.beta4"
gem "haml", "3.0.0.rc.2"
gem "compass", "0.10.0.rc4"
gem "inherited_resources"
group :test do
namespace :assets do
namespace :js do
desc "Package JavaScript"
task :package do
puts "Packaging path.js..."
repackage_javascript
end
namespace :package do
task "pre-commit" do
# Dan Croak, February 2008
# updated by Dan Dofter, February 2010
VENDORED_HAML_BIN = Dir["#{Rails.root}/vendor/gems/haml*/bin"].first
VIEWS_DIR = "#{Rails.root}/app/views"
CSS_DIR = "#{Rails.root}/public/stylesheets"
SASS_DIR = "#{VIEWS_DIR}/stylesheets"
def convert_css_to_sass(css_file)
@archfear
archfear / chrome-profile
Created November 8, 2013 04:13
This script creates an app which launches Google Chrome with a new profile and allows for running multiple instances of Chrome simultaneously.
#!/bin/bash
#
# This script creates an app which launches Google Chrome with a new profile
# and allows for running multiple instances of Chrome simultaneously.
#
# Based on: http://blog.duoconsulting.com/2011/03/13/multiple-profiles-in-google-chrome-for-os-x/
set -e
if [ $# == 0 ]; then
@archfear
archfear / fix_whitespace.rake
Last active December 27, 2015 17:59
Pre-commit hook for git which removes trailing whitespace, converts tabs to spaces and adds a newline to the end of the file if missing.
script_file = File.join(Rails.root, "script", "git_fix_whitespace.sh")
desc "Remove trailing whitespace and convert tabs to spaces"
task :fix_whitespace do
`sh #{script_file} -f`
end
namespace :fix_whitespace do
desc "Installs a git pre-commit hook which removes trailing whitespace and converts tabs to spaces"
task :install, :force do |t, args|