Skip to content

Instantly share code, notes, and snippets.

View mberlanda's full-sized avatar

Mauro Berlanda mberlanda

  • Amazon
  • Madrid
  • 19:22 (UTC +02:00)
View GitHub Profile
@mberlanda
mberlanda / JoinableQueueWrapper.py
Created June 17, 2022 22:24
Sample demonstration of a wrapper around a mp.JoinableQueue enforcing message deduplication via a mp.Manager and a mp.Lock.
import multiprocessing as mp
import os
import time
from dataclasses import dataclass
from datetime import datetime
@dataclass
class JobItem:
x: int
y: int
@mberlanda
mberlanda / create_session.lua
Created October 8, 2019 15:09
Sample session invalidation management with redis and lua
-------- BEGIN argv ---------
local foo = ARGV[1] -- foo
local bar = ARGV[2] -- foo:bar
local baz = ARGV[3] -- foo:baz
local val = ARGV[4]
local ttl = ARGV[5]
-------- END argv ---------
local key = "sessions::" .. foo .. "::" .. bar .. "::" .. baz
@mberlanda
mberlanda / 8queens.lua
Created July 7, 2019 15:45
Eight Queens Puzzle in Lua
N = 8 -- board size
function isplaceok(a, n, c)
for i = 1, n - 1 do -- for each queen already placed
if (a[i] == c) or -- same column?
(a[i] - i == c - n) or -- same diagonal?
(a[i] + i == c + n) then -- same diagonal?
return false -- place can be attacked
end
end
@mberlanda
mberlanda / RUBY_CHANGES.md
Last active June 12, 2019 09:32
Provide some insights about the recent ruby changes and features
@mberlanda
mberlanda / rubocop_cleanup.pl
Last active January 29, 2019 10:36
Perl script to parse rubocop configuration files and looking for dead references
#!/usr/bin/env perl -w
use 5.006;
use strict;
use warnings;
use YAML::Tiny;
use Cwd qw( cwd );
use File::Spec::Functions qw( catfile catdir );
# This scripts allows to find out which files are excluded in .rubocop.yml
@mberlanda
mberlanda / MULTIPLE_GIT_TAGGING.md
Created November 14, 2018 16:41
Multiple Git Tagging on the same repo
@mberlanda
mberlanda / rubocop.pl
Created July 30, 2018 14:13
Parse rubocop.yml and find out non existing files
#!/usr/bin/env perl -w
use 5.006;
use strict;
use warnings;
use YAML::Tiny;
use Cwd qw( cwd );
use File::Spec::Functions qw( catfile catdir );
my $yaml = YAML::Tiny->read(
@mberlanda
mberlanda / rebase_branches.sh
Created July 26, 2018 15:38
Rebase several branches
#!/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
@mberlanda
mberlanda / README.md
Last active July 16, 2018 16:14
Allow to install multiple gem versions

Multiple gem versions

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:

  • L7 TARGET_DIR: the dir where the gems will be extracted
  • L8 PKG_DIR : the dir where the .gem files will be downloaded

Keybase proof

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: