Skip to content

Instantly share code, notes, and snippets.

Avatar

Marcelo Almeida marceloalmeida

View GitHub Profile
@greenbrian
greenbrian / vault-token-role-via-api.sh
Last active Mar 16, 2021
HashiCorp Vault Token Role overview
View vault-token-role-via-api.sh
# start vault in dev mode
VAULT_UI=true vault server -dev -dev-root-token-id="password"
# write some secrets for our example usage
curl --request POST \
--silent \
--header "X-Vault-Token: password" \
--header "Content-Type: application/json" \
--data '{ "options": { "cas": 0 }, "data": { "username": "administrator", "password": "hunter2" } }' \
http://127.0.0.1:8200/v1/secret/data/dev | jq '.'
@mastermatt
mastermatt / semaphore.py
Last active Sep 27, 2020
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
View delete-jenkins-job-build-history.groovy
// change this variable to match the name of the job whose builds you want to delete
def jobName = "Your Job Name"
def job = Jenkins.instance.getItem(jobName)
job.getBuilds().each { it.delete() }
// reset the build number to 1
job.nextBuildNumber = 1
job.save()
@robbiet480
robbiet480 / README.md
Last active Oct 23, 2019
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

View jenkins-delete-failed-builds.groovy
def jobName = '(...)'
Jenkins.instance.getItemByFullName(jobName).builds.findAll { it.result == Result.FAILURE}.each { it.delete() }
@leonjza
leonjza / netcat.py
Last active May 15, 2021
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)
@rantav
rantav / README.md
Created Aug 23, 2012
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...

@diasjorge
diasjorge / Agenda
Created Feb 15, 2012
Efficient bash cheat sheet
View Agenda
Efficient moving
Ctrl-a Move to the start of the line.
Ctrl-e Move to the end of the line.
Ctrl-b Move back one character.
Alt-b Move back one word.
Ctrl-f Move forward one character.
Alt-f Move forward one word.
@bartoszmajsak
bartoszmajsak / prepare-commit-msg.sh
Last active Apr 29, 2021
How to automatically prepend git commit with a branch name
View prepare-commit-msg.sh
#!/bin/bash
# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"