Skip to content

Instantly share code, notes, and snippets.

@franckverrot
franckverrot / pipeline-operator.rb
Last active September 23, 2015 11:21
Pipeline operator in Ruby
# mul_x_y :: [Fixnum, Fixnum] -> Fixnum
mul_x_y = ->(x, y) { x * y }
# adder :: Fixnum -> (Fixnum -> Fixnum)
adder = ->(base) {
->(input) { input + base }
}
# add_two :: Fixnum -> Fixnum
add_two = adder[2]
@endash
endash / __.markdown
Last active October 20, 2015 19:28
Ruby Object Mapper configuration

N.B. This is a strawman proposal This is primarily based on the stand-alone use-case and not part of any framework integration. As such, there are possibly edge or corner cases not taken into account. That said, this is mostly shifting class boundaries around a bit and clarifying semantics, rather than modifying the underlying logic.

The main context here is present-day use of Environment.new, not the global ROM.setup.

Very basic, slapdash first cut at a refactor: https://github.com/endash/rom/tree/rework-env (this really just served to test that the existing code could be re-arranged as intended and still work, not as a genuine attempt at a refactor).

Current issues

Issue 1: We instantiate Environment, but Environment is throw-away. We actually want the Container at the end, in all cases, so that we can get at relations, commands, etc. We even access the Container via Environment#env, so users are encouraged to mentally conflate the two. Environment is, essentially, a sin

@carlisia
carlisia / rom-references
Last active January 8, 2019 10:23
ROM - References for creating a custom adapter
We couldn’t find that file to show.
@maetl
maetl / gist:4542fc2390eb8701284e
Last active September 30, 2015 21:54
Using transproc to compose various hash transformations and mappings
require 'transproc/all'
require 'addressable/uri'
##
# Convert string keys to symbols
#
transform = Transproc(:symbolize_keys)
data = {
'name' => 'Mark Rickerby',
@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
@solnic
solnic / gist:9b9deedd7891e2c7ac83
Last active August 19, 2016 08:46
Virtus pg array type for Sequel
module Virtus
class PGArray < Attribute
primitive Sequel::Postgres::PGArray
def primitive
options[:primitive]
end
def coerce(value)
Sequel.pg_array(value)
@jodosha
jodosha / Gemfile
Last active December 9, 2020 15:09
Full stack Lotus application example
source 'https://rubygems.org'
gem 'rake'
gem 'lotus-router'
gem 'lotus-controller'
gem 'lotus-view'
group :test do
gem 'rspec'
gem 'capybara'
require 'axiom-schema'
# A schema (definition) is pure RA, no RDMBS
# concepts are in the mix. Those are only
# added with Axiom::Database objects shown
# further below. Even renaming of attributes
# is not done at this level. It's database
# business. Internally, this is implemented
# by performing a #rename op on an axiom
# relation tho.
@kjellski
kjellski / gitorious_resque_debug_doc.md
Created November 28, 2013 13:20
gitorious documentation improvement for resque debugging...

debugging in gitorious

In case you're experiencing any errors or unexpected behaviour, these are stept to follow in order to narrow down the problem. The goal is to get the most out of your system that would help the developers to identify the problem and help you fixing your problem.

is the problem reproducable?

This is the most important question you should be able to answer. If not, it's really hard to help. If it is not happening all the time, more like "every now and then", try to document what happened before, each time something unexpected happens, write it down. Collects all informations arround the event that should succeed, but does not.

Try to answer these questions:

What steps will reproduce the problem?

module Calculate
attr_accessor :num1
attr_accessor :num2
def calculate
self.!
end
end
class Arithmetic < Module