Skip to content

Instantly share code, notes, and snippets.

View unleashed's full-sized avatar
👶
Parenting x2

Alejandro Martinez Ruiz unleashed

👶
Parenting x2
View GitHub Profile
@unleashed
unleashed / benchmark.rb
Created September 3, 2014 15:01
mikz: does anyway have better way of converting whatever/string/like/this to [['whatever'], ['whatever', 'string'], ['whatever', 'string', 'like'], ['whatever', 'string', 'like', 'this']] than: str.split('/').reduce([]){ |acc, v| acc.push(([acc.last].compact + [v]).flatten) }
require 'benchmark'
loops = 1_000_000
str = 'whatever/string/like/this'
Benchmark.bm do |x|
x.report 'michal1' do
loops.times do
str.split('/').reduce([]){ |acc, v| acc.push(([acc.last].compact + [v]).flatten) }
@unleashed
unleashed / set_vs_array.rb
Last active August 29, 2015 14:17
Set vs Array with small data set // Cost of Set creation on top of Array
# Info:
#
# A performance benchmark of `Set` vs `Array` on a 5 integer element data set*.
#
# S: a class INSTANTIATED containing a Set INSTANTIATED for each `include?` query
# A: a class INSTANTIATED with an already instantiated Array for each `include?` query
# SS: an already instantiated class with an already instantiated Set for each `include?` query
# AA: an already instantiated class with an already instantiated Array for each `include?` query
#
# For pure comparison purposes of Set and Array, you should only pay attention to SS and AA benchmarks.

Keybase proof

I hereby claim:

  • I am unleashed on github.
  • I am unleashed (https://keybase.io/unleashed) on keybase.
  • I have a public key whose fingerprint is 33E0 ED94 CC4D 3300 0F56 B35A CE22 9595 A73A 83B0

To claim this, I am signing this object:

@unleashed
unleashed / gpgbackup.sh
Last active June 18, 2016 12:44
GnuPG key backup
#!/bin/sh
mkdir ./gpgbackup
gpg --export -a > ./gpgbackup/pubring.asc
gpg --export-secret-keys -a > ./gpgbackup/secring.asc
gpg --export-ownertrust -a > ./gpgbackup/ownertrust.asc
tar cvjf ./gpgbackup.tar.bz2 ./gpgbackup
rm -rf ./gpgbackup
gpg --symmetric --output ./gpgbackup.tar.bz2.crypt ./gpgbackup.tar.bz2
rm ./gpgbackup.tar.bz2
md5sum ./gpgbackup.tar.bz2.crypt > ./gpgbackup.tar.bz2.crypt.md5
@unleashed
unleashed / openpgp.txt
Created June 18, 2016 14:53
OpenKeychain Linked Identity
This Gist confirms the Linked Identity in my OpenPGP key, and links it to this GitHub account.
Token for proof:
[Verifying my OpenPGP key: openpgp4fpr:33e0ed94cc4d33000f56b35ace229595a73a83b0]
@unleashed
unleashed / openpgp.txt
Created June 18, 2016 14:53
OpenKeychain Linked Identity
This Gist confirms the Linked Identity in my OpenPGP key, and links it to this GitHub account.
Token for proof:
[Verifying my OpenPGP key: openpgp4fpr:33e0ed94cc4d33000f56b35ace229595a73a83b0]
@unleashed
unleashed / openpgp.txt
Created June 18, 2016 14:53
OpenKeychain Linked Identity
This Gist confirms the Linked Identity in my OpenPGP key, and links it to this GitHub account.
Token for proof:
[Verifying my OpenPGP key: openpgp4fpr:33e0ed94cc4d33000f56b35ace229595a73a83b0]
@unleashed
unleashed / git-recommit-as
Created August 6, 2018 18:04
scripts that helped me rebase and opensource apisonator
#!/bin/bash
#
# This script receives a parameter, the revision from which to take
# the committer information, and applies that committer information
# to the current HEAD.
#
# N.B.: The machinery uses git commit --amend, so if you have staged
# changes you will add them to the commit! This is solvable, but not
# worth the effort.
@unleashed
unleashed / maistra_apimgmt.sh
Last active June 18, 2019 13:28
Install Maistra on a CentOS/RHEL machine
#!/bin/bash
if test -x "$(pwd)/istiooc"; then
ISTIOOC=$(pwd)/istiooc
else
ISTIOOC=${HOME}/istiooc
fi
NAMESPACE=${NAMESPACE:-bookinfo}
DEPLOYMENT=${DEPLOYMENT:-productpage-v1}
@unleashed
unleashed / gist-go
Last active April 25, 2019 14:07
Get GitHub Gist
#!/bin/bash
#
# gist-go - Get a Github Gist
# Copyright (c) 2019 Alejandro Martinez Ruiz <alex flawedcode org>
#
# Downloads latest version of files in a Github gist, optionally outputting them to stdout.
# Files will by default be written to the current working directory, unless you
# specify --stdout (or -o) as first parameter.
#
# Usage: