I hereby claim:
- I am mberlanda on github.
- I am mberlanda (https://keybase.io/mberlanda) on keybase.
- I have a public key ASAmHgHzX-F6f6Q2QgGnrbqQLRJfeaXgCw54YdMeRyJuQwo
To claim this, I am signing this object:
require 'rails_helper' | |
require 'representable/json' | |
require 'representable/json/collection' | |
class Song < OpenStruct | |
end | |
# Ex. 1 using standalone collections | |
class SongRepresenter < Representable::Decorator | |
include Representable::JSON |
# source: https://rosettacode.org/wiki/Sorting_algorithms/Quicksort#Ruby | |
class Array | |
def quick_sort | |
h, *t = self | |
h ? t.partition { |e| e < h }.inject { |l, r| l.quick_sort + [h] + r.quick_sort } : [] | |
end | |
end |
# https://it.wikipedia.org/wiki/Partita_IVA#Struttura_della_partita_IVA | |
module ChecksumCalculation | |
def calculate(ary) | |
(10 - t(ary)) % 10 | |
end | |
private | |
def t(ary) | |
odd, even = separate_odd_even(ary) |
class NewtonsMethod | |
def initialize(f_proc, f_prime_proc) | |
@fp = f_proc | |
@fpp = f_prime_proc | |
end | |
def apply(x) | |
x - (@fp.call(x) / (@fpp.call(x) * 1.0)) | |
end |
# https://en.wikipedia.org/wiki/Riemann_sum | |
class RiemannSum | |
def initialize(f, v_start, v_end, n_step) | |
@f = f | |
@v_start = v_start | |
@v_end = v_end | |
@n_step = n_step | |
@step_size = (v_end - v_start) / (n_step * 1.0) | |
end |
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use 5.014; | |
=head1 NAME | |
Rails Assets Coverage |
require 'bundler' | |
lockfile = Bundler::LockfileParser.new(Bundler.read_file('Gemfile.lock')) | |
specs = lockfile.specs | |
gems_hash = Hash.new.tap do |h| | |
specs.each do |s| | |
h[s.name] = { | |
spec: s, | |
dependencies: s.dependencies.map(&:name) |
I hereby claim:
To claim this, I am signing this object:
While developing a serialization gem I needed to compare my current code with previous gem versions.
(Un)fortunately bundler
does not allow to install several versions of the same gem to prevent conflicts on class names.
The purpose of this script is to wrap a gem into a namespace/module named.
You should set in the main script:
#!/usr/bin/env bash | |
set -euo pipefail | |
IFS=$'\n\t' | |
PROJECT_DIR=$(git rev-parse --show-toplevel) | |
# Base branch for rebasing | |
BASE_BRANCH="master" | |
# Enter here the name of the branches to rebase |