Skip to content

Instantly share code, notes, and snippets.

View marceloalmeida's full-sized avatar

Marcelo Almeida marceloalmeida

View GitHub Profile
marceloalmeida /
Created August 28, 2019 18:08 — forked from robbiet480/
A consul-template plugin to get EC2 metadata



This is a simple little Python script to let you query EC2 metadata from consul-template. It's only requirement is boto. It uses the EC2 internal metadata service so it does not require any API keys or even a region. The only caveat is that this can only be run on a machine on EC2.


You can give no arguments for full dictionary output or one or more arguments to get specific key(s). Put it somewhere on your machine, chmod +x it and give the full path to consul-template.


marceloalmeida /
Last active January 18, 2019 15:53 — forked from rantav/
Find slow queries in mongo DB

A few show tricks to find slow queries in mongodb

Enable profiling

First, you have to enable profiling

> db.setProfilingLevel(1)

Now let it run for a while. It collects the slow queries ( > 100ms) into a capped collections, so queries go in and if it's full, old queries go out, so don't be surprised that it's a moving target...

marceloalmeida /
Created September 18, 2018 08:52 — forked from leonjza/
Python Netcat
import socket
class Netcat:
""" Python 'netcat like' module """
def __init__(self, ip, port):
self.buff = ""
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
marceloalmeida /
Created September 12, 2018 08:27 — forked from mastermatt/
Consul Semaphore in Python
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import datetime
import json
import logging
import os
import socket
import time
marceloalmeida /
Last active April 22, 2019 11:03 — forked from bartoszmajsak/
How to automatically prepend git commit with a branch name


Hook to prepend branch name to commit for better integration with third party systems.


Install hook on git repository

curl -sL -o .git/hooks/prepare-commit-msg && \