Skip to content

Instantly share code, notes, and snippets.

View flash-gordon's full-sized avatar
🔪
Working on sharp tools

Nikita Shilnikov flash-gordon

🔪
Working on sharp tools
View GitHub Profile
#!/usr/bin/env ruby
require "rom-sql"
require "rom-repository"
require "byebug"
module Persistence
module Relations
class Configurations < ROM::Relation[:sql]
gateway :bonuses
Sequel.migration do
up do
create_table(:users) do
primary_key :id
String :first_name, null: false, limit: 100
String :last_name, null: false, limit: 100
String :middle_name, null: true, limit: 100
String :email, null: false, limit: 500
String :role, null: true, limit: 50
@flash-gordon
flash-gordon / env_validation.rb
Created September 18, 2016 10:14
ENV validation POC
require 'dry-validation'
class EnvValidation
class ENV
def inspect
ivs = instance_variables.each { |v| "#{v}=#{instance_variable_get(v)}" }.join(', ')
"ENV[#{ivs}]"
end
def to_s

Keybase proof

I hereby claim:

  • I am flash-gordon on github.
  • I am flashgordon (https://keybase.io/flashgordon) on keybase.
  • I have a public key whose fingerprint is 4171 2454 F1FB C02B 5846 950E E569 D1D6 4C40 E241

To claim this, I am signing this object:

@flash-gordon
flash-gordon / pg_inferrer.rb
Created September 7, 2016 13:12
custom inferrer
require 'rom/sql/types/pg'
module ROM
module SQL
class Schema
class PGInferrer < Inferrer
# define all pg specific logic here
end
end
end
Bundler.setup(:default, :benchmarks)
Bundler.require
require 'benchmark'
require 'benchmark/ips'
b = { b: :b }
Benchmark.ips do |x|
x.report('merge') { { a: :a }.merge(b) }
Bundler.setup(:default, :benchmarks)
Bundler.require
require 'benchmark'
require 'benchmark/ips'
ATTRS = ('a'..'z').to_a.map(&:to_sym).take(10)
class ManualStruct
class_eval(<<-RUBY)
require 'json'
require 'uri'
require 'net/http'
require 'rom'
require 'rom-http'
module Types
include Dry::Types.module
end
#!/usr/bin/env ruby
require 'rom-sql'
require 'rom/sql/commands/postgres'
conn = Sequel.connect('postgres://localhost/upsert_example')
conn.drop_table?(:quotes)
conn.create_table :quotes do
machine:
java:
version: openjdk7
environment:
RAILS_ENV: test
JRUBY_OPTS: -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-noverify -X-C -Xcompile.invokedynamic=false --1.9 -J-Xmx2g
dependencies:
cache_directories:
- '~/.rvm/rubies'