Skip to content

Instantly share code, notes, and snippets.

View parndt's full-sized avatar

Philip Arndt parndt

View GitHub Profile
@tommeier
tommeier / avatar.perl
Created September 14, 2012 05:37
Run Gource over your git repo
#!/usr/bin/perl
#fetch Gravatars
use strict;
use warnings;
use LWP::Simple;
use Digest::MD5 qw(md5_hex);
my $size = 90;
@robinsloan
robinsloan / langoliers.rb
Last active February 27, 2025 02:44
The Langoliers, a tweet deletion script
require "rubygems"
require "twitter"
require "json"
# things you must configure
TWITTER_USER = "your_username"
MAX_AGE_IN_DAYS = 1 # anything older than this is deleted
# get these from dev.twitter.com
CONSUMER_KEY = "your_consumer_key"
@knewter
knewter / food_fight_play_comands_controller.rb
Created August 31, 2012 23:52
command controller with a callback style
class FoodFightPlayCommandsController < LoggedInController
def create
command = FoodFightPlayCommand.new(params[:food_fight_play_command])
command.person_id = current_person.id
# Set up success / failure callbacks
command.on_success = method(:on_success)
command.on_failure = method(:on_failure)
command.execute!
end
ENGINE_RAILS_ROOT = File.join(File.dirname(__FILE__), '../') unless defined?(ENGINE_RAILS_ROOT)
def setup_environment
# Configure Rails Environment
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rspec'
@drnic
drnic / Guardfile
Created April 5, 2012 06:45
An example Guardfile with the works for a Rails app
guard 'rspec', :version => 2 do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
@raphaelcm
raphaelcm / migrate.rb
Created February 10, 2012 17:10
Migrate local Refinery images/resources to S3
#!/usr/bin/env ruby
# Migrate local Refinery images & resources to S3.
# Assumes you've set up an AWS::S3 connection
# elsewhere (I have an initializer that does it).
image_classes = [Image]
data_classes = [Resource]
def upload(path, file, bucket, retries = 3)
@radar
radar / gist:1631012
Created January 18, 2012 04:41 — forked from parndt/gist:1629498
A DSL for defining different page types for Refinery CMS. Allows setting default page parts per type and defining which template shall render when the page is requested.
Refinery::Pages.configure do
types do
define :home do
self.parts = %w[intro body]
self.template = 'refinery/pages/home' # this is automatic but shows overriding
end
define :show do
self.parts = %w[body side]
# self.template is automatically 'refinery/pages/show' and thus not required.
@ugisozols
ugisozols / gist:1600844
Created January 12, 2012 14:32
Refinery::Blog routes
Refinery::Core::Engine.routes.draw do
# frontend
namespace :blog do
root :to => "posts#index"
resources :posts
end
# backend
namespace :blog, :path => "" do
@ugisozols
ugisozols / gist:1027992
Created June 15, 2011 20:13
Search Psych::SyntaxError
# This will help you trace .yml file which containts Psych::SyntaxError
require "rubygems"
require "psych"
$LOAD_PATH.unshift(File.dirname(__FILE__))
# specify your locales folder in Dir.glob("*") with relative path from this file
Dir.glob("*").sort.each do |file|
begin
@mhaylock
mhaylock / gist:995049
Created May 27, 2011 11:11
nginx config to add Cache-Control header to rails static cache files
location / {
try_files /system/maintenance.html $uri $uri/index.html $uri.html @passenger;
expires 60s;
add_header Cache-Control public;
add_header Vary Accept-Encoding;
}