Skip to content

Instantly share code, notes, and snippets.

View AMHOL's full-sized avatar

Andy Holland AMHOL

  • Manchester, UK
  • 09:44 (UTC +01:00)
View GitHub Profile
@ef2k
ef2k / usr_bin_subl.sh
Last active August 10, 2016 20:16
Detach sublime from terminal (/usr/bin/subl)
#!/bin/bash
# Detach sublime from terminal
nohup /opt/sublime_text_2/sublime_text --class=sublime-text-2 "$@" 2>/dev/null &
@davidpelaez
davidpelaez / custom_processor.rb
Created March 3, 2016 16:10
How to add custom steps to rom-mapper default Transproc processor. Useful to enhance the mapper with custom functionality and data transformations, e.g: lazy evaluation as presented in http://solnic.eu/2015/07/15/importing-data-with-rom-and-transproc.html
module Dataops
module Processors
class EnhancedAttributes < TransprocWithHook
BlockWrapper = Struct.new(:block) do
def call(*args)
self.block.call *args
end
end
@solnic
solnic / rom-repo-crud.rb
Last active April 8, 2016 15:02
Upcoming rom-repository command support
require "rom-repository"
require "rom-sql"
config = ROM::Configuration.new(:sql, 'postgres://localhost/rom_repository')
class Users < ROM::Relation[:sql]
def by_id(id)
where(id: id)
end
end
@keathley
keathley / dry_monad_usage.md
Last active March 14, 2024 15:16
A description of how to take advantage of the dry-monad gem.

How we're using dry-monad

Imagine that we have an application where user's have a location. We want to find the weather for their current location using an external service call. We want to provide this functionality in a json api. A basic implementation might look like this.

def create
 user = User.find(params[:id])
@kule
kule / mini_rspec.rb
Created September 11, 2018 09:37
Simplified example of how rspec works
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'colorize'
end
class MatcherInterface
def initialize(some_object)
@some_object = some_object