Skip to content

Instantly share code, notes, and snippets.

View ahawkins's full-sized avatar
💭
🌈🏄🏼‍♂️🤙🏻

Adam Hawkins ahawkins

💭
🌈🏄🏼‍♂️🤙🏻
View GitHub Profile
module CacheHelper
def self.included(base)
base.class_eval do |klass|
klass.send :include, ActionController::UrlWriter
end
class << base
def default_url_options
ActionMailer::Base.default_url_options
end
@ahawkins
ahawkins / config.ru
Created December 11, 2010 05:27
resque web server + rack + rails 2 + bundler
#!/usr/bin/env ruby
require 'logger'
require 'rubygems'
require 'config/environment'
require 'resque/server'
# Set the RESQUECONFIG env variable if you've a `resque.rb` or similar
# config file you want loaded on boot.

Book Sale. All Books $10 + shipping. Paypal accepted. Contact me for details.

  • Cocoa Programming – Pragmatic Programmers
  • Learning jQuery – Packt
  • Refactoring to Patterns (Hard Cover) – Addison Wesley Signature Series
  • GoF Book (hard cover)
  • Real World Haskell Pragmatic Programmers
  • SQL AntiPattens – Pragmatic Programmers
  • XUnit Test Patterns (Hard Cover) – Addison Wesley Signature Series
  • The Rspec Book – Pragmatic Programmers
# handles cached actions and fragments with easy
def write_fragment(key, content, options = nil)
if options[:tag]
tags = options[:tag].is_a?(Array) ? options[:tag] : [options[:tag]]
tags.each do |tag|
some_redis.sadd tag, fragment_cache_key(key)
end
end
super
module ActsAsSmsable
def self.included(base)
base.class_eval do
has_many :participants_sms_messages, :as => :participant, :dependent => :destroy
has_many :sms_messages, :through => :sms_messages_participants do
def sent_to(*args)
conditions = args.map do |obj|
composite_key = "("
composite_key += "participants_sms_message.participant_id = #{obj.id}"
module RadiumCRM
module ActsAsActivity
def self.included(base)
base.class_eval do
has_many :activities, :as => :reference, :dependent => :destroy do
def create_with_tags(*tags)
activity = build :account => @owner.account
activity.tag_list.add @owner.class.to_s.underscore
activity.tag_list.add(tags)
module ScopeNamedRoutes
def self.included(klass)
klass.class_eval do
actual_routes = []
Rails.application.routes.named_routes.routes.each {|name, r| actual_routes << r }
scoped_routes = actual_routes.select do |route|
Rails.logger.debug route.path
route.path.match(/^\/:account_id\//)
end
// ==========================================================================
// Project: Admin - loginPage
// Copyright: ©2011 My Company, Inc.
// ==========================================================================
/*globals Admin */
// This page describes the main user interface for your application.
Admin.loginPage = SC.Page.design({
mainPane: SC.MainPane.design({
require 'spec_helper'
require 'nokogiri'
xml = <<-xml
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<result type="Doc.Get" howmany="1" Documents="1" Page="1/1">
<contact row="1">
<OPCO>49 Sonera / Sonera</OPCO>
<CLAS>MP</CLAS>
@ahawkins
ahawkins / Speactular.tmTheme
Created January 18, 2011 06:06
Spectacular theme posted in a Gist since it's gone from the official site
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Spectacular</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>