Skip to content

Instantly share code, notes, and snippets.

Fabrizio Branca fbrnc

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am fbrnc on github.
  • I am fbrnc (https://keybase.io/fbrnc) on keybase.
  • I have a public key ASB3WTuY4rB_v4d3YnnCk5vrK16eY-f6I0GfoWBkWywtQAo

To claim this, I am signing this object:

View id_fabrizio_2016.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDylDQT7AW84cExfb2ILuzDu9Qv+Vb/W4/0CsUREnP5pEbsLbzt+4ccmPkitC1CXkhdb0Ok2GI6Vq3Y9M4pK3uYMdM4jPk+2l56nVwWkW83ysEhJmTgRaVSwoWFdRRTQeaFr5BVfOSboQb64Hs0gCm7twmDg+XUxrfci6xQFMYEglfTI86WjHosfHzEF2NLyBp5bHL6KqZ6by/Hfy5uIf2leDCWp3HwfgVzMZSgXn5VVPGU21do3fWemPKJLn4cmoBtbX6Mz1Fpx/nZsebuhb4biYH4EurrUj71LfXoy4w4VOPYUMWv0+ELss0Vc3Mz7ID5NcIU7LCQdbYd234d6Z5HbyR8A0FAKEwkEOmN0vEE8/ahCkDQuUzH/RnDJuHdnLvCN67Y/U2TipPDke/XVBW0J9Z5wBbU33QIM95A+toO/271EY7Dy2dkLp5rkmhPvrUs9Rph2IF+LE24N8Gc0Wn/BIBw94oCeaWjcdAJ5nuOQmL+MUU/H1FCU3uDeQ1kuJ9VyxKgHlpa2LppIOQ6mlMgVdGMUzn6uf4Hv3FyVvURx7cn+kbbuxTuAnrQWZhTcN+jjDNxCNLVNmh6SWz/J5eZm3kGTZdcehF0FNhBQP+SogmjSKurtRtPHyT3lvToXktqlnbsAAOh+dFp5Xt48QfIZ7knltipIKqBvnnxQ7BvDQ== Fabrizio 2016
@fbrnc
fbrnc / growl
Created Aug 8, 2016
Growl notification
View growl
#!/bin/bash
echo -n $'\e]9;'
echo -n $1
echo $'\007'
View gist:2582d373629dea0b6f2f408152954c6a
ssh-dss AAAAB3NzaC1kc3MAAACATEP3SRn8/N+bHiZBH8vjjaNpYRQoPSTICxPCWTCLH4dWQXUB0r/zZ/zi9DOcIDIVOJcZGE6Cb9rXMVccijVdQ1GBFf5hDburM3sLI/Eucogm2zApmCpn/IvwOUZymjpF821tIp+7qTGFopAOFDUZDUQzNWRqAqDgs1/WContRysAAAAVAJg6+p6vsCKCx41+KQBx4rx/gyTrAAAAgDOfKzbUJo/h+n0w2R1vKJNqZevLG41QlRH8ZFgb6yOn0VElj1QKu3oI/rId+t1ZDAjBwTY4XwtZfLsg+oDbhcbjoeuVJEXp8I6LOT1uypxfmjoiVFfum24qxnxJLxmCSM/wcXJani9FlMMop8BWm2hBRYrdZr2KW+qwpfNJbhGkAAAAgEeJI71mIfd4HKvWcaXrM4kOeuM2dZnosDC7VbLpYRDlMpTZzoi0l1DUlckJzSMXddEgJAcNIxEXIxOmxB4lwHlbqTsg4e8dX7D9u1jOZE8Zd64oGe1g/VxMLbo6JP6Wa8cowyigaA4VLb6QFnPYWeCFmPhvuBYdbLZ6uHAdud5T AOE Fabrizio Branca
@fbrnc
fbrnc / is_leader.sh
Last active Mar 13, 2017
"Good enough" leader election script for AWS AutoScalingGroups
View is_leader.sh
#!/usr/bin/env bash
function echoerr { echo "$@" 1>&2; }
function error_exit { echoerr "$1"; exit 1; }
if [ -z "${REGION}" ] ; then error_exit "No REGION set"; fi
command -v jq >/dev/null 2>&1 || error_exit "'jq' not found"
command -v aws >/dev/null 2>&1 || error_exit "'aws' not found"
command -v tee >/dev/null 2>&1 || error_exit "'tee' not found"
command -v ec2metadata >/dev/null 2>&1 || error_exit "'ec2metadata' not found"
@fbrnc
fbrnc / counter.js
Created Jun 9, 2016
Simple hit counter with node.js and Redis
View counter.js
var db = require("redis-client").createClient();
require("http").createServer(function(request, response) {
db.incr("count",function(err, reply) {
response.writeHead(200, { "Content-Type": "text/plain" });
response.write(reply.toString());
response.end();
});
}).listen(8181);
View grafana_backup.sh
BASEURL=http://username:password@127.0.0.1:3000
for dash in $(curl -s -k "${BASEURL}/api/search" | jq -r '.[].title'); do
curl -k "${BASEURL}/api/dashboards/db/${dash}" > "${dash}.json"
done
@fbrnc
fbrnc / gitlog2elasticsearch.php
Last active Nov 16, 2019
git log to Elasticsearch
View gitlog2elasticsearch.php
#/bin/bash
cd /var/hackathon/projects
for i in `find . -maxdepth 1 -mindepth 1 -type d`; do
project=`echo $i | sed 's/\.\///g'`
cd "/var/hackathon/projects/$project"
echo "Updating project $project"
git pull
php /var/hackathon/gitlog2elasticsearch.php http://localhost:9200/hackathon/commit/ "$project" '2 days ago'
done
@fbrnc
fbrnc / consumer.php
Last active Dec 28, 2019
AWS Kinesis Example for PHP (using the AWS SDK for PHP)
View consumer.php
<?php
// curl -sS https://getcomposer.org/installer | php
// php composer.phar require aws/aws-sdk-php
// export AWS_ACCESS_KEY_ID=...
// export AWS_SECRET_ACCESS_KEY=...
$streamName = '<INSERT_YOUR_STREAMNAME_HERE>';
$numberOfRecordsPerBatch = 10000;
@fbrnc
fbrnc / send-receive-sqs.php
Last active Sep 4, 2018
Sending and receiving messages from/to AWS SQS via PHP
View send-receive-sqs.php
<?php
// curl -sS https://getcomposer.org/installer | php
// php composer.phar require aws/aws-sdk-php
// export AWS_ACCESS_KEY_ID=...
// export AWS_SECRET_ACCESS_KEY=...
$queueUrl = '<INSERT_URL_OF_EXISTING_QUEUE_HERE>';
You can’t perform that action at this time.