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 = "apache | |
| batch_name | |
| datetime_with_seconds | |
| download_csv_datetime | |
| download_csv_timezone | |
| expiration | |
| mmdd | |
| mmyy | |
| hhmmss | |
| iso8601_milliseconds |
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 Array | |
| def square! | |
| self.map! {|i| i ** 2} | |
| end | |
| end | |
| a = [1, 2, 3] | |
| a.square! | |
| if a == [1, 4, 9] |
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 OrbitalCoordinate | |
| def initalize(lat, long, altit) | |
| @lat = lat | |
| @long = long | |
| @altit = altit | |
| # @veloc = veloc # meters per second | |
| # how many seconds it will take to get to another point. | |
| OrbitalVelocity..new(sec, OrbitalCoordinate) | |
| 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
| irb(main):015:0> (0..4).each_with_index.map.inject(0) {|i, (j, k)| puts "i: #{i} j: #{j} k: #{k}" ; i } | |
| i: 0 j: 0 k: 0 | |
| i: 0 j: 1 k: 1 | |
| i: 0 j: 2 k: 2 | |
| i: 0 j: 3 k: 3 | |
| i: 0 j: 4 k: 4 | |
| => 0 | |
| irb(main):016: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
| /* PayPal Shop with Apps Script */ | |
| /* Written by Amit Agarwal - ctrlq.org */ | |
| /* http://www.labnol.org/internet/sell-digital-products-online/28554/ */ | |
| PAYPAL = [ | |
| ["product-001", "useful-websites-book.pdf"], | |
| ["product-002", "linux-training-course.mp4"], |
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 Foo | |
| def bar | |
| "stuff" | |
| end | |
| end | |
| World Foo # world-accessible | |
| # pry(main)> method(:World).owner | |
| # => Cucumber::RbSupport::RbDsl | |
| # http://www.rubydoc.info/github/cucumber/cucumber/Cucumber/RbSupport/RbDsl: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
| # Only run the following code when this file is the main file being run | |
| # instead of having been required or loaded by another file | |
| if __FILE__==$0 | |
| # Find the parent directory of this file and add it to the front | |
| # of the list of locations to look in when using require | |
| $:.unshift File.expand_path("../../", __FILE__) | |
| end | |
| # http://stackoverflow.com/questions/4687680/what-does-if-file-0-mean-in-ruby |
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 initialize out=STDOUT | |
| $stdout = out | |
| end | |
| end | |
| Foo.new(StringIO.new) |
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 Fridge < ActiveRecord::Base | |
| has_many :soda_ownerships, dependent: :destroy | |
| has_many :cokes, through: :soda_ownerships, source: :owner, source_type: 'Coke' | |
| has_many :sprites, through: :soda_ownerships, source: :owner, source_type: 'Sprite' | |
| end | |
| class SodaOwnership < ActiveRecord::Base | |
| belongs_to :fridge | |
| belongs_to :owner, polymorphic: true | |
| belongs_to :coke, class_name: 'owner_type', foreign_key: 'owner_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
| require 'ostruct' | |
| require 'yaml' | |
| require 'erb' | |
| require 'active_support/core_ext/class/attribute' | |
| require 'active_support/core_ext/hash/indifferent_access' | |
| require 'active_support/core_ext/hash/deep_merge' | |
| require File.expand_path(File.dirname(__FILE__)+'/../config/initializers/openstruct_additions') | |
| class AppConfig | |
| class_attribute :config |