Skip to content

Instantly share code, notes, and snippets.

View klochner's full-sized avatar

kevin lochner klochner

View GitHub Profile
### Keybase proof
I hereby claim:
* I am klochner on github.
* I am klochner (https://keybase.io/klochner) on keybase.
* I have a public key whose fingerprint is 1934 D31D 2857 BBA4 699C D5EF 5239 6745 C3F7 E0D0
To claim this, I am signing this object:
@klochner
klochner / keybase.md
Created December 9, 2014 05:52
keybase.md
### Keybase proof
I hereby claim:
* I am klochner on github.
* I am klochner (https://keybase.io/klochner) on keybase.
* I have a public key whose fingerprint is BB95 4724 3DDE 55BA 16B3 0923 B9B8 24B2 9462 C374
To claim this, I am signing this object:
function merge(ray1, ray2) {
var out = [];
var index1 = 0;
var index2 = 0;
var length1 = ray1.length;
var length2 = ray2.length;
while (index1 < length1 && index2 < length2) {
var item1 = ray1[index1];
var item2 = ray2[index2];
if (item1 <= item2) {
def get_public_action_urls(controller)
controller_name = (/(\S+)_controller/).match(controller.name.underscore)[1]
controller.action_methods.select { |m|
url_for(:controller= >controller_name,
:action=>m,
:method=>:get,
:host=>APP_CONFIG['settings']['domain']
) rescue nil}.collect do |m|
url_for :controller=>controller_name,
:action=>m,:host=>APP_CONFIG['settings']['domain']
require 'rubygems'
require 'optparse'
require 'yaml'
options = {}
ARGV.options do |opts|
opts.on( "-c", "--configfile ENVIRONMENT", String,
"mongrel cluster config file." ) do |config_file|
options[:config_file] = config_file
end
def freq(letter)
freq_dict = {"a" => 8.167,
"b" => 1.492,
"c" => 2.782,
"d" => 4.253,
"e" => 12.702,
"f" => 2.228,
"g" => 2.015,
"h" => 6.094,
"i" => 6.966,
class ActionMailer::Base
@@name_regex = '[\w\.%\+\-]+'.freeze
@@dom_head_regex = '(?:[A-Z0-9\-]+\.)+'.freeze
@@dom_tld_regex = '(?:com|org|net|edu|gov|mil|biz|info|mobi|name|aero|jobs|museum|[A-Z]{2})'.freeze
@@carated_regex = /\A.*<\s*(#{@@name_regex}@#{@@dom_head_regex}#{@@dom_tld_regex})\s*>.*\z/i
@@uncarated_regex = /\A\s*(#{@@name_regex}@#{@@dom_head_regex}#{@@dom_tld_regex})\s*\z/i
def valid_recipient(s)
addr = $1 if s=~@@carated_regex || s=~@@uncarated_regex
addr && Unsubscribe.find_by_email(addr).nil?
def send_to_sales_force(info_request)
sf_url = "www.salesforce.com"
sfhash = {"oid"=>"GET_THIS_FROM_SALES_FORCE",
"retURL"=>"http://www.mycompany.com",
"first_name"=>info_request.first_name,
"last_name"=>info_request.last_name,
"email"=>info_request.email,
"company"=>info_request.company,
def sanitize_for_filename
#strip the string
ret = self.strip
#blow away apostrophes
ret.gsub! /['`]/,""
# @ --> at, & --> and
ret.gsub! /\s*@\s*/, " at "
ret.gsub! /\s*&\s*/, " and "
class << Foo
def mass_habtm(attr_array)
attr_str = attr_array.map{|a| %Q{'#{a}'} }.uniq.join(",")
self.connection.execute(%Q{insert into foos_bars (foo_id,bar_id)
select distinct foos.id,bars.id from foos,bars
where foos.id = #{self.id}
and bars.some_attribute in (#{attr_str})})
end
end