Skip to content

Instantly share code, notes, and snippets.

@lorennorman
lorennorman / gist:91403
Created April 7, 2009 19:02
My favorite Rails setup.
# My Rails 2.3 Template
# You can use it like this:
# rails your_app_name -m http://gist.github.com/91403.txt
# Plugins
plugin 'rspec', :git => 'git://github.com/dchelimsky/rspec.git'
plugin 'rspec-rails', :git => 'git://github.com/dchelimsky/rspec-rails.git'
plugin 'role_requirement', :git => 'git://github.com/lorennorman/role_requirement.git'
plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git'
plugin 'aasm', :git => 'git://github.com/rubyist/aasm.git'
@lorennorman
lorennorman / Basic Git
Created September 26, 2009 20:03
A Rails template for a bare bones, but checked in, install. Used this as a starting point and add your favorite gems, scripts, and libraries.
# Basic Rails project, default files cleaned up and checked into Git
# Partly taken from: http://github.com/jeremymcanally/rails-templates/blob/master/newgit.rb
# Use it like this:
# rails your_app_name -m http://gist.github.com/194395.txt
# rails:rm_tmp_dirs
["./tmp/pids", "./tmp/sessions", "./tmp/sockets", "./tmp/cache"].each do |f|
run("rmdir ./#{f}")
end
# STI Models
class Question < AR::Base; end # should never be instantiated
class YesNoQuestion < Question; end # should
class TextQuestion < Question; end # should
# etc...
# Form.rb (model)
accepts_nested_attributes_for :questions # except I don't want to instantiate Question!
# forms/edit.html.erb (view)
# Stolen from: http://railstips.org/blog/archives/2009/10/09/more-mongomapper-awesomeness/
class User
include MongoMapper::Document
many :posts
end
class Post
include MongoMapper::Document
<% semantic_form_for @model_name do |form| %>
<%= form.inputs %>
<%= form.buttons %>
<% end %>
// Watches the spec files for changes and reloads the Jasmine test runner
// Watches the source files for changes and auto-builds with Sprockets
// Rebuilds also trigger the tests
var SOURCE_DIR = "src";
var SOURCE_MAIN = SOURCE_DIR+'/application.js';
var BUILD_DIR = 'build';
var BUILD_MAIN = BUILD_DIR+'/application.js';
var SPEC_DIR = 'spec';
var WATCH_INTERVAL = 5000;
// Let's specify some Behaviors, first
// Gotta have x,y coords!
var Positionable =
{ x: 0
, y: 0 // phear my inverted c0mmaZ!
};
// Mmmm, delicious physics
var Physical =
// Create a quick singleton object to represent our mock mobile app
var App = {};
// Our App has many states and state-change callbacks
App.currentState = null;
App.STATES = [
{name: 'main_menu'},
{name: 'loading'},
{
name: 'list_doables',
onEnter: function()
@lorennorman
lorennorman / worldmap.scss
Created July 27, 2011 01:59
100ish lines of scss that drive the worldmap page for http://scoutmob.com
@import "vendor/960";
@import "shared/position_and_dimensions";
$cities-sprite-dimensions: true;
@import "worldmap/cities/*.png";
@include all-cities-sprites;
$links-sprite-dimensions: true;
@import "worldmap/links/*.png";
@include all-links-sprites;
@lorennorman
lorennorman / hex_grid.scad
Created December 29, 2011 17:02
learning me some openscad by playing with a hexagonal grid
module hexagon(radius)
{
circle(r=radius,$fn=6);
}
module shell(radius)
{
difference()
{
hexagon(radius*1.2); // base