Skip to content

Instantly share code, notes, and snippets.

View scottwater's full-sized avatar

Scott Watermasysk scottwater

View GitHub Profile
@scottwater
scottwater / css.css
Created October 6, 2011 21:17
Adding Google+ To KickoffLabs
#socialmessage, #socialnetworks{float:none;}
#gplus{float:left;}
#socialnetworks #Twitter, #socialnetworks #Facebook {float:left; !important}
@scottwater
scottwater / adwords.html
Created October 6, 2011 13:40
Google Conversion Tracking With KickoffLabs
<script>
$(document).ready(function(){
$("#signup_form").bind("kol:success", function(e, data, status, xhr) {
$div = $('<div style="display:inline;">');
$div.append('<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/992175653/?value=20&amp;label=J_1oCKunogMQpcyN2QM&amp;guid=ON&amp;script=0"/>');
$div.appendTo('body');
});
});
</script>
@scottwater
scottwater / postmarker.rb
Created September 4, 2011 13:32
Supporting Multiple SMTP Servers in Rails
module Postmarker
def postmark_mail(*args)
mail_message = mail(*args)
if can_use_postmark?(mail_message.From.to_s)
mail_message.delivery_method.settings.merge!(
:address => 'smtp.postmarkapp.com',
@scottwater
scottwater / domain.rb
Created August 27, 2011 18:08
Subdomains and Domains in Rails 3.0
class Domain
def self.matches?(request)
# ROOT_DOMAIN is a configurable value so we don't catch skip www.kickofflabs.com
request.host.downcase != KickoffLabs::ROOT_DOMAIN
end
end
@scottwater
scottwater / brew.config
Created July 20, 2011 14:13
brew install libtiff
HOMEBREW_VERSION: 0.8
HEAD: 6d15547fa6d422fd55e3c7c7dcf617176afe55da
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_LIBRARY_PATH: /usr/local/Library/Homebrew
Hardware: 8-core 64-bit sandybridge
OS X: 10.7
Kernel Architecture: x86_64
Ruby: 1.8.7-249
# Pass in the name of the site you wich to create a cert for
domain_name = ARGV[0]
if domain_name == nil
puts "Y U No give me a domain name?"
else
system "openssl genrsa -out #{domain_name}.key 1024"
system "openssl req -new -key #{domain_name}.key -out #{domain_name}.csr -subj '/C=US/ST=NJ/L=Monroe/O=MyCompany/OU=IT/CN=#{domain_name}'"
system "cp #{domain_name}.key #{domain_name}.key.bak"
@scottwater
scottwater / kapow.zsh
Created May 13, 2011 04:33 — forked from csexton/kapow.zsh
Zsh function to restart an app running under pow
# Restart a rack app running under pow
# http://pow.cx/
#
# Adds a kapow command that will restart an app
#
# $ kapow myapp
# $ kapow # defaults to current directory
#
# Supports command completion.
#
@scottwater
scottwater / mail_queue.rb
Created April 26, 2011 14:24
A really simple general purpose mail queue for resque
module MailQueue
extend self
def queue
:default
end
def perform(options = {})
options = options.with_indifferent_access
Site.joins(:user).select('sites.user_id, count(*) as count').group('sites.user_id')
<Site user_id: 1> #should have a count of 2
# returns only the user_id. If I cheat and name the 'count' column the same name as another column on my model it returned.
Site.joins(:user).select('sites.user_id, count(*) as id').group('sites.user_id') #BAD!
<Site id: 2, user_id: 1> #id == count in this result
@scottwater
scottwater / secure_resqueue_server_1.rb
Created April 13, 2011 14:08
Quick samples on securing Resque::Server
require 'resque/server'
class SecureResqueServer < Resque::Server
before do
redirect '/' unless some_condition_is_met!
end
end