Skip to content

Instantly share code, notes, and snippets.

@paulhandy
paulhandy / cleanup-zfs-snapshots
Created September 18, 2017 19:19
Clean up old zfs snapshots
https://serverfault.com/questions/340837/how-to-delete-all-but-last-n-zfs-snapshots#340846
You may find something like this a little simpler
zfs list -t snapshot -o name | grep ^tank@Auto | tac | tail -n +16 | xargs -n 1 zfs destroy -r
output the list of snapshot (names only) with zfs list -t snaphot -o name
filter to keep only the ones that match tank@Auto with grep ^tank@Auto
reverse the list (previously sorted from oldest to newest) with tac
limit output to the 16th oldest result and following with tail -n +16
@paulhandy
paulhandy / instructions-snapshot-216223.md
Last active September 23, 2017 01:36
IOTA Snapshot @ Milestone 216223

Snapshot generated from milestone 216223.

Snapshot signature verification

I signed the snapshot both in the IRI client, checked at runtime, and with my pgp key (found at keybase.io/paulhandy). As before, to verify the signature, you may download the snapshot from:

m5_sn.txt

m5_sn.txt.asc

@paulhandy
paulhandy / docker-cleanup
Last active September 18, 2017 19:20
Clean up old docker instances
from: https://github.com/moby/moby/issues/3456
docker ps -a | grep Exit | awk '{print $1}' | xargs docker rm
https://stackoverflow.com/questions/17236796/how-to-remove-old-docker-containers
There is a new feature in Docker 1.13.x called Docker container prune: docker container prune This will do what you want and should work on all platforms the same way.
There is also a Docker system prune, which will clean up containers, images, volumes, and networks all in one command.
@paulhandy
paulhandy / snapshot-instructions.md
Last active August 8, 2017 19:51
IOTA Snapshot @milestone 150354

Snapshot generated from milestone 150354.

You may be downloaded by ipfs hash: QmRwdX9mwYof1qkMbQgphnsh9kr32itmTtohusWYH1menV

Download snapshot as:

wget -O snapshot.json https://ipfs.io/ipfs/QmRwdX9mwYof1qkMbQgphnsh9kr32itmTtohusWYH1menV

Download signature as:

@paulhandy
paulhandy / nvim-tunnel
Created March 19, 2017 23:46
neovim tunnel for shared vim sessions
ssh -o ExitOnForwardFailure=yes -fNL $2:127.0.0.1:$1 ${@:3}
nvim-qt --server 127.0.0.1:$2
#usage:
#$ ./nvim-tunnel 6668 6669 user@remote.url
@paulhandy
paulhandy / main.c
Created January 2, 2017 19:41
Prints a random tryte string
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define MYCHAR 'A'
#define TRYTELEN 2673
char *get_random_trytes (int length) {
int i = 0, j;
char *out = malloc(sizeof(char)*length);
@paulhandy
paulhandy / gist:b638d07197bf2bcbd15d8c2fac384dfb
Last active December 25, 2016 19:43
test for valid udp uri
var isValidUri = function(node) {
var getInside = /^udp:\/\/([\[][^\]\.]*[\]]|[^\[\]:]*)[:]{0,1}([0-9]{1,}$|$)/i;
var stripBrackets = /[\[]{0,1}([^\[\]]*)[\]]{0,1}/;
var uriTest = /((^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$)|(^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[

Keybase proof

I hereby claim:

  • I am paulhandy on github.
  • I am paulhandy (https://keybase.io/paulhandy) on keybase.
  • I have a public key ASA1CQSJ2PjhyH1QYoStSaaJX6Z5D3ueRh9Bnj3DKRtZ3wo

To claim this, I am signing this object:

#!/bin/node
// purpose: get your firefox bookmarks in a format that dwb will accept. prints to stdout
// usage: node firefox2dwb.js [./bookmarks.json] [ >> $HOME/.config/dwb/default/bookmarks ]
var fs = require('fs');
fs.readFile(process.argv[2], function(err, data){
var bm, ch;
bm = JSON.parse(data);
ch = bm.children[0];