Skip to content

Instantly share code, notes, and snippets.

View tsnow's full-sized avatar

Tim Snowhite tsnow

  • Palantir
  • Washington, DC
View GitHub Profile
context 'a new address' do
setup { @address = Address.new}
context 'with a valid,resolvable place' do
setup {
@address.zipcode = 97202
geo_response = mock(GeoResponse)
{:success => true, :zip => 97202, :lng => 10, :lat => 10}.each{|method,resp| geo_response.stubs(method).returns(resp)}
Geokit::Geocoders::MultiGeocoder.should_recieve(:geocode).returns(geo_response)
}
should "create location" do
sqlite> delete from listing_type_options;
sqlite> .quit
MyRealTrade> rake db:seed
MyRealTrade> sqlite3 db/development.sqlite3
sqlite> select * from listing_type_options;
27|Single Family
28|Townhouse
29|Apartment/Condo
30|Multi Family
31|Undeveloped Land
//Sorry, I was crazy. Ignore this bug report.
Delayed::Job.delete_all;
{
TradePlan => :work_listing_affinities,
SearchPlan => :work_listing_affinities}.each do |klass,method|
klass.all.each{|k| k.send_later(method)}
end
{ Address => [:cycle_location_and_geocode_and_save, 0, true],
SearchPlan => [:calc_important_affinities, 2, false]}.each do |klass,method_priority|
method = method_priority[0]
priority = method_priority[1]

On April 26th 2010 I deactivated my facebook account.

Here is my response to their "Why are you leaving?" survey:

[x] Facebook is no longer Useful for me.

"I'm no longer near my friends, so it's not useful to organize events with them anymore.

As my professional life grows, having a public photo history of my college social group is no longer an enjoyable activity.

/*
HTTP Host: static.ak.fbcdn.net
Generated: April 26th 2010 3:53:31 PM PDT
Machine: 10.16.139.107
Locale: nu_ll
Path: js/19khsprwvtvokwow.pkg.js
*/
if (window.CavalryLogger) {
CavalryLogger.start_js(["js\/19khsprwvtvokwow.pkg.js"]);
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" id="facebook" class=" no_js">
<head>
<meta http-equiv="Content-type" content="text/html;
charset=utf-8" />
<meta http-equiv="Content-language" content="en" />
<script type="text/javascript">
//<![CDATA[
CavalryLogger=false;
min_release = "1.8.2 (2004-12-25)"
ruby_release = "#{RUBY_VERSION} (#{RUBY_RELEASE_DATE})"
if ruby_release =~ /1\.8\.3/
abort <<-end_message
Rails does not work with Ruby version 1.8.3.
Please upgrade to version 1.8.4 or downgrade to 1.8.2.
end_message
elsif ruby_release < min_release
#For http://stackoverflow.com/questions/3818686/this-sql-appears-to-be-giving-weird-results-with-multiple-joins-how-do-i-correct
#If you want to batch this all in one query, I would suggest creating a bunch of subqueries to count the records for each join, then joining to each of those.
#If you have few companies it would probably be better to use @klew's answer, and just loop through each company doing one query for each join type.
def self.get_list(report_start_date, report_end_date)
#Create a subquery for each join table which creates a count of all the records per company
email_sub_query = Company.scoped(:select =>
'companies.id,
count(contact_emails.id) as email_count',
:joins =>
@tsnow
tsnow / sphinx_extended.rb
Created October 15, 2010 20:15
Search query syntax
Storeaka.search_for_ids(
[
%[@name "^#{q}$"],
%[@url "^#{q}$"],
%[@aka =("\$#{q}")]
]).map{|x| "(#{x})"}.join(' | '),
:match_mode => :extended2) #(@name "^hertz$") | (@url "^hertz$") | (@aka =("\$hertz"))