Skip to content

Instantly share code, notes, and snippets.

View colin's full-sized avatar

Colin Schlueter colin

View GitHub Profile
@colin
colin / gist:40071
Created December 26, 2008 14:53 — forked from peterc/gist:33337
# SUPER DARING APP TEMPLATE 1.0
# By Peter Cooper
# Link to local copy of edge rails
inside('vendor') { run 'ln -s ~/dev/rails/rails rails' }
# Delete unnecessary files
run "rm README"
run "rm public/index.html"
run "rm public/favicon.ico"
# Examples of Nesting Associated Attributes
# This is a look at the various ways to set associated attributes through
# nested parameters. For example, let's say Project has_many :tasks and
# we want to update the tasks the same time we edit a project. There are
# several ways this interface could be handled, and here are a few.
#
# For these examples, we're trying to create two new tasks and update an
# existing task (with id 3) through a project.
# Approach 1
# legacy User class to import users from a vbulletion database
class LegacyUser < LegacyModel
# important! please change:
self.model = User # which is the new Rails model
self.table_name = "vbulletin_user" # the vbulletin table name
# attribue mapping: {:rails => :vbulletin}
self.attribute_mapping = {:legacy_id => :userid, :name => :username, :email => :email, :password => :email, :password_confirmation => :email} # map old vbulletin attrbute names to new rails attribute names {:rails => :vbulletin}
attr_accessor *self.attribute_mapping.values
# mysql-style output for an array of Ruby objects
#
# Usage:
# report(records) # displays report with all fields
# report(records, :field1, :field2, ...) # displays report with given fields
#
# Example:
# >> report(records, :id, :amount, :created_at)
# +------+-----------+--------------------------------+
# | id | amount | created_at |
plugin 'rspec', :git => 'git://github.com/dchelimsky/rspec.git'
plugin 'rspec-rails', :git => 'git://github.com/dchelimsky/rspec-rails.git'
plugin 'exception_notifier', :git => 'git://github.com/rails/exception_notification.git'
plugin 'asset_packager', :git => 'http://synthesis.sbecker.net/pages/asset_packager'
plugin 'make_resourceful', :git => 'git://github.com/hcatlin/make_resourceful.git'
plugin 'cucumber', :git => 'git://github.com/aslakhellesoy/cucumber.git'
plugin 'webrat', :git => 'git://github.com/brynary/webrat.git'
# gem 'mislav-will_paginate', :version => '~> 2.2.3', :lib => 'will_paginate', :source => 'http://gems.github.com'
# comes with:
# * working user registration/login via authlogic
# * rspec/cucumber/culerity for testing
# * thinkinG_sphinx configuration
# * german localization
# * capistrano deployment script
# * jquery and blueprint css set up
# TODO
# * add forgot password method
# * add cucucmber features for login/registration

Getting Started

Panda runs entirely within Amazon's Web Services, so before continuing you will need to sign up for an account and have access to EC2, S3 and SimpleDB services.

If this is the first time you've used EC2, you'll need to ensure you've setup certificates and local environment. Everything is described in Amazon's EC2 Getting Started Guide.

If you would like to run Panda on a different platform, please first follow the Local Installation Guide

Launch the AMI

/* Expanded form of a bookmarklet for extracting rev=canonical OR tinyurling a page */
(function(){
var url=document.location;
var links=document.getElementsByTagName('link');
var found=0;
for(var i = 0, l; l = links[i]; i++) {
if (l.getAttribute('rev') == 'canonical' || (/alternate short/).exec(l.getAttribute('rel'))) {
found=l.getAttribute('href');
break;
}
require 'rubygems'
require 'sinatra'
get '/' do
"Hello from Sinatra running on Java!"
end
require 'rubygems'
require 'xml' # libxml2 ruby bindings
# TABLE SCHEMA:
#create table flickr_shapes (id int not null auto_increment primary key, kind varchar(255), label varchar(255), woe_id int, min_lat decimal(20,17), min_lng decimal(20,17), max_lat decimal(20,17), max_lng decimal(20,17));
# USE:
#select * from flickr_shapes where 51.52830123901367 between min_lat and max_lat AND -0.0916564017534256 between min_lng and max_lng;
class MyCallbacks
include XML::SaxParser::Callbacks