Skip to content

Instantly share code, notes, and snippets.

View djui's full-sized avatar

Uwe Dauernheim djui

View GitHub Profile
@djui
djui / readln.go
Created December 2, 2015 10:08
Minimal readline with timeout example
import (
"bufio"
"errors"
"strings"
"time"
)
// Readln reads and returns a single line (sentinal: \n) from stdin.
// If a given timeout has passed, an error is returned.
// This functionality is similar to GNU's `read -e -p [s] -t [num] [name]`
❯ ll
total 937M
-rw-r--r-- 1 uwe staff 8.8K Nov 20 23:38 CoreOS_Image_Signing_Key.asc
-rw-r--r-- 1 uwe staff 332 Nov 23 22:55 Dockerfile
-rw-r--r-- 1 uwe staff 3.7K Nov 23 22:35 Makefile
-rw-r--r-- 1 uwe staff 3.3K Nov 20 23:19 README.md
-rwxr-xr-x 1 uwe staff 2.1K Nov 23 23:05 build_ova.sh
-rwxr-xr-x 1 uwe staff 433 Nov 20 23:36 build_pdftables.com-ee.sh
-rw-r--r-- 1 uwe staff 496M Nov 23 22:30 coreos_production_vmware_image.vmdk
-rw-r--r-- 1 uwe staff 543 Nov 23 22:30 coreos_production_vmware_image.vmdk.bz2.sig
@djui
djui / DSF.md
Last active October 9, 2015 12:34
Delay-Sensitivity Framework (DSF)
@djui
djui / goodreads-export.py
Created October 6, 2015 14:43
Simple script to export Goodreads exports
#!/usr/bin/env python3
import csv
import sys
def main(args):
if not args:
return 'Usage: goodreads-export FILE'
@djui
djui / ibooks-export.py
Last active February 17, 2022 05:51
Simple iBooks book index export script
#!/usr/bin/env python3
import os
import plistlib
import sys
from datetime import datetime
def main(args):
books_path = '~/Library/Containers/com.apple.BKAgentService/Data/Documents/iBooks/Books/Books.plist'
@djui
djui / Inbox-Fluid.js
Created October 6, 2015 12:26
User script for Google Inbox Fluid App to update the Badge and send notifications on new Emails
var gUnreadMails = new Set()
setInterval(checkUnread, 3000)
function checkUnread() {
updateBadge()
notify()
}
function updateBadge() {
@djui
djui / chrome_current_session.sh
Created July 7, 2015 09:20
Google Chrome Current Tabs (quick but dirty)
#!/bin/sh
PROFILE=Default
strings $HOME/Library/Application\ Support/Google/Chrome/$PROFILE/Current\ Session | sort | uniq | grep ^http
@djui
djui / compact-vmdk.sh
Created March 12, 2015 13:47
Compacts VMDK images by converting it temporarily to a VDI image, compacting it, and then converting it back.
#!/bin/sh -e
if [ "$#" -ne 2 ] ; then
echo "Usage: compact-vmdk <VM_NAME> <IMAGE_PATH>"
echo
echo "Compacts VMDK images by converting it temporarily to a VDI image, compacting it,"
echo "and then converting it back."
echo
echo "Example:"
echo
@djui
djui / vpn.sh
Last active August 29, 2015 14:07
#!/bin/sh -e
cmd=connect
name=$(scutil --nc list | sed -n 's/^* \+.\+\? \+.\+\? \+IPSec \+"\(.\+\?\)" \+\[IPSec\]/\1/p')
password=
secret=
token=
_usage() {
echo "Usage: $(basename $0) <command> [-n name] [-p pass] [-s secret] [-t token] [-h]"
@djui
djui / totp_mini.py
Last active August 29, 2015 14:07
Shortest TOTP I know of
#!/usr/bin/env python
import base64,hashlib,hmac,struct,time,sys
if not len(sys.argv[1:]): sys.exit('usage: totp <secret>')
digest = hmac.new(base64.b32decode(sys.argv[1]), struct.pack('>Q', int(time.time()) // 30), hashlib.sha1).digest()
offset = ord(digest[19]) & 15
print '06d' % (struct.unpack('>I', digest[offset:offset+4])[0] & 0x7fffffff % 1000000)