Skip to content

Instantly share code, notes, and snippets.

View djui's full-sized avatar

Uwe Dauernheim djui

View GitHub Profile
(require '[com.keminglabs.zmq-async.core :refer [register-socket!]]
'[clojure.core.async :refer [>! <! <!! >!! go chan sliding-buffer close!]])
(let [addr "tcp://*:9999"
[s-in s-out] (repeatedly 2 #(chan (sliding-buffer 64)))]
(register-socket! {:in s-in :out s-out :socket-type :rep
:configurator (fn [socket] (.bind socket addr))})
(println "waiting messages...")
@djui
djui / gtb
Last active August 29, 2015 14:07 — forked from dschuetz/gtb
#!/usr/bin/python
import hmac, struct, time, base64, hashlib # for totp generation
import re, sys, subprocess # for general stuff
from getopt import getopt, GetoptError # pretending to be easy-to-use
#
# gtb - Google(auth) + Tunnelblick
#
@djui
djui / vpn.sh
Created October 18, 2014 21:40
Takes a password, generates the TOTP token and starts the OSX VPN
#!/bin/sh
## Dependencies: $ brew install oath-toolkit
function connect {
service="$1"
password='123456'
secret=$(cat $HOME/.google_authenticator)
totp=$(oathtool --base32 --totp $secret)
@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)
@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 / 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 / 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 / git pull-request
Created December 15, 2010 15:04
Formats the last commit and sends emails to all members in the pull request group using standard sendmail. I wrote this because the builtin 'git send-email' does only allow to send a patch file which I think is killer in a small team development.
[pull-request]
group = firstname@lastname.com firstname2@lastname2.com
[alias]
pull-request = "!branch=$(git name-rev --name-only HEAD) ; echo \"git pull $(git remote) $branch\n\n $(git log -1 HEAD --stat)\" | mail -s \"Pull request: $branch\" $(git config pull-request.group)"
SL s·l [ˈəsːəl] n. Swedish company that resists customer comfort delivering train and bus transportation service in time.
» brew install --use-gcc emacs --cocoa --with-x
==> Downloading http://ftp.gnu.org/pub/gnu/emacs/emacs-23.3.tar.bz2
File already downloaded and cached to /Users/uwe/Library/Caches/Homebrew
==> Downloading patches
######################################################################## 100.0%
==> Patching
patching file lisp/term/ns-win.el
Hunk #1 succeeded at 1267 (offset 4 lines).
patching file src/nsfns.m
Hunk #1 succeeded at 2591 (offset 2 lines).