Skip to content

Instantly share code, notes, and snippets.

Setup tips

Basics

  • Dark theme
  • emacs keybindings

GUI Config

  • disable code folding
  • disable status bar
  • disable navigation bar

Setting up secure, private dns cache for local network

See https://calomel.org/unbound_dns.html - specifically recursive, authoritative, validating dns over tls cache using 9.9.9.9 and 1.1.1.1

Setup

  • Unifi usg with unifi controller running on a raspi with fixed ip
  • unifi usg serves dhcp and hostnames for dhcp devices, upstreams to local dns cache
  • local dns cache upstreams over tls, and validates with dnssec
import zlib
class ZipStream(object):
GZIP_MAGIC = 32 + zlib.MAX_WBITS
CHUNK_SIZE = 4 * 4096
def __init__(self, f):
self.decompress = zlib.decompressobj(self.GZIP_MAGIC)
self.file = f
$ cloc app/src/main/
89 text files.
87 unique files.
2 files ignored.
github.com/AlDanial/cloc v 1.74 T=0.70 s (123.8 files/s, 7577.3 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
Java 52 845 4 3275
ADDR="$(adb shell ip -f inet addr show wlan0|grep inet|cut -d' ' -f 6|cut -d\/ -f1)"
echo "connecting to $ADDR"
adb tcpip 5555
adb connect $ADDR:5555

Keybase proof

I hereby claim:

  • I am mdellavo on github.
  • I am mdellavo (https://keybase.io/mdellavo) on keybase.
  • I have a public key ASCq6viRr5WXpJtmzTGNrpJ1fwfgnha5YO07x-zMI2n7lAo

To claim this, I am signing this object:

#!/usr/bin/env python
# sudo zcat /db/logs/mongodb.log.6.gz | /tmp/mongo_slow_log.py 100 2017-01-01T00:00:00 2017-01-01T00:01:00
import re
import sys
import datetime
DATETIME_ARG_FORMAT = "%Y-%m-%dT%H:%M:%S"
MONGO_TIMESTAMP_FORMAT = "%Y-%m-%dT%H:%M:%S.%f+0000"
The 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
md2 2285.35k 4634.78k 6194.65k 6870.34k 7032.90k
mdc2 13815.89k 13134.95k 15944.69k 16054.02k 16189.83k
md4 52168.71k 156615.24k 376170.13k 576946.12k 676958.53k
md5 38348.71k 115547.65k 250306.98k 359768.04k 409865.07k
hmac(md5) 39607.23k 114825.22k 249540.18k 355392.78k 399067.15k
sha1 39185.97k 90724.33k 266446.56k 376649.27k 434629.74k
rmd160 28687.79k 71553.37k 135660.19k 174646.58k 187926.89k
rc4 311110.49k 320318.12k 349607.73k 355096.52k 357613.95k
-- INIT
glFinish()
glGetError() = 0
glViewport(<int> 0x0, <int> 0x0, <int> 0x400, <int> 0x300)
glClear(<int> 0x4000)
glGetError() = 0
glViewport(<int> 0x0, <int> 0x0, <int> 0x400, <int> 0x300)
glClear(<int> 0x4000)
glGetString(<int> 0x1F02) = 4.1 INTEL-10.25.17
class GeneratorContextManager(object):
"""Helper for @contextmanager decorator."""
def __init__(self, gen):
self.gen = gen
def __enter__(self):
try:
return self.gen.next()