$ brew install cloc
$ bundle install
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 "sequel" | |
DB = Sequel.postgres("arel") | |
DB.create_table!(:movies) { primary_key :id } | |
class Movie < Sequel::Model | |
end | |
# Asterisk (I agree this one isn't ideal) | |
Movie.select{count{}.*} # SELECT count(*) FROM "movies" |
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 "active_record" | |
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") | |
ActiveRecord::Migration.class_eval do | |
create_table(:records) do |t| | |
t.string :column | |
end | |
end | |
data = 50_000.times.map { |i| Hash[column: "Column #{i}"] } |
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 "open-uri" | |
require "net/http" | |
Error = Class.new(StandardError) | |
DOWNLOAD_ERRORS = [ | |
SocketError, | |
OpenURI::HTTPError, | |
RuntimeError, | |
URI::InvalidURIError, |
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 "active_record" | |
ActiveRecord::Base.establish_connection("postgres:///db") | |
insert = Arel::Nodes::InsertStatement.new | |
insert.relation = Arel::Table.new(:movies) | |
insert.columns = hash.keys.map { |k| Arel::Table.new(:movies)[k] } | |
insert.values = Arel::Nodes::Values.new(hash.values, insert.columns) | |
ActiveRecord::Base.connection.execute(insert.to_sql) |
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
############ | |
# GROUPING # | |
############ | |
def Given(*) end | |
Given(/There (is|are) some links?/) { } # ERROR | |
Given(/There (?:is|are) some links?/) { } |
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 "mail" | |
Mail.defaults do | |
delivery_method :smtp, | |
address: "smtp.gmail.com", | |
port: 587, | |
user_name: ENV["GMAIL_EMAIL"], | |
password: ENV["GMAIL_PASSWORD"], | |
authentication: "plain", | |
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 "active_record" | |
ActiveRecord::Base.establish_connection('postgres:///testing') | |
ActiveRecord::Migration.verbose = false | |
ActiveRecord::Migration.class_eval do | |
create_table :played_quizzes, force: true do |t| | |
t.integer :player_ids, array: true | |
t.json :quiz_snapshot | |
end |