Skip to content

Instantly share code, notes, and snippets.

View uolter's full-sized avatar

Walter Traspadini uolter

View GitHub Profile
@uolter
uolter / webgo.go
Created March 13, 2015 13:00
Dump http post with json
package main
import (
"encoding/json"
"io/ioutil"
"log"
"net/http"
)
type test_struct struct {
@uolter
uolter / cluster_count.py
Created February 7, 2016 10:38
Map reduce example to classify cluster and values
__author__ = 'uolter'
import map_reduce
def mapper(input_key, input_value):
def cut_and_clean_value(cluster):
"""
:param cluster: string in the format <cluster>:<value>
:return: touple cluster and value. If value is NaN return 0
@uolter
uolter / map_reduce.py
Created February 8, 2016 05:40
Map reduce engine emulator
__author__ = 'uolter'
"""
Defines a single function, map_reduce, which takes an input
dictionary i and applies the user-defined function mapper to each
(input_key,input_value) pair, producing a list of intermediate
keys and intermediate values. Repeated intermediate keys then
have their values grouped into a list, and the user-defined
function reducer is applied to the intermediate key and list of
@uolter
uolter / hide_code.py
Created September 4, 2016 16:27
Hide code cells in Jupyter notebook
from IPython.display import HTML
def hide_code():
return HTML('''<script>
code_show=true;
function code_toggle() {
if (code_show){
$("div.input").hide();
} else {
$("div.input").show();
@uolter
uolter / haproxy.cfg
Created December 15, 2017 15:02
haproxy load balancing with Round Robin
#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
@uolter
uolter / haproxy.cfg
Created December 15, 2017 15:29
haproxy load balancing configuration Aloha load-balancer
# Global settings
#---------------------------------------------------------------------
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
@uolter
uolter / lambda_stop.py
Last active January 23, 2018 10:27
AWS lambda which stops EC2 instances with Env Dev tag
import boto3
# Enter the region your instances are in. Include only the region without specifying Availability Zone; e.g., 'us-east-1'
region = 'eu-west-1'
filters = [{'Name':'tag:Env', 'Values':['Dev']}]
def lambda_handler(event, context):
ec2 = boto3.client('ec2', region_name=region)
@uolter
uolter / terraform_terragrunt_aliases
Created June 3, 2020 12:02
Useful Terraform and Terrgagrunt aliases
# Terraform
alias trf='terraform'
## Terragrunt
alias trg='terragrunt'
alias trgfmt='terragrunt hclfmt'
alias trglint='find . -type f -not -path "*/\.*" | grep ".hcl" | terragrunt hclfmt'
alias trgcleancache='find . -type d -name ".terragrunt-cache" -prune -exec rm -rf {} \;'
function trginitall() {
const https = require('https');
const fs = require('fs');
const hostname = 'Todo';
var outstanding_reqs = 0;
var got_continue = false;
function readTextFile() {
@uolter
uolter / release-notes.sh
Last active August 5, 2020 08:37
Bash script to create a Release with updated CHANGELOG file
#!/bin/bash
latest_tags () {
echo "Latest tags!"
git describe --tags `git rev-list --tags --max-count=3`
echo "Status"
git status -uno
}