This file contains hidden or 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
# Alex MacCaw | |
# [email protected] | |
# Paranoid Hash | |
# This is so you don't need to validate options on initialize - as you may not require all the options for every method. | |
# You can validate them as the program runs - so you don't get unexpected nils. | |
# I still haven't decided whether this is a good idea or not ;) | |
# class Foo | |
# attr_reader :options |
This file contains hidden or 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
# Installing a Rails Stack on EC2/Ubuntu | |
# based on ami-1c5db975 - see http://alestic.com/ for more info. | |
sudo apt-get update | |
sudo apt-get dist-upgrade | |
sudo apt-get install build-essential | |
sudo apt-get install ruby rdoc mysql-server libmysql-ruby ruby1.8-dev irb1.8 libdbd-mysql-perl libdbi-perl libmysql-ruby1.8 libmysqlclient15off libnet-daemon-perl libplrpc-perl libreadline-ruby1.8 libruby1.8 mysql-client-5.0 mysql-common mysql-server-5.0 ruby1.8 subversion rubygems libopenssl-ruby irb rake | |
This file contains hidden or 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
# Advanced to_xml | |
# | |
# Alex MacCaw | |
# [email protected] | |
# | |
# Provide to_xml support to things like strings, | |
# so you can now actually do ['foo'].to_xml without | |
# it throwing an exception. | |
# | |
# One gotcha to look out for is Rails calls |
This file contains hidden or 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
# The first few steps I always make when creating a new Rails app | |
# Alex MacCaw | |
# [email protected] | |
# cd home | |
cd | |
# Setup your svn repo | |
svn mkdir your_svn_details/app_name | |
svn mkdir your_svn_details/app_name/trunk |
This file contains hidden or 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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" | |
"http://www.w3.org/TR/html4/strict.dtd"> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<title>twitter</title> | |
<meta name="generator" content="TextMate http://macromates.com/"> | |
<meta name="author" content="Alex MacCaw"> | |
<!-- Date: 2009-01-10 --> |
This file contains hidden or 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
class TwitterBinder < Binder::Collection | |
class << self | |
# What about filters - should they be implemented? | |
# | |
# I also feel this is lacking 'views'. | |
# There should be a view for the index, and the login | |
# There should also be an easy api in ruby/js for switching views | |
def index | |
self.items = twit.timeline(:user) |
This file contains hidden or 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
class UsersBinder < Binder::Collection | |
class << self | |
# self.items is a special method | |
# Basically it'll update users on the client side | |
def index | |
self.items = User.all | |
end | |
# def index(offset) | |
# self.items = User.all(:conditions => ['id > ?', offset]) |
This file contains hidden or 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 'digest/sha1' | |
require 'net/http' | |
class GravatarFetcher | |
# Gravatar is a bit stupid, in that there's | |
# no way to tell if they're returning the default | |
# avatar - here's a hack to do that. | |
class << self | |
def fetch(email, size=60) | |
email_hash = Digest::MD5.hexdigest(email) | |
http = Net::HTTP.new("www.gravatar.com", 80) |
This file contains hidden or 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
# Simple application config. | |
# Create a file in config/application.yml | |
# with the following: | |
# | |
# :defaults: &defaults | |
# :app_name: MyApp | |
# | |
# :development: | |
# <<: *defaults | |
# |
This file contains hidden or 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
module ValidBrowser | |
# Browser restrictor | |
# | |
# You can choose whether to just display a warning, | |
# or disable access completely. | |
# | |
# You need to include ValidBrowser in application.rb | |
# You also need to install the UserAgent plugin - http://github.com/josh/useragent | |
# | |
# Example 1 - show warning: |
OlderNewer