Skip to content

Instantly share code, notes, and snippets.

@akheron
akheron / ec2-connect.sh
Created October 19, 2012 11:20
Connect to Amazon EC2 instances
#!/bin/sh
#
# Look up the public IP address of an Amazon EC2 instance via
# the Amazon API, and connect to it using ssh.
# Defaults
region=eu-west-1
identity_file=~/amazon/identity.pem
username=ubuntu
@akheron
akheron / smtpd_fixture.py
Last active June 30, 2021 10:26
SMTP server pytest fixture
# The SMTP server runs in a separate thread and stores sent messages in a list
#
# Usage:
#
# def test_fn(smtpd):
# host = smtpd.host
# port = smtpd.port
#
# # Run code that send email using an smtp server at host:port
#
@akheron
akheron / remote-emacs.sh
Created March 2, 2011 11:28
Use emacsclient for editing remote files by setting this script as EDITOR in the remote machine
#!/bin/sh
#
# Use this script as your EDITOR to allow editing remote files with emacsclient.
# Works by connecting to the Emacs machine with SSH and using a suitable tramp prefix.
# How to reach this machine from the one that's running Emacs
ME=user@remote-host
# How to reach the machine that's running Emacs from this machine
THEY=user@host-running-emacs
@akheron
akheron / gist:766049
Created January 5, 2011 08:13
Sample proxy.pac to be used with SSH tunnels
// -*- js2 -*-
//
// Works at least in Chrome. To setup the SOCKS proxy, use the -D option:
//
// ssh -D 5001 user@tunnel_endpoint_host
//
function FindProxyForURL(url, host) {
if(dnsDomainIs(host, "192.168.1.5")) {
return "SOCKS localhost:5001;";
@akheron
akheron / .gitconfig
Last active December 29, 2019 06:48
My dotfiles: .gitconfig, .mailcap, .screenrc, .toprc, .tmux.conf
[alias]
st = status --short --branch
dc = diff --cached -M -B -C
typo = commit --amend
fixup = commit --amend --no-edit
logk = log --graph --pretty=\"format:%C(yellow)%h%C(red)%d%Creset %s %C(green)%an, %ar%Creset\"
ffpull = pull --ff-only
ffmerge = merge --ff-only
ri = "!f() { rev=$(git rev-parse $1 2>/dev/null) || rev=HEAD~$1; git rebase -i $rev; }; f"
rc = rebase --continue
@akheron
akheron / PG.js
Created November 5, 2018 12:36
purescript-postgresql-client library monad
exports.getSQLState = function (error) {
return error.code || ''
}
exports.getError = function (errorType) {
return function (error) {
return {
errorType: errorType,
severity: error.severity || '',
code: error.code || '',
@akheron
akheron / config
Created May 2, 2012 10:50
git config for detached worktree
# Create the repository with "git init --bare", then edit config to match this:
[core]
repositoryformatversion = 0
filemode = true
bare = false
worktree = /path/to/worktree
[receive]
denycurrentbranch = ignore
@akheron
akheron / benchmark.md
Last active July 30, 2017 05:56
elm-make benchmark

The test

Clone rtfeldman/elm-spa-example. Download all deps: elm-package install --yes.

Then time the builds running these commands:

rm -rf elm-stuff/build-artifacts
@akheron
akheron / get-workspaces.sh
Created May 26, 2017 10:51
i3 workspace/output helpers
#!/bin/sh
usage() {
echo "usage: get-workspaces.sh OUTPUT"
echo ""
echo "Print the names of workspaces on the given output"
echo ""
exit 2
}
@akheron
akheron / couchdb_test.py
Created November 11, 2010 09:07
Test script for CouchDB bulk insertions with different docid selection schemes
from datetime import datetime
# See https://gist.github.com/672279/
from inoi.util.random import sequential_id, monotonic_id
import httplib2
import json
import random
import time
import sys