Skip to content

Instantly share code, notes, and snippets.

View marzocchi's full-sized avatar

Federico Marzocchi marzocchi

View GitHub Profile
@marzocchi
marzocchi / recover-double-encrypted.sh
Created October 24, 2019 13:11
Recover files that ended up being double-encrypted while using git-crypt
#!/bin/sh
set -e
hash() {
if [[ $# != 1 ]]; then
echo "usage: hash FILE" >&2
return 1
fi
shasum "$1" | cut -f1 -d' '
@marzocchi
marzocchi / main.go
Last active September 13, 2018 15:19
bin/parse-url
package main
import (
"bufio"
"fmt"
"gopkg.in/yaml.v2"
"net/url"
"os"
)
@marzocchi
marzocchi / config.ini
Created August 14, 2018 10:49
Git difftool configuration for comparing MySQL schemas
[diff]
tool = diff-for-schema
[difftool]
prompt = false
[difftool "diff-for-schema"]
cmd = diff --show-function-line='^CREATE TABLE' -U1 -- "$LOCAL" "$REMOTE"
@marzocchi
marzocchi / dme.sh
Created July 7, 2017 08:59
zsh hook for loading docker-machine env by containing dir
devbox-register-hook() {
autoload add-zsh-hook
add-zsh-hook chpwd devbox-load-env
}
devbox-unregister-hook() {
autoload add-zsh-hook
add-zsh-hook -d chpwd devbox-load-env
}
@marzocchi
marzocchi / Makefile
Last active June 4, 2017 23:16
`make build` done right
# build depends on bin/homework
build: bin/homework
# bin/homework depends on all .go files in this directory tree
bin/homework: $(shell find . -name '*.go' -not -path './vendor/*')
go build -o bin/homework main.go
@marzocchi
marzocchi / WebDriverCurlService.php
Created June 3, 2017 11:42 — forked from markpol/WebDriverCurlService.php
customizing Curl Options for WebDriver client
<?php
namespace Tests;
use WebDriver\Service\CurlService;
use WebDriver\Service\CurlServiceInterface;
/**
* Class WebDriverCurlService
* @package Tests
@marzocchi
marzocchi / focus.sh
Created April 1, 2017 11:36
Use bindkey to track terminal focused state
function got-focus() {
echo $(date) $TTY got focus >> ~/focus.log
export ACTIVE=1
}
function lost-focus() {
echo $(date) $TTY lost focus >> ~/focus.log
export ACTIVE=0
}
@marzocchi
marzocchi / esx.sh
Last active January 12, 2017 09:57
esx.sh: glue together a bunch of shell programs to run queries on Elasticsearch
#!/bin/sh
set -e
NAME=$(basename "$0")
RC_DIR="$HOME/.esx"
HISTORY_DIR="$RC_DIR/history"
LAST_RESULTS_FILE="$RC_DIR/last-result.json"
QUERY_TEMPLATE_URL="https://gist.githubusercontent.com/marzocchi/71cc6c82eda0e0c36fb8dd36f7da92cf/raw/template.json"
@marzocchi
marzocchi / fw.sh
Created December 19, 2016 06:21
Map local port 80 to 8080
echo "
rdr pass inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080
" | sudo pfctl -ef -
@marzocchi
marzocchi / git-delete-branches.sh
Created September 21, 2016 12:45
Delete GIT branches using a dialog with multiple selection
#!/usr/bin/env zsh
set -e
ANSWER_FILE=$(mktemp)
function ask() {
local -a choices
for branch in $(git branch); do