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
# 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 |
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
# 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/ |
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
#!/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. |
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
xml.root do | |
xml.foo do | |
xml.bar | |
end | |
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
# 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' |
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 'rest_client' | |
require 'json' | |
################### | |
# CONF # | |
################### | |
# The smallest amount of changed documents before the views are updated | |
MIN_NUM_OF_CHANGED_DOCS = 10 |
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
$ 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... |
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
=== 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 |
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
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. |
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 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} |