Skip to content

Instantly share code, notes, and snippets.

<html>
<!-- http://docs.jquery.com/ -->
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
// we will add our javascript code here
$(document).ready(function() {
//Tag cloud selection logic
$("#tag_cloud li").click(function() {
#given the following models---------------------------
class Parent
has_many :children
end
class Child
belongs_to :parent #column: parent_id in the db
end
<<<<<<< HEAD
#Anything in here is what
#was in the branch you merged into
=======
#Anything in here is what
#was in the branch you merged from
>>>>>>> a-n-other-branch
#Small function to generate a comma delimited dictionary on a unix system
def gen_dictionary
f = open("| cat /usr/share/dict/words")
g = Array.new
while (foo = f.gets)
g << foo.strip
end
puts g.join(', ')
end
center = [500,500]
radius = 500
height = 100
width = 100
num_edge = 50
num_hour = 10
num_min = 10
length_hour = 300
#Subclassing Array instead of including Enumerable
class Core < Array
attr_reader :name
def initialize( name, data )
@name = name
self[0..-1] = data
end
#!/bin/bash
createdb NEW_DB
pg_restore -d NEW_DB BACKUP_FILE
# List of environments and their heroku git remotes
ENVIRONMENTS = {
:staging => 'myapp-staging',
:production => 'myapp-production'
}
namespace :deploy do
ENVIRONMENTS.keys.each do |env|
desc "Deploy to #{env}"
task env do
//
// Backbone.Rails.js
//
// Makes Backbone.js play nicely with the default Rails setup, i.e.,
// no need to set
// ActiveRecord::Base.include_root_in_json = false
// and build all of your models directly from `params` rather than
// `params[:model]`.
//
// Load this file after backbone.js and before your application JS.
@latentflip
latentflip / validations.rb
Created February 10, 2011 14:52
Fails validation, but the_model.errors will be empty.
class TheModel < ActiveRecord::Base
def before_validation_on_create
#do some stuff
setup_defaults
end
private
def setup_defaults
self.expense ||= true