Skip to content

Instantly share code, notes, and snippets.

View jonkgrimes's full-sized avatar

Jonathan Grimes jonkgrimes

View GitHub Profile
@jonkgrimes
jonkgrimes / businesses_and_ads.rb
Last active August 29, 2015 14:13
Get a list of businesses and ads counts
range = Date.new(2014,12,1)..Date.new(2014,12,31)
# Gets the list of businesses that ran ads in "range" and the ad count
Business.joins(:ads).where(ads: {publisher_id: 365, start_date:range}).uniq.map do |business|
"#{business.name}, #{business.ads.where(publisher_id: 365, start_date: range).count}"
end.each { |elem| puts elem }; 1
# Gets the list of ads that ran for a given publisher with the business name, business uuid
Business.joins(:ads).where(ads: {publisher_id: 365, start_date:range}).uniq.each do |business|
puts "#{business.uuid},#{business.name},#{business.custom_id}"
{
location: {
city: "Austin",
state: "TX"
},
results: [
{
"type": "Business",
"id": "a41be902-d385-4ff8-b3b7-f1d0d2e43209",
"name": "Orland Park Cyclery",
@jonkgrimes
jonkgrimes / unicorn.rb
Last active November 18, 2016 18:44
Unicorn.rb for keen.io configuration
worker_processes 3 # amount of unicorn workers to spin up
timeout 30 # restarts workers that hang for 30 seconds
preload_app true
GC.respond_to?(:copy_on_write_friendly=) and
GC.copy_on_write_friendly = true
before_fork do |server,worker|
defined?(ActiveRecord::Base) and
@jonkgrimes
jonkgrimes / Gemfile
Created January 18, 2013 14:28
TheSquareFoot's Gemfile
source 'https://rubygems.org'
ruby '1.9.3'
gem 'rails', '3.2.11'
gem 'pg'
gem 'unicorn'
gem 'rmagick'
gem 'carrierwave', git: "git://github.com/jnicklas/carrierwave.git"
gem 'fog'
gem 'devise'