This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
OlderNewer