$ brew install cloc
$ bundle install
This file contains 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 |
This file contains 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 "roda" | |
require "sequel" | |
require "rack/test" | |
require "json" | |
DB = Sequel.sqlite | |
DB.create_table :accounts do | |
primary_key :id | |
String :status_id, default: 1, null: false | |
String :email, null: false |
This file contains 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 ApplicationController < ActionController:Base | |
extend ControllerMacros | |
end |
This file contains 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 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
source "https://rubygems.org" | |
gem "roda" | |
gem "http", "~> 3.3" | |
gem "rest-client" | |
gem "httparty" |
This file contains 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 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
width, imagemagick, libvips | |
1000, 0.129, 0.045 | |
1500, 0.190, 0.067 | |
2000, 0.276, 0.054 | |
2500, 0.380, 0.068 | |
3000, 0.498, 0.085 |
This file contains 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 "mongoid" | |
require "shrine" | |
require "shrine/storage/memory" | |
require "stringio" | |
Mongoid.configure do |config| | |
config.clients.default = { hosts: ['localhost:27017'], database: 'my_db' } | |
config.log_level = :debug | |
end |
This file contains 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 ApplicationController < ActionController::Base | |
private | |
def stream_body(async: false, **options, &block) | |
self.status ||= 200 | |
self.headers["Cache-Control"] = "no-cache" | |
self.headers.delete("Content-Length") | |
stream_class = async ? AsyncStream : Stream |
NewerOlder