Skip to content

Instantly share code, notes, and snippets.

View radamant's full-sized avatar

Adam Pearson radamant

  • The Instrumental Group
  • Olympia
View GitHub Profile
class ResquePaperclipJob
@queue = :paperclip
def self.perform(instance_klass, instance_id, attachment_name)
instance = instance_klass.constantize.find(instance_id)
instance.send("#{attachment_name}_processing!", :save => true)
begin
instance.send(attachment_name).reprocess!
instance.send("#{attachment_name}_processed!")
class DelayedPaperclipJob < Struct.new(:instance_klass, :instance_id, :attachment_name)
def perform
instance = instance_klass.constantize.find(instance_id)
instance.send("#{attachment_name}_processing!", :save => true)
begin
instance.send(attachment_name).reprocess!
instance.send("#{attachment_name}_processed!")
rescue Exception => e
instance.send("#{attachment_name}_processing!", :save => true)
# RUN IN CPS
require 'spec/factories'
footage_user = Factory(:footage_contributor,
:aip_id => "7c15b020-1b5d-012d-be98-64b9e8c74a0e",
:email => "[email protected]",
:first_name => "Adam",
:last_name => "Pearson",
:is_enrolled => true
)
@radamant
radamant / gist:362371
Created April 10, 2010 23:39
A simple graph using Raphael
We couldn’t find that file to show.
@radamant
radamant / haml_converter.rb
Created July 19, 2010 14:16
Simple haml-sass conversion for jekyll
module Jekyll
require 'haml'
class HamlConverter < Converter
safe true
priority :low
def matches(ext)
ext =~ /haml/i
end
#!/usr/bin/env ruby
def run(cmd)
puts ">> #{cmd}"
puts `#{cmd}`
end
branch = ARGV[0]
remote = branch.split("/")[0]
name = branch.split("/")[1]
var rules = {"email-address":{minlength:10}}
// or var validations = { rules: {...}, messages: {...} }
for(fieldName in rules){
var element = $('input[name="' + fieldName + '"]');
var fieldRules = rules[fieldName]
for(ruleName in fieldRules){
var rule = {};
rule[ruleName] = fieldRules[ruleName];
var numbers = [1,2,3,4];
var numObject = {
1: 1,
2: 2,
3: 3,
4: 4
}
var funcs = [];
@radamant
radamant / pouch.rb
Created October 20, 2010 19:42
simple command that runs `mkdir -p new/path/; touch /new/path/file`
#!/usr/bin/env ruby
path = ARGV[0]
dir = File.dirname(path)
`mkdir -p #{File.dirname(path)}; touch #{path}`

Development

Guidelines

Underscores, spaces, tabs, dashes

ruby

def tabs_or_spaces