Skip to content

Instantly share code, notes, and snippets.

View jgarber's full-sized avatar

Jason Garber jgarber

View GitHub Profile
[Wed May 27 10:48:29 2009] [error] cgid daemon process died, restarting
[Wed May 27 10:48:29 2009] [warn] long lost child came home! (pid 10881)
[ pid=10888 file=ext/apache2/Hooks.cpp:566 time=2009-05-27 10:48:31.874 ]:
Unexpected error in mod_passenger: The ApplicationPool server unexpectedly closed the connection while we're reading a response for the 'g
et' command.
Backtrace:
(empty)
[ pid=10888 file=ext/apache2/Hooks.cpp:566 time=2009-05-27 10:48:31.875 ]:
Unexpected error in mod_passenger: The ApplicationPool server unexpectedly closed the connection while we're reading a response for the 'g
et' command.
require File.dirname(__FILE__) + '/spec_helper'
class Page
def part_with_array_find(name)
parts.to_a.find {|p| p.name == name.to_s }
end
def part_with_sql_find(name)
parts.find_by_name name.to_s
end
end
@jgarber
jgarber / gist:164899
Created August 9, 2009 21:06
Color management with Photoshop and Illustrator
I struggled with color management all day (or you might say, for years now).
Here's what I did:
Read http://www.viget.com/inspire/the-mysterious-save-for-web-color-shift/.
He's exactly right. Doesn't cover Illustrator, though. Here's what I figured
out:
Calibrate your monitor. I use Huey Pro. I use a color temperature of D65 and a
Gamma of 2.2.
require File.dirname(__FILE__) + '/../spec_helper'
require 'benchmark'
class DeepChildPagesDataset < Dataset::Base
uses :home_page
def load
create_page "Parent" do
1.upto(50) do |num|
@jgarber
jgarber / gist:1022726
Created June 13, 2011 13:00
Costs of running a production Rails app
Monthly costs associated with a solid setup for a Rails app (based on minimal traffic).
* Linode 512 - $19.95
* Github account - $7
* Pingdom uptime monitoring - $9.95 ($0.50 to add 1 check to existing account.)
* New Relic performance monitoring - $24 (or on-demand if you want to do shorter tests)
* Amazon CloudFront - less than $5
Other service possibilities:
* Basecamp - project management and collaboration
@jgarber
jgarber / gist:1354025
Created November 10, 2011 03:28
IndyHall Community app
* Member directory with photos
* Messages
** Multiple categories
** Email subscription
** Unsubscribe from a category
** Mute a thread if you're not interested
** Proper threading in Gmail
** Proper preview snippet in Gmail
** Take a convo off-list
** Reply to original author
@jgarber
jgarber / gist:1367789
Created November 15, 2011 17:56
Fetching most popular items in the last seven days using charlotte-ruby/impressionist
Impression.where("created_at>=? and created_at<=?",7.days.ago,Time.now).select("impressionable_id").group("impressionable_id").order("count_impressionable_id DESC").limit(7).count
@jgarber
jgarber / gist:1474739
Created December 14, 2011 01:09
Example refactoring for Greg's Rspec talk
describe TournamentRegistration do
it "should parameterize itself with id" do
registration = Factory.create(:tournament_registration, :team_name => "Mighty Badgers")
registration.to_param.should == "#{registration.id}-mighty-badgers"
end
end
@jgarber
jgarber / which_string_coercion_is_faster.rb
Created January 24, 2012 16:10
What's the fastest way to convert from a subclass of String to a String?
#!/usr/bin/env ruby
require 'benchmark'
TIMES_TO_REPEAT = 10_000_000
class SpecialString < String; end
Benchmark.bmbm do|b|
b.report("''.to_s") do
str = ''

Give RedCloth a try!

A simple paragraph with
a line break, some emphasis and a link

  • an item
  • and another
  1. one
  2. two