Skip to content

Instantly share code, notes, and snippets.

@adambair
adambair / titler
Created April 26, 2009 15:06
Post your current iTunes track to Presently.
#!/usr/bin/env ruby
require 'rubygems'
require 'rbosa'
account='xxx'
username='xxx'
password='xxx'
api="https://#{account}.presentlyapp.com/api/twitter/statuses/update.xml"
itunes = OSA.app("iTunes")
class User < ActiveRecord::Base
validates_presence_of :email, :password, :password_confirmation
acts_as_authentic
end
@adambair
adambair / epic snow leopard upgrade guide.txt
Created September 3, 2009 13:44 — forked from edward/epic snow leopard upgrade guide.txt
Epic Snow Leopard Upgrayyyyd Guide
=== 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
# Eric Wallace and Adam Bair
# Ruby Games (github.com/clr/ruby_games) #003
class WideFinder
def initialize( findee )
@counts = Hash.new(0)
if findee.kind_of?(Array)
countme( findee )
elsif findee.kind_of?(String)
@adambair
adambair / vcheat
Created October 5, 2009 13:00
open a cheat in your browser form the command line (osx)
#!/usr/bin/env ruby
`/usr/bin/open http://cheat.errtheblog.com/s/#{ARGV[0]}`
→ git commit
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
102 2556 104 626 101 1930 317 979 0:00:01 0:00:01 --:--:-- 1171
[master 44244cf] Fix #35 Contractor tabs
22 files changed, 609 insertions(+), 145 deletions(-)
create mode 100644 app/views/contractors/_contract.html.erb
rewrite app/views/contractors/show.html.erb (90%)
create mode 100755 public/images/ui-bg_flat_0_aaaaaa_40x100.png
create mode 100755 public/images/ui-bg_flat_75_ffffff_40x100.png
* Beautiful code is the balanced application of Proportion, Integrity, and Clarity.
Proportion
/\ [ each are necessary ]
/ \ [ none are sufficient ]
/____\
Integrity Clarity
* Proportion: The smallest size needed to do the job.
# How to setup multiple heroku accounts
# (assuming you already have one setup)
# make sure ~/bin is in your path
create ~/bin/hcred and populate it with the following:
1 #!/usr/bin/env ruby
2
3 `rm ~/.heroku/credentials`
def self.defaults
defaults = OpenStruct.new
defaults.from_date = default_from_date
defaults.to_date = default_to_date
defaults
end
def self.default_from_date
default_date - 1.year
end
class ProductObserver < ActiveRecord::Observer
observe :product
def after_save(product)
reload_routes
end
def after_destroy(product)
reload_routes
end