Skip to content

Instantly share code, notes, and snippets.

View jimmybaker's full-sized avatar

Jimmy Baker jimmybaker

View GitHub Profile
class Session < ActiveRecord::Base
end
s = Session.find_by_session_id 'INSERT-SESSION-ID-HERE'
Marshal.load(Base64.decode64(s.data))
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'
dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
daemon_options = {
:multiple => false,
:dir_mode => :normal,
:dir => File.join(dir, 'tmp', 'pids'),
:backtrace => true
class Address < ActiveRecord::Base
belongs_to :addressable, :polymorphic => true
named_scope :default, :conditions => { :default => true }
named_scope :without, lambda{|address| { :conditions => ["id <> ?", address.to_param] }}
before_save :set_default
private
def set_default

HOWTO: iPhone AT&T Tethering

In 10 steps:

  • Update iTunes to 8.2 via Software Update
  • Update your iPhone to the 3.0 release (out today - June 17th)
  • Download this dmg and mount it: tethering file
  • Enable hidden carrier testing option (in Terminal.app): defaults write com.apple.iTunes carrier-testing -bool TRUE
  • Start up iTunes
@jimmybaker
jimmybaker / database.yml
Created December 30, 2009 21:50 — forked from jnunemaker/database.yml
mongo setup for rails
development: &global_settings
database: textual_development
host: 127.0.0.1
port: 27017
test:
database: textual_test
<<: *global_settings
production:
class Comment
include MongoMapper::EmbeddedDocument
include Gravatarable
key :name, String
key :email, String
key :url, String
key :body, String
key :created_at, Time
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.swig505.redis</string>
<key>Program</key>
<string>/usr/local/redis/redis-server</string>
<key>ProgramArguments</key>
<array>
desc "Fetch affiliate offers"
task :getoffers => :environment do
require 'nokogiri'
require 'open-uri'
Offer.find(:all).each do |offer|
url = "http://www.findaffiliateoffers.com/index.php?function=search&search="
doc = Nokogiri::HTML(open(url))
payout = doc.at_css(".l4").text[/[0-9\.]+/]
offer.update_attribute(:payout, payout)
desc "Fetch affiliate offers"
task :getoffers => :environment do
require 'mechanize'
agent = WWW::Mechanize.new
agent.get("http://odigger.com/Find-All-Affiliate-Programs")
total_number_of_pages = ..gram the total number of pages..
total_number_of_pages.to_i.times do |page_num|
agent.get("http://odigger.com/Find-All-Affiliate-Programs?&pg=#{page_num + 1}")
@jimmybaker
jimmybaker / etc_init.d_unicorn_example.co.uk
Created November 3, 2011 20:39 — forked from scottlowe/etc_init.d_unicorn_example.co.uk
Ruby on Rails server setup on Ubuntu 11.04 with Nginx, Unicorn, Rbenv
#! /bin/bash
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the unicorn web server
# Description: starts unicorn