This file contains 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
<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() { |
This file contains 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
#given the following models--------------------------- | |
class Parent | |
has_many :children | |
end | |
class Child | |
belongs_to :parent #column: parent_id in the db | |
end |
This file contains 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
<<<<<<< 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 |
This file contains 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
#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 |
This file contains 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
center = [500,500] | |
radius = 500 | |
height = 100 | |
width = 100 | |
num_edge = 50 | |
num_hour = 10 | |
num_min = 10 | |
length_hour = 300 |
This file contains 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
#Subclassing Array instead of including Enumerable | |
class Core < Array | |
attr_reader :name | |
def initialize( name, data ) | |
@name = name | |
self[0..-1] = data | |
end |
This file contains 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
#!/bin/bash | |
createdb NEW_DB | |
pg_restore -d NEW_DB BACKUP_FILE |
This file contains 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
# 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 |
This file contains 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
// | |
// 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. |
This file contains 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 TheModel < ActiveRecord::Base | |
def before_validation_on_create | |
#do some stuff | |
setup_defaults | |
end | |
private | |
def setup_defaults | |
self.expense ||= true |
OlderNewer