This file contains hidden or 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 = {} | |
| 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; | |
| }); |
This file contains hidden or 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
| 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) } |
This file contains hidden or 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
| 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) |
This file contains hidden or 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
| # 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 npm@0.2.16 | |
| npm info using node@v0.3.8-pre | |
| npm info preinstall coffee-script@1.0.0 | |
| npm info install coffee-script@1.0.0 | |
| npm info postinstall coffee-script@1.0.0 |
This file contains hidden or 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
| create_table "parents", :force => true do |t| | |
| t.column "name", :string | |
| t.column "type", :string | |
| end | |
| ### | |
| class Parent < ActiveRecord::Base |
This file contains hidden or 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
| # 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 |
This file contains hidden or 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
| 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) |
This file contains hidden or 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 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 |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| 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 |
OlderNewer