Skip to content

Instantly share code, notes, and snippets.

View rramsden's full-sized avatar
♨️
Keep On Keeping On

Richard Ramsden rramsden

♨️
Keep On Keeping On
View GitHub Profile
@rramsden
rramsden / gist:777176
Created January 13, 2011 00:37
nested arguments in javascript
Class = {}
Class.new = function(object) { return Class.extend({}, object); }
Class.extend = function(parent, self) { // child = this
return (function() {
self.super = function() {
self.parent = parent(arguments);
}
self.initialize.apply(self, arguments);
return self;
});
require 'yaml'
require 'parslet'
module Prolog
include Parslet
rule(:collection) { statement.repeat.as(:collection) }
rule(:statement) { ((headed|headless) >> str('.') >> newline?).as(:statement) }
rule(:headed) { (structure >> space? >> str(':-') >> space? >> conjunction).as(:headed) }
require 'rainbow'
puts "enter a number"
mod = Integer(gets)
(0..mod-1).each do |i|
row = ""
(0..mod-1).each do |j|
if ((j * i) % mod) == 1
row += " #{(j * i) % mod}".ljust(3).color(:red)
# node version
v0.3.8-pre
rramsden@rramsden-laptop:~$ npm install coffee-script
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info preinstall [email protected]
npm info install [email protected]
npm info postinstall [email protected]
create_table "parents", :force => true do |t|
t.column "name", :string
t.column "type", :string
end
###
class Parent < ActiveRecord::Base
# RAILS 2.3.4
ruby-1.8.7-p302 > Child.all.size
=> 4
ruby-1.8.7-p302 > SubChild.all.size
=> 5
ruby-1.8.7-p302 > Child.all.size
=> 9
ruby-1.8.7-p302 >
# RAILS 3
abstract (1.0.0)
actionmailer (2.3.4)
actionpack (3.0.3, 2.3.4)
activemodel (3.0.3)
activerecord (2.3.4)
activeresource (3.0.3, 2.3.4)
activesupport (3.0.3, 2.3.4)
adzap-validates_timeliness (2.0.0)
beanstalk-client (1.1.0)
bterlson-reddit (0.3.0)
class Website < ActiveRecord::Base
has_many :redirects
end
class Redirect < ActiveRecord::Base
def self.factory_build(attributes)
# how do i access the primary_key of my Website
# when I call @website.redirects.factory_build(...)
end
end
copy_from = Partner.find_by_name("SomePartner")
partners = Partner.all - [copy_from]
partners.each do |partner|
copy_from.blacklists.each{|x| y = x.clone; y.partner_id = partner.id; }
end
TODO:
create hooks for updates to rails project CHANGELOG's to hook into libnotify + growl
https://github.com/rails/rails/blob/master/actionpack/CHANGELOG
https://github.com/rails/rails/blob/master/activesupport/CHANGELOG
https://github.com/rails/rails/blob/master/activerecord/CHANGELOG
https://github.com/rails/rails/blob/master/activemodel/CHANGELOG
https://github.com/rails/rails/blob/master/actionmailer/CHANGELOG
https://github.com/rails/rails/blob/master/activeresource/CHANGELOG