Skip to content

Instantly share code, notes, and snippets.

Giovanni Kock Bonetti giovannibonetti

View GitHub Profile
View Cloud trace middleware (Ruby)
# local machine
$ gcloud --project "..." app instances ssh "..." --service "default" --version "..."
# app engine flex instance
$ docker ps
$ docker exec -it 2284fbe5c3bc bash
# docker container running on app engine flex instance
root@2284fbe5c3bc:/app$ bundle exec rake middleware
@giovannibonetti
giovannibonetti / git-migrate-all-branches
Created Jun 8, 2018
Useful for migrating between git hosting services
View git-migrate-all-branches
#!/usr/bin/env bash
# Step 1: clone the repository from the old remote
# Step 2: add the new remote
# Based on https://gist.github.com/grimzy/a1d3aae40412634df29cf86bb74a6f72
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
git push --all new-remote
@giovannibonetti
giovannibonetti / moment_benchmark.js
Last active Mar 20, 2018
Benchmark comparing time arithmetics with moment duration and plain numbers
View moment_benchmark.js
var moment = require('moment');
var _ = require('lodash');
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite;
// Exemplo: preenchendo de 8:00 às 18:00 com slots de 30 minutos
suite.add('Adding numbers', function() {
// Conversão de string "8:30" para número (8 * 60 + 30) e vice-versa
function timeStringToNumber(timeString) {
return moment.duration(timeString).asMinutes()
@giovannibonetti
giovannibonetti / Pentaho-Kettle-RabbitMQ-Consumer.java
Created Dec 9, 2013
Here I have some code I used in a Pentaho Kettle (a.k.a. PDI) transformation for communicating with RabbitMQ. Output step => Pentaho-Kettle-RabbitMQ-Producer.java Input step => Pentaho-Kettle-RabbitMQ-Consumer.java (non-blocking). How to use it: 1) Prepare your Kettle transformation; 2) Download RabbitMQ's Java client (only the main Java file is…
View Pentaho-Kettle-RabbitMQ-Consumer.java
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.ConnectionFactory;
//import com.rabbitmq.client.QueueingConsumer;
import com.rabbitmq.client.GetResponse;
import com.rabbitmq.client.AMQP;
//import com.rabbitmq.client.*;
//import com.rabbitmq.client.MessageProperties;
//import com.rabbitmq.client.AlreadyClosedException;
You can’t perform that action at this time.