Skip to content

Instantly share code, notes, and snippets.

@gdvalle
gdvalle / putty-monokai.reg
Created December 2, 2012 05:24
Monokai style theme for PuTTY; colors copied from ST2's theme
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\monokai]
"Colour21"="255,255,255"
"Colour20"="245,222,179"
"Colour19"="200,240,240"
"Colour18"="0,217,217"
"Colour17"="179,146,239"
"Colour16"="174,129,255"
"Colour15"="122,204,218"
@gdvalle
gdvalle / pasteit.py
Last active December 12, 2015 08:49
hastebinit-like script for paste.pm. Python 2 and 3 compatible.
#!/usr/bin/env python
""""Client for paste.pm"""
import sys
PY3 = sys.version > '3'
if PY3:
from urllib.parse import urlencode
from urllib.request import Request, urlopen
else:
@gdvalle
gdvalle / gist:8640893
Last active January 4, 2016 15:29
murmur upgrade script
#!/usr/bin/env python
import argparse
import urllib
import os
import tarfile
import subprocess
import logging
logging.basicConfig(format='%(asctime)s: %(message)s', level=logging.DEBUG)
@gdvalle
gdvalle / timeit_filter.py
Created June 17, 2014 20:16
Script to test speed of filter_leading_non_json_lines()
#!/usr/bin/env python
import timeit
import sys
try:
count = int(sys.argv[1])
except:
count = 1
@gdvalle
gdvalle / test_ansible_slow_copy.sh
Created June 17, 2014 20:28
Script to reproduce slow Ansible file copy
#!/usr/bin/env bash
#
# Breaking commit: https://github.com/ansible/ansible/commit/460794d697ee8fa4a959e76442bd9a2e777d6251
# Last working commit: https://github.com/ansible/ansible/commit/237b9cb05669f22099cc6c47de44c5f6321869c3
#
# It appears that the kv_regex.match() hangs ansible during larger file copies.
#
FSIZE=60000
HOST="localhost"
ANSIBLE_ARGS="-i '$HOST,' -v -D test.yml"
@gdvalle
gdvalle / Molokai.colorscheme
Created September 18, 2014 17:34
Molokai color scheme for Konsole
[Background]
Color=39,40,34
[BackgroundIntense]
Color=39,40,34
[Color0]
Color=0,0,0
[Color0Intense]
@gdvalle
gdvalle / atomcat.sh
Last active May 23, 2021 18:26
An atomic file updater in shell.
#!/bin/sh
set -u
PROG="${0##*/}"
# Default temp file suffix
SUFFIX="${SUFFIX-.tmp$$}"
usage() {
printf 'usage: echo foo | %s <file> [lockfile] [tempfile]\n' "$PROG" >&2
@gdvalle
gdvalle / prometheus_alert_migrate.vimscript
Created March 3, 2016 16:28
Convert Prometheus 0.16.x alerts to 0.17 format
:%s/WITH/LABELS/g
:%s/SUMMARY \(.*\)/ANNOTATIONS {\r summary = \1,/g
:%s/DESCRIPTION \(.*\)/ description = \1\r \}/g
@gdvalle
gdvalle / update_readme
Created February 18, 2017 21:33
Replace text between invisible markdown comments.
#!/usr/bin/env bash
# This just replaces the text between a couple of hopefully invisible
# markdown comments, like so: `[//]: #` (text within backticks)
set -euo pipefail
main_output="$(cargo run -- --help)"
output="$(printf "### main\n\`\`\`\n%s\n\`\`\`" "$main_output")\n"
output+="### subcommands\n"
@gdvalle
gdvalle / benchmark.lua
Last active February 5, 2018 18:32
OpenResty micro benchmark lib
local ffi = require "ffi"
local ngx = ngx
local ngx_update_time = ngx.update_time
local ngx_say = ngx.say
local tonumber = tonumber
ffi.cdef[[
typedef long time_t;