Skip to content

Instantly share code, notes, and snippets.

@miekg
miekg / gist:6032733
Created July 18, 2013 20:22
Table output after fixing
Fruit Price Advantages
----- ----- ----------
Bananas $1.34 built-in wrapper
Apples $0.10 cures   scurvy
Bananas $0.73 scurvy
Oranges $2.10 cures scurvy
@miekg
miekg / zsh make function for golang
Created August 12, 2013 05:12
When doing cgo I get confused when to type make (to compile C code) or when to type go build (to compile Go code). Also in Vim you use :make, so to stop any confusing I'm using the following function. This allows me to always use 'make'.
make() {
if [[ -f Makefile || -f GNUMakefile ]]; then
command make "$@"
return
fi
go build
# if go build failed with exit code 1, the build env wasn't
# correct, in that case, try make again
if [[ $? -eq 1 ]]; then
command make "$@"
# In earlier versions of this makefile, the other two directories were
# subdirectories of $(TZDIR). However, this led to configuration errors.
# For example, with posix_right under the earlier scheme,
# TZ='right/Australia/Adelaide' got you localtime with leap seconds,
# but gmtime without leap seconds, which led to problems with applications
# like sendmail that subtract gmtime from localtime.
# Therefore, the other two directories are now siblings of $(TZDIR).
# You must replace all of $(TZDIR) to switch from not using leap seconds
# to using them, or vice versa.
@miekg
miekg / gist:6255503
Last active December 21, 2015 05:18
Fish like shell path in zsh.
# shorten path -> /home/miekg/bla -> /h/m/bla
function shorten() {
full=$(print -P "$1")
a=(${(s:/:)full})
if [[ $#a -eq 0 || $#a -eq 1 ]]; then
print $1; return
fi
last=$a[$#a]
a[$#a]= # clear last element
for i in $a; do
#!/bin/bash
KEYDIR=/etc/bind/external/keys
DSDIR=/etc/bind/external/ds
ZONES="miek.nl atoom.net dnssex.nl dnsex.nl"
cd "$1"
for z in $ZONES; do
if [ -e $z.nsec3 ]; then
# sign with NSEC3
/usr/sbin/dnssec-signzone -P $(grep -v '^\#' $z.nsec3) -N \
unixtime -K $KEYDIR -d $DSDIR -o $z -S $z >/dev/null 2>&1
@miekg
miekg / gist:6478416
Created September 7, 2013 19:18
Compile libcairo for Ubuntu Raring
http://packages.ubuntu.com/saucy/libcairo2;
#download sources;
sudo apt-get build-dep libcairo2;
dpkg-source -x cairo_1.12.16-0ubuntu1.dsc;
cd cairo-*;
dpkg-buildpackage -rfakeroot -us -uc;
#install debs
@miekg
miekg / grpc-dns.txt
Created December 29, 2015 21:21
gRPC based DNS protocol
Network Working Group R. Gieben
Internet-Draft December 20, 2015
Intended status: Standards Track
Expires: June 22, 2016
Using <http://www.iana.org/domains/root/db> as the definition for country codes, the IANA pages for the registration date and some shell foo, this is the list of ccTLD registration:
arpa: 1985-01-01.
arpa: 1985-01-01.
com: 1985-01-01.
com: 1985-01-01.
mil: 1985-01-01.
net: 1985-01-01.
net: 1985-01-01.
us: 1985-02-15.
@miekg
miekg / gist:8149674
Created December 27, 2013 17:04
q has regained the ability to look at NSEC3 records. Usable, but rough around the edges. More stuff coming.
% ./q -check -dnssec dsdksldkskd.nl
;+ Secure signature, 7um0qsaocsaqtmhof0hkbk9th6ek5ce9.nl. RRSIG(NSEC3) validates (DNSKEY nl./54171/net)
;+ Secure signature, sk4e8fj94u78smusb40o1n0oltbblu2r.nl. RRSIG(NSEC3) validates (DNSKEY nl./54171/net)
;+ Secure signature, t98kg1p1cjtdoc4ksb7g57jc9vulltcd.nl. RRSIG(NSEC3) validates (DNSKEY nl./54171/net)
;+ Secure signature, nl. RRSIG(SOA) validates (DNSKEY nl./54171/net)
;+ Denial, closest encloser, nl. (sk4e8fj94u78smusb40o1n0oltbblu2r)
;+ Denial, next closer dsdksldkskd.nl. (7um0qsaocsaqtmhof0hkbk9th6ek5ce9.nl.), covered by 7UM22A80THPR89UNASIDE8K6IHNVVAJ7 -> sk4e8fj94u78smusb40o1n0oltbblu2r
;+ Denial, source of synthesis *.nl. (t98kg1p1cjtdoc4ksb7g57jc9vulltcd.nl.), covered by T98MULSKU3E499AGCTTRJK6H0L3E5T92 -> sk4e8fj94u78smusb40o1n0oltbblu2r
;+ Denial, secure authenticated denial of existence proof for name error
#
# See /usr/share/doc/unbound/examples/unbound.conf for a commented
# reference config file.
server:
# The following line will configure unbound to perform cryptographic
# DNSSEC validation using the root trust anchor.
auto-trust-anchor-file: "/var/lib/unbound/root.key"
do-not-query-localhost: no
local-zone: "168.192.in-addr.arpa" transparent