Skip to content

Instantly share code, notes, and snippets.

View giovannibonetti's full-sized avatar
🏠
Working from home

Giovanni Kock Bonetti giovannibonetti

🏠
Working from home
View GitHub Profile
@giovannibonetti
giovannibonetti / Pentaho-Kettle-RabbitMQ-Consumer.java
Created December 9, 2013 18:37
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…
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;
# 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 June 8, 2018 17:51
Useful for migrating between git hosting services
#!/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 March 20, 2018 17:29
Benchmark comparing time arithmetics with moment duration and plain numbers
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()