Skip to content

Instantly share code, notes, and snippets.

View mattetti's full-sized avatar

Matt Aimonetti mattetti

View GitHub Profile
# expires_at '21:30', :public => true, :private => false
# will set max-age to the amount of seconds between now and tomorrow at 9:30PM
module ExpiresAt
def self.included(base)
base.send(:include, InstanceMethods)
end
module InstanceMethods
@mattetti
mattetti / connection_fix.rb
Created May 22, 2010 00:52 — forked from defunkt/connection_fix.rb
limit the amount of retries to 5
# If your workers are inactive for a long period of time, they'll lose
# their MySQL connection.
#
# This hack ensures we re-connect whenever a connection is
# lost. Because, really. why not?
#
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar)
#
# From:
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/
@mattetti
mattetti / install_homebrew.rb
Created May 18, 2010 02:09 — forked from mxcl/install_homebrew.markdown
Ruby 1.9 compatible version
#!/usr/bin/ruby
#
# Download and execute this script in one-line with no temporary files:
#
# ruby -e "$(curl http://gist.github.com/raw/323731/install_homebrew.rb)"
#
#
# I deliberately didn't DRY /usr/local references into a variable as this
# script will not "just work" if you change the destination directory. However
# please feel free to fork it and make that possible.
xml.root do
xml.foo do
xml.bar
end
end
@mattetti
mattetti / gist:259716
Created December 18, 2009 19:48 — forked from alloy/gist:225050
# Install kicker on osx: sudo gem install kicker --source http://gemcutter.org
#
# Place a `.kick' file with this code in the root of your project, which contains the file to watch.
# Then start running kicker from the project root: $ kicker
module Mockup
FILE_TO_WATCH = 'mockup-1.psd'
def self.last_exported_version
FileUtils.mkdir_p 'output'
require 'rest_client'
require 'json'
###################
# CONF #
###################
# The smallest amount of changed documents before the views are updated
MIN_NUM_OF_CHANGED_DOCS = 10
$ thor merb:gem:redeploy
Installing abstract-1.0.0
Installing cgi_multipart_eof_fix-2.5.0
Installing couchrest-0.30
Installing daemons-1.0.10
Installing erubis-2.6.3
Installing extlib-0.9.10
Installing fail-fast-1.0.0
Installing fastthread-1.0.1
Building native extensions. This could take a while...
=== Epic Snow Leopard Upgrayyyyd Guide ===
Son, you’re now living in the land of 64-bit systems.
That means that some of your 32-bit shit is now broken.
Not all is lost.
== Fixing MySQL weirdness
CIS 282
Files Assignment
To turn in:
 Attach a file files_lastname.rb as an attachment to the assignment in Blackboard
 Subject line: CIS 282, Name, Files
To do:
Take your program from the Hash Assignment and modify it to use files for storing the data instead of initializing the data at run-time.
def print_out(string)
STDOUT << string
end
def products
@products ||= { 827 => {'name' => "ARM", 'price' => 349.99},
199 => {'name' => "LEG", 'price' => 224.75},
776 => {'name' => "FIRSTBORN", 'price' => 1499.95},
222 => {'name' => "LIFESAVINGS", 'price' => 49.99},
811 => {'name' => "RETIREMENT", 'price' => 49.99}