Skip to content

Instantly share code, notes, and snippets.

View tsmango's full-sized avatar

Tom Mango tsmango

View GitHub Profile
>> Rails.cache.write('test-counter', 1)
=> true
>> Rails.cache.read('test-counter')
=> 1
>> Rails.cache.read('test-counter')
=> 1
>> Rails.cache.read('test-counter')
=> 1
>> Rails.cache.read('test-counter')
=> 1
# app/models/util/cache.rb
class Util::Cache
def self.increment(key, amount = 1)
if (value = Rails.cache.read(key)).nil?
Rails.cache.write(key, (value = amount))
else
Rails.cache.write(key, (value = value + amount))
end
<!-- /dashboard/_container - This partial is used as a template -->
<table id="dashboard">
<tr>
<td id="tabs">
<!-- Links to different areas of the dashboard -->
</td>
<td id="main">
<%= yield %>
</td>
require 'open-uri'
namespace :parse do
task :teams => :environment do
api_key = ''
teams = Array.new
entry_names = Hash.new
entry_urls = Hash.new
(1..6).to_a.each do |page|
[["201", "hurl", "http://hurl.r09.railsrumble.com"], ["734m", "LAZEROIDS!", "http://lazeroids.r09.railsrumble.com"], ["a-coders-diarrhea", "idealist", "http://idealist.r09.railsrumble.com"], ["aaron-longwell", "The Line Diet", "http://linediet.r09.railsrumble.com"], ["acts_as_ninjas", "Bartender Cocktail Recipies", "http://bartender.r09.railsrumble.com"], ["agile-bastards", "Everybody Loves Beer", "http://lovesbeer.r09.railsrumble.com"], ["agile-nomads", "PeepNote", "http://peepnote.r09.railsrumble.com"], ["agilitic-featuring-meboo", "PingMyRide", "http://agilitic.r09.railsrumble.com"], ["allcaps", "Decaf Sucks", "http://allcaps.r09.railsrumble.com"], ["andrew", "Rostered", "http://rostered.r09.railsrumble.com"], ["antga-me", "antga.me", "http://antgame.r09.railsrumble.com"], ["awesome", "Twt App", "http://valuable.r09.railsrumble.com"], ["bendyworks", "Yield the Floor", "http://yieldthefloor.r09.railsrumble.com"], ["big-bad-machine", "Twitter Competition Manager", "http://roundem.r09.railsrumble.com"], ["big
require 'rack/utils'
class FacebookCookielessSessionMiddleware
def initialize(app, session_key = '_session_id')
@app = app
@session_key = session_key
end
def call(env)
params = Rack::Request.new(env)
# The following is taken from our application_controller.rb
before_filter :handle_facebook_requests
# Ensure Facebook requests are stateful by overwriting the session method
def session
if request_for_facebook? and !params[:_session_id].nil?
# TODO: Confirm _session_id is associated with the proper ip address
Rails.cache.fetch("sessions/#{params[:_session_id]}", :expires_in => 1.week) do
def request_for_facebook?
# Until I escape Panera Bread hell
# (request.subdomains.first == 'web1' or request.subdomains.first == 'facebook') ? true : false
true
end
<!-- Automatically resize a textarea's height (like Facebook) -->
<textarea id="comment" rows="1" cols="50"></textarea>
<script type="text/javascript" charset="utf-8">
function autoResize(fieldId) {
var length = $(fieldId).value.length;
if(length > 0) {
$(fieldId).rows = Math.floor(length / $(fieldId).cols) + 1;
/* shrinkify google */
input.lsb, input.gac_sb {
-webkit-appearance: push-button !important;
}
input.lst {
font-size: 13px !important;
}
table.gac_m {