Skip to content

Instantly share code, notes, and snippets.

View hdonnay's full-sized avatar

Hank Donnay hdonnay

View GitHub Profile
#!/bin/sh
exec 2>/dev/null
exec sox -c 2 -n -d synth pinknoise band -n 2500 4000 tremolo 0.03 5 reverb 20 gain -l 6
@hdonnay
hdonnay / api.go
Last active March 27, 2018 17:58
logger idea
package tlog
// import (...)
func WithTags(ctx context.Context, pairs ...string) context.Context {
// turn these pairs into a bunch of [][2]string, shove into the Context
}
func Print(ctx context.Context, f string, v ...interface{}) {
tags := fromContext(ctx)

Keybase proof

I hereby claim:

  • I am hdonnay on github.
  • I am hdonnay (https://keybase.io/hdonnay) on keybase.
  • I have a public key whose fingerprint is 5989 62F6 8B4F 9428 F27F 43D1 82E2 1E8C 09B4 BE6D

To claim this, I am signing this object:

@hdonnay
hdonnay / work.c
Created October 13, 2017 17:43
work (nix-shell wrapper)
#define _XOPEN_SOURCE 700
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
extern char **environ;
@hdonnay
hdonnay / tls-hook.sh
Last active January 10, 2017 01:11
acmetool tls-sni hook
#!/bin/sh
# Provided in the public domain.
#
# This works best as a suid hook.
# nginx may complain about the server_name being too long. Either fix it, or
# the commented out pattern should work.
NGINX_SITES=/etc/nginx/sites-enabled
cfg="$NGINX_SITES/challenge-$2"
pem="${TMPDIR:-/tmp}/challenge-$2.pem"
@hdonnay
hdonnay / gdb
Created October 12, 2016 19:32
gdbserver work
% gdb amd64/bin/cat
GNU gdb (GDB; openSUSE Tumbleweed) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-suse-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
// This is something like n^2 worst-case.
//
// []string must be sorted
func diffStrings(new, old []string) (added, removed []string) {
Add:
for _, x := range new {
for _, y := range old {
if x == y {
continue Add
}
@hdonnay
hdonnay / mk_freeze.sh
Last active December 18, 2015 00:59
Helper script to use esky with salt
#!/bin/sh
trap '[ -f patch.$$ ] && patch -R < patch.$$' 0
PATH="$PATH:`pwd`/patchelf/src"
set -e
#exec >/dev/null
[ -f setup.py ] || { printf "You seem to be in the wrong directory.\n"} >&2; exit 1; }
if ! which patchelf >/dev/null 2>&1; then
printf "Couldn't find 'patchelf', going to download and compile.\n" >&2
git clone https://github.com/NixOS/patchelf
(
@hdonnay
hdonnay / ht.sh
Last active December 14, 2015 10:29
ht, a hashtable in sh
#!/bin/sh
VERSION='1.0.2'
usage() {
cat >&2 <<EOF
$(basename $0) -- $VERSION
USAGE:
$(basename $0) [-r] [-d dir] { -o | [-v] KEY }
If stdin is attached, it will be inserted into key KEY. If it's not,
@hdonnay
hdonnay / stats.pl
Last active December 12, 2015 10:38
#!/usr/bin/perl
use strict;
use warnings;
use List::MoreUtils qw(zip);
my @a = ( 'Kernel Name', 'Hostname', 'Kernel', 'Platform', 'OS' );
my @b = split(/ /, `uname -snrio`);
chomp($b[-1]);
my @c = ( 'used', 'total' );
my %uname = zip(@a, @b);