Skip to content

Instantly share code, notes, and snippets.

#! /usr/bin/env ruby
require 'bundler/inline'
gemfile(true) do
source "https://rubygems.org"
gem 'rom-sql'
gem 'rom-repository'
gem 'sqlite3'
require 'bundler/inline'
gemfile(true) do
source "https://rubygems.org"
gem 'rom'
gem 'rom-sql'
gem 'sequel'
gem 'sqlite3'
end

Keybase proof

I hereby claim:

  • I am cflipse on github.
  • I am cflipse (https://keybase.io/cflipse) on keybase.
  • I have a public key whose fingerprint is 2588 47E5 91AD DA73 8A92 7A06 B9D0 8841 1798 4F07

To claim this, I am signing this object:

require 'bundler/inline'
gemfile(true) do
source 'https://rubygems.org'
gem 'rom', github: 'rom-rb/rom'
gem 'rom-sql', github: 'rom-rb/rom-sql'
gem 'rom-repository', github: 'rom-rb/rom-repository'
gem 'sqlite3'
end
#!/usr/bin/env ruby
require 'bundler/inline'
require 'json'
gemfile(:install) do
gem 'rom', '>= 2.0', github: 'rom-rb/rom', branch: 'master'
gem 'rom-http', github: 'rom-http-rb/rom-http', branch: 'master'
gem 'faraday'
end
require 'rom/memory'
class BlenderRelation < ROM::Relation[:memory]
repository :memory
register_as :blender
forward :join
end
class PostWithTagsMapper < ROM::Mapper
@cflipse
cflipse / dataset_pagination.rb
Last active August 29, 2015 14:15
pagination wrapper
require 'charlatan'
# A simple pagination wrapper that implements the handful of
# methods that Kaminari wants for displaying pagination.
#
# Currently requires implementing a `window` function in the
# relation as well. `limit().offeset()` filters are what make
# up that method.
class DatasetPagination
@cflipse
cflipse / migration.rb
Last active August 29, 2015 14:13
daily random shuffle
class WidgetShuffleMigration
def change
change_table :widgets do |t|
# used to store the result of a rand() function, which satisifies: 0 < rand() < 1
t.float :shuffle_order, index: true
end
end
end
require "active_model/lint"
require "test/unit/assertions"
shared_examples_for "ActiveModel" do
include ActiveModel::Lint::Tests
include Test::Unit::Assertions
before { @model = subject }
ActiveModel::Lint::Tests.public_instance_methods.map(&:to_s).grep(/^test/).each do |test|
@cflipse
cflipse / Post.rb
Last active October 1, 2019 15:56
External Validations using only ActiveModel
require 'active_model'
# Most of this is the basic boilerplate described in the docs for active_model/errors; ie, the bare minimum
# a class must have to use AM::Errors
class Post
extend ActiveModel::Naming
attr_reader :errors
attr_accessor :title, :author, :publication_date