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 TakeNoArgs | |
| def say_hi | |
| puts "hello" | |
| end | |
| end | |
| TakeNoArgs.new.say_hi #=> hello | |
| TakeNoArgs.new( ['how are you?'] ).say_hi #=> hello | |
| TakeNoArgs.new( {:args => 13}, 12, "hello" ).say_hi #=> hello |
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
| puts %W( | |
| ADDITIONAL_LOAD_PATHS | |
| ARGF | |
| ARGV | |
| ActionController | |
| ActionView | |
| ActiveRecord | |
| ArgumentError | |
| Array | |
| BasicSocket |
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
| [1,2,3,4,5,6,7,8,9,0, #numbers | |
| '',"",'hi',"hello", #strings | |
| :sym, /hi/, 1.324, #symbol, regex, float | |
| [nil],[],[1],[''],['hi'], #arrays | |
| {},{:hi => ''},{'hi' => 'hello'}, #hashes | |
| true,false,nil ].map { |item| !!item } |
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
| > ps | ruby -e 'require "csv"; puts CSV.generate { |csv| ARGF.each_line { |line| csv << line.split(/\s+/).reject(&:empty?) }}' | |
| PID,TTY,TIME,CMD | |
| 62541,ttys000,0:00.71,-zsh | |
| 59313,ttys004,0:01.23,-zsh | |
| 63830,ttys004,0:00.00,ruby,-e,require,"""csv"";",puts,CSV.generate,{,|csv|,ARGF.each_line,{,|line|,csv,<<,line.split(/\s+/).reject(&:empty?),}} |
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
| module HStoreProperties | |
| extend self | |
| def boolean_h_store_fields_for(property_names) | |
| property_names.each do |key| | |
| attr_accessible key | |
| scope "has_#{key}", lambda { |value| where('properties @> (? => ?)', key, value) } | |
| define_method(key) do | |
| properties && properties[key].to_bool | |
| 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
| records = MyArray.new | |
| LocalEvaluation.for(id).map { |evaluation| records << evaluation } | |
| OfficialEvaluation.for(id).map { |evaluation| records << evaluation } | |
| return sort(records) || [] | |
| sort(MyArray.new( | |
| LocalEvaluation.for(id).concat(OfficialEvaluation.for(id)) | |
| )) || [] |
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 Paper | |
| Scopes.define_for_last_year(self, :due_date) | |
| end | |
| class Book | |
| Scopes.define_for_last_year(self, :release_date) | |
| end | |
| class Publication | |
| Scopes.define_for_last_year(self, :pub_date) |
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 String | |
| def to_proc | |
| Proc.new { self } | |
| end | |
| end | |
| say &"Hello, World!" | |
| # => Hello, World! | |
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
| function example() { | |
| var myVar = 1; | |
| if(myVar === 1) { | |
| var myVar = 2; | |
| } | |
| return myVar; | |
| } | |
| function declared() { | |
| return "declared function"; |
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
| <?xml version="1.0" encoding="utf-8"?> | |
| <project> | |
| <!-- <meta /> | |
| Use meta nodes to set metadata for your application. The description is ignored | |
| on most targets, but is useful for packaging like Chrome Apps or Opera Widgets. | |
| For compatibility with Android and webOS, the package name must include at least |