// jQuery
$(document).ready(function() {
// code
})
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
| group :production do | |
| gem 'unicorn' | |
| # Enable gzip compression on heroku, but don't compress images. | |
| gem 'heroku-deflater' | |
| # Heroku injects it if it's not in there already | |
| gem 'rails_12factor' | |
| 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
| sentence = "there is a wild rose" | |
| letters = sentence.gsub(' ','').split(//) |
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 Object | |
| def try_chain(*a) | |
| a.inject(self){ |object, method| object.try(method.to_sym) } | |
| 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
| mymodule { | |
| @at-root { | |
| .#{&}-header { ... } | |
| .#{&}-footer { ... } | |
| .#{&}-body { | |
| a { ... } | |
| span { ... } | |
| p { ... } | |
| } | |
| } |
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
| ## INHERIT from a base class | |
| # ----------------------------------------- | |
| class Product < ActiveRecord::Base | |
| belongs_to :category | |
| def self.lookup(item_code) | |
| where(:item_code => item_code).first | |
| 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
| class SelfMaker | |
| def yet_what_is_self? | |
| self.class.class_eval do | |
| mirror(self, "Inside class_eval of SelfMaker#yet_what_is_self?") | |
| end | |
| instance_eval do | |
| mirror(self, "Inside instance_eval of SelfMaker#yet_what_is_self?") | |
| 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
| $VERBOSE = nil | |
| require File.expand_path('../rooby', __FILE__) | |
| Person = Rooby::Class.new 'Person' do | |
| define :initialize do |name| | |
| @name = name | |
| end | |
| define :name do |
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 Attachment < ActiveRecord::Base | |
| belongs_to :attachable, :polymorphic => true | |
| mount_uploader :item, AttachmentUploader | |
| # background the storage of files to AWS and processing | |
| # makes for fast uploads! | |
| store_in_background :item | |
| attr_accessible :item | |
| before_save :update_attachment_attributes |
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
| # Here, I am define a "module" with name Ma. I also define two methods. One without "self." | |
| # and one with. See, later on, what happens when I "include" and what happens when I "extend" | |
| # the "module" within a "class". | |
| # | |
| module Ma | |
| # I will be able to make this method an instance or a class method of a class. | |
| # It depends whether I will "include" or "extend" the module in the class. | |
| # Note that this method, I cannot call it directly on Ma. In order for this method | |
| # to be useful, I have to include or extend this module within a class. | |
| # |