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 RetrieverForm | |
| include ActiveModel::Conversion | |
| include ActiveModel::Validations | |
| validate :existance_of_email | |
| def initialize(attributes = {}) | |
| @email = attributes[:email] | |
| 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
| require 'heroku-api' | |
| require 'tmpdir' | |
| branch = '' | |
| git_url = '' | |
| heroku_host = '' | |
| heroku_key = '' | |
| app_name = "t8y-#{branch.downcase.gsub('_', '-').gsub(/[^a-z0-9\-]/, '')}" | |
| heroku = Heroku::API.new(api_key: heroku_key) |
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
| def hash2openstruct(attributes) | |
| attributes = attributes.reduce({}) do |attributes, (name, value)| | |
| if value.is_a?(Hash) | |
| value = hash2openstruct(value) | |
| elsif value.is_a?(Array) | |
| value = value.map { |v| hash2openstruct(v) } | |
| end | |
| attributes[name] = value | |
| attributes | |
| 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
| require 'ostruct' | |
| # ClosedStruct is similar to OpenStruct, except: | |
| # | |
| # * Immutable. Cannot be changed after insantiation. | |
| # * Raises NoMethodError on undefined attributes instead of returning nil. | |
| # | |
| # Example: | |
| # struct = ClosedStruct.new do |attributes| | |
| # attributes.name1 = 'value1' |
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 Hook | |
| attr_reader :payload | |
| def initialize(payload) | |
| @payload = payload | |
| end | |
| def operation_attributes | |
| send(:"#{action}_operation_attributes") | |
| 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
| #!/usr/bin/env ruby | |
| require_relative '../config/boot' | |
| require_relative '../config/environment' | |
| require 'delayed/command' | |
| Delayed::Command.new(ARGV).daemonize |
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
| # RecursiveClosedStruct is similar to OpenStruct, except: | |
| # | |
| # * Immutable. Cannot be changed after instantiation. | |
| # * Raises NoMethodError on undefined methods instead of returning nil. | |
| # * Recursively coerces descendants into a RecursiveClosedStruct. | |
| # | |
| # NoMethodError example: | |
| # struct = RecursiveClosedStruct.new(key1: "value") | |
| # struct.key1 # => "value" | |
| # struct.key2 # => NoMethodError |
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 ViewController | |
| include TableSection | |
| def numberOfSectionsInTableView(tableView) | |
| 2 | |
| end | |
| def numberOfRowsInSection0(tableView) | |
| @data.count | |
| 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
| // Create a function on the controller that computes propA | |
| // and popC. | |
| function ModelCtrl($scope) { | |
| $scope.models = [{propA: 'A', probB: 'B'}]; | |
| $scope.propC = function(model) { | |
| return model.propA + model.propB; | |
| } | |
| } |
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
| #!/usr/bin/env ruby | |
| ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __FILE__) | |
| require 'bundler/setup' | |
| require 'sequel' | |
| if ARGV.size != 2 | |
| puts "usage: #{__FILE__} <DATA_PATH> <DB_PATH>" | |
| puts " #{__FILE__} ~/Desktop/sites.txt ~/Desktop/database.sqlite" | |
| abort |