Skip to content

Instantly share code, notes, and snippets.

Avatar

Marcelo Almeida marceloalmeida

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am marceloalmeida on github.
  • I am marceloalmeida (https://keybase.io/marceloalmeida) on keybase.
  • I have a public key whose fingerprint is 586B 41A6 EF3F E801 D4B9 3F6E E509 8C68 B9B1 823D

To claim this, I am signing this object:

@marceloalmeida
marceloalmeida / semaphore.py
Created Sep 12, 2018 — forked from mastermatt/semaphore.py
Consul Semaphore in Python
View semaphore.py
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
marceloalmeida / netcat.py
Created Sep 18, 2018 — forked from leonjza/netcat.py
Python Netcat
View netcat.py
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
marceloalmeida / consul_blocking_query.sh
Created Sep 18, 2018
Consul Blocking query example
View consul_blocking_query.sh
#!/bin/bash -e
CONSUL_ADDR=${CONSUL_ADDR="http://consul.service.consul:8500"}
CONSUL_ENDPOINT=${CONSUL_ENDPOINT="/v1/catalog/services"}
while true; do
INDEX_FILE="$(mktemp -t consul_index_)"
CONSUL_INDEX=$(
curl -isL \
-H 'X-Consul-Index: 1' \
@marceloalmeida
marceloalmeida / README.md
Last active Jan 18, 2019 — forked from rantav/README.md
Find slow queries in mongo DB
View README.md

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
marceloalmeida / README.md
Last active Apr 22, 2019 — forked from bartoszmajsak/prepare-commit-msg.sh
How to automatically prepend git commit with a branch name
View README.md

prepare-commit-msg

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

Installation

Install hook on git repository

curl -sL https://gist.github.com/marceloalmeida/067889e16abb243f98ac35e8943247bb/raw/prepare-commit-msg -o .git/hooks/prepare-commit-msg && \
@marceloalmeida
marceloalmeida / README.md
Created Aug 28, 2019 — forked from robbiet480/README.md
A consul-template plugin to get EC2 metadata
View README.md

ec2-consul-template-plugin

About

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.

Usage

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.

Examples

@marceloalmeida
marceloalmeida / README.md
Last active Feb 25, 2021
Certificates cheat sheet
View README.md

Certificates cheat sheet

Generate Certificate and sign

Generate private key

openssl genrsa -out test.com.key 4096
@marceloalmeida
marceloalmeida / .gitattributes
Last active Apr 13, 2021
How to show diffs for gpg-encrypted files?
View .gitattributes
*.gpg filter=gpg diff=gpg
*.asc filter=gpg diff=gpg