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 do_bulk_creation # Controller action called from request | |
| prize = Prize.find_by_id(params[:code][:prize_id]) | |
| codes = params[:code][:codes].split("\r\n").each{ |c| c.strip } | |
| if bulk_creation_valid?(prize, codes) | |
| perform_bulk_creation(prize, codes) | |
| else | |
| set_bulk_creation_error(prize, codes) | |
| @bulk = Code.new(params[:code]) | |
| render :action => :bulk_create | |
| 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
| field :name | |
| accessible | |
| validates :presence do | |
| message "please provide a name" | |
| end | |
| end | |
| field :email | |
| accessible | |
| validates :format 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 Duck | |
| def get_angry_tubbo | |
| self.quack | |
| end | |
| def get_angry_everyone_else_in_the_world | |
| quack | |
| end | |
| def quack |
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
| # my controller | |
| def create | |
| @uid = Uid.find_by(number: uid_params[:number]) | |
| if @uid | |
| update | |
| else | |
| @uid = Uid.new(uid_params) | |
| if @uid.save | |
| puts "Uid is #{@uid.inspect}" |
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 'cinch' | |
| require 'tweetstream' | |
| require 'pry' | |
| require 'pp' | |
| FOLLOWED_USERS = [595112123,710713526,1695958922] # Array of twitter ID's to follow | |
| TweetStream.configure do |config| | |
| config.consumer_key = 'YOUR-CONSUMER-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
| require 'rubygems' | |
| require 'data_mapper' | |
| require 'nokogiri' | |
| # Connect to database | |
| DataMapper.setup(:default, 'mysql://root@localhost/mpuk') | |
| class Event | |
| include DataMapper::Resource | |
| property :id, Serial |
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 'spec_helper' | |
| class FakeOrder | |
| include ActiveModel::Validations | |
| attr_accessor :site_ids, :user_id | |
| validate :validate_at_least_one_site_chosen | |
| validates_presence_of :user_id | |
| def validate_at_least_one_site_chosen | |
| errors.add(:site, "please choose at least one site") |
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 SimpleDelegator | |
| def delegation_chain | |
| [self].tap do |output| | |
| object = self | |
| while object.respond_to?("__getobj__") | |
| object = object.__getobj__ | |
| output << object | |
| 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
| namespace :deploy do | |
| before :restart, :tag do | |
| on roles(:app) do | |
| within "#{deploy_to}/repo" do | |
| execute :git, "tag -f deployed-to-#{fetch(:stage)}" | |
| begin | |
| execute :git, "remote add upstream #{fetch(:repo_url)}" | |
| rescue | |
| # The remote might already exist. We don't care if it does. | |
| 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 'rspec/matchers' | |
| module Suite | |
| class Table < Struct.new(:table) | |
| def rows | |
| @rows ||= table.all('tbody tr').map do |tr| | |
| tr.all('td').map(&:text) | |
| end | |
| end | |
| end |