Skip to content

Instantly share code, notes, and snippets.

View seangaffney's full-sized avatar

Sean Gaffney seangaffney

View GitHub Profile
class ApplicationController < ActionController::Base
before_filter do
if (Subdomain)
@site = Site.find_by_name!(request.subdomain)
end
end
end
@seangaffney
seangaffney / TextMate SASS Save to CSS
Created September 16, 2010 22:26
This TextMate command will export your SCSS files to CSS on save. Hotness. Requires HAML gem to be installed. It's really just a modified version of the LESS Save to CSS command. Be sure to check the screenshot in the comments for the rest of the config
#!/usr/bin/env ruby
file = STDIN.read[/sass: ([^*]+\.scss)/, 1] || ENV["TM_FILEPATH"]
file2 = file.sub(/\.scss/,'.css')
system("sass \"#{file}\":\"#{file2}\"")
@seangaffney
seangaffney / s3.rb
Created December 6, 2010 18:55
Convert Tempfile to binary using binmode
# Returns representation of the data of the file assigned to the given
# style, in the format most representative of the current storage.
def to_file style = default_style
return @queued_for_write[style] if @queued_for_write[style]
filename = path(style)
extname = File.extname(filename)
basename = File.basename(filename, extname)
file = Tempfile.new([basename, extname])
file.binmode # Added
file.write(AWS::S3::S3Object.value(path(style), bucket_name))
@seangaffney
seangaffney / application_controller.rb
Created June 10, 2011 03:56
Setting mailer path in Rails 3
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :mailer_set_url_options
def mailer_set_url_options
ActionMailer::Base.default_url_options[:host] = request.host_with_port
end
end
@seangaffney
seangaffney / gist:1041775
Created June 23, 2011 02:37
Inexplicable validation fail
ruby-1.9.2-p180-patched :010 > s = Style.create!(:name => "Awesometown", :family => 'Yay beer', :code => '8D')
ActiveRecord::RecordInvalid: Validation failed: Name can't be blank, Family can't be blank, Code can't be blank
from /Users/seangaffney/.rvm/gems/ruby-1.9.2-p180-patched/gems/activerecord-3.0.9/lib/active_record/validations.rb:49:in `save!'
from /Users/seangaffney/.rvm/gems/ruby-1.9.2-p180-patched/gems/activerecord-3.0.9/lib/active_record/attribute_methods/dirty.rb:30:in `save!'
from /Users/seangaffney/.rvm/gems/ruby-1.9.2-p180-patched/gems/activerecord-3.0.9/lib/active_record/transactions.rb:245:in `block in save!'
from /Users/seangaffney/.rvm/gems/ruby-1.9.2-p180-patched/gems/activerecord-3.0.9/lib/active_record/transactions.rb:292:in `block in with_transaction_returning_status'
from /Users/seangaffney/.rvm/gems/ruby-1.9.2-p180-patched/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
from /Users/seangaffney/.rvm/gems/ruby-1.9.2
@seangaffney
seangaffney / .bash_alias
Created July 25, 2011 15:24
HAWTEST BASH PROFILE EVAR
alias lls='ls -lha'
alias ~='cd ~'
alias reload="source ~/.bash_profile"
alias pyserver="python -m SimpleHTTPServer"
# Projects
alias cdb1="cd ~/Sites/blah1"
alias cdb2="cd ~/Sites/blah2"
@seangaffney
seangaffney / gist:1469551
Created December 12, 2011 22:59
Print functions bound to currently selected's click event
jQuery.each($($0).data("events").click, function(key, handlerObj) { console.log(handlerObj.handler) });
@seangaffney
seangaffney / sgFixThatIsh.js
Created January 20, 2012 16:58
Fix That Ish - A plugin for fixing things (one thing in particular) in the browser window. No support for IE8 and below.
/*
* jQuery sgFixThatIsh v0.1 :)
* http://seangaffney.cc
* Copyright 2012, Sean Gaffney
*/
(function( $ ){
var opts = { bottomPadding: 8 };
var $header, $content, $win;
var contWidth, currentContWidth, headHeight, headWidth,
@seangaffney
seangaffney / Emoticons
Last active December 21, 2015 02:09 — forked from endolith/Has weird right-to-left characters.txt
Unicode Emoticons
¢‿¢
©¿© o
ª{•̃̾_•̃̾}ª
¬_¬
¯\(º_o)/¯
¯\(º o)/¯
¯\_(⊙︿⊙)_/¯
¯\_(ツ)_/¯
°ω°
°Д°
DummyCourse = Struct.new(:title) do
def description
"Courses have been discontinued. This course contains all syllabi."
end
def published_for_ios
true
end