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
| [ruby] irb | |
| 2.0.0dev :001 > %w(abc def) | |
| => ["abc", "def"] | |
| 2.0.0dev :002 > %i(abc def) | |
| 2.0.0dev :003?> |
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 Foo | |
| def hello | |
| :regular_instance_method | |
| end | |
| end | |
| def singleton_class_for(obj) | |
| class << obj; self; 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 Test1 | |
| def self.bar | |
| :bar | |
| end | |
| end | |
| class Test2 < Test1 | |
| end | |
| Test2.bar # => :bar |
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
| RSpec.configure do |config| | |
| config.after do | |
| if example.exception && example.metadata[:type] == :request | |
| puts "current url: #{page.current_url}" | |
| puts "page source:\n\n #{page.source} \n\n" | |
| end | |
| 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 Office < ActiveRecord::Base | |
| end | |
| # .. for example .. | |
| o = Office.create(latitude: 32, longitude: -86) |
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
| hash = {:wtf => 'candy', |:wtf2 => 'chocolate'} | |
| *hit some keys* | |
| hash = {:wtf => 'candy', | |
| |:wtf2 => 'chocolate'} |
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 Ability | |
| include CanCan::Ability | |
| def initialize(user) | |
| # ... | |
| can :perform, EventStatusChange do |status_change| | |
| user.admin? || ["pending approval"].include?(status_change.new_status) | |
| 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
| ALTER TABLE ip_ranges add ip_range POLYGON NULL; | |
| UPDATE ip_ranges | |
| SET ip_range=Polygon( | |
| LineString( | |
| Point(ip_start, 1), | |
| Point(ip_start, 0), | |
| Point(ip_end, 0), | |
| Point(ip_end, 1), | |
| Point(ip_start, 1) | |
| ) |
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
| # A Backbone sync that sends along location information, if available | |
| Backbone = this.Backbone | |
| Backbone.locationSync = (method, model, options) -> | |
| options.data = { } unless options.data? | |
| navigator.geolocation.getCurrentPosition (position) -> | |
| options.data.latitude = position.coords.latitude | |
| options.data.longitude = position.coords.longitude |
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
| describe "#users", fakefs: true do | |
| def stub_etc_passwd | |
| FileUtils.mkdir("/etc") | |
| File.open("/etc/passwd", "w") do |f| | |
| f.puts("andy:*:100:100") | |
| f.puts("bob:*:101:102") | |
| end | |
| end | |
| it "reads /etc/passwd and returns user information" do |