# change mirror to ubuntu.osuosl.org first
sudo apt-get update
sudo apt-get install build-essential libreadline-dev libssl-dev zlib1g-dev libxml2-dev libxslt-dev
CREATE AGGREGATE vector_sum ( | |
sfunc = AXH_Vector_Sum, | |
basetype = int[], | |
stype = int[], | |
initcond = '{0}' | |
); | |
DROP FUNCTION IF EXISTS AXH_Vector_Sum(int[], int[]); | |
CREATE OR REPLACE FUNCTION AXH_Vector_Sum(int[], int[]) | |
RETURNS int[] AS $$ |
CREATE AGGREGATE vector_sum ( | |
sfunc = AXH_Vector_Sum, | |
basetype = int[], | |
stype = int[], | |
initcond = '{0}' | |
); | |
DROP FUNCTION IF EXISTS AXH_Vector_Sum(int[], int[]); | |
CREATE OR REPLACE FUNCTION AXH_Vector_Sum(int[], int[]) | |
RETURNS int[] AS $$ |
# lib/tasks/db.rake | |
namespace :db do | |
desc "Dumps the database to db/APP_NAME.dump" | |
task :dump => :environment do | |
cmd = nil | |
with_config do |app, host, db, user| | |
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump" | |
end | |
puts cmd |
class Dog | |
attr_writer :name | |
def initialize(name) | |
@name = name | |
end | |
def bark | |
puts "patrick" | |
end |
class SomeModel | |
include Mongoid::Document | |
field :date, :type => Date | |
validates_presence_of :date | |
def date=(value) | |
begin | |
date_parsed = value.to_date | |
write_attribute :date, date_parsed |
(function($){ | |
// | |
//-------------------------------------- Model : Image | |
// | |
Image = Backbone.Model.extend({ | |
defaults: { | |
'delete' : false | |
} | |
}); | |
class AccountSignup | |
def self.new(warden, acccount_params) | |
account = Subscribem::Account.create(account_params) | |
account.create_schema | |
UserSignup.new(warden, account, account.owner) | |
end | |
end | |
Backbone.Model::nestCollection = (attributeName, nestedCollection) -> | |
#setup nested references | |
for item, i in nestedCollection | |
@attributes[attributeName][i] = nestedCollection.at(i).attributes | |
#create empty arrays if none | |
nestedCollection.bind 'add', (initiative) => | |
if !@get(attributeName) | |
@attributes[attributeName] = [] | |
@get(attributeName).push(initiative.attributes) |
function nestCollection(model, attributeName, nestedCollection) { | |
//setup nested references | |
for (var i = 0; i < nestedCollection.length; i++) { | |
model.attributes[attributeName][i] = nestedCollection.at(i).attributes; | |
} | |
//create empty arrays if none | |
nestedCollection.bind('add', function (initiative) { | |
if (!model.get(attributeName)) { | |
model.attributes[attributeName] = []; |