Skip to content

Instantly share code, notes, and snippets.

@lsowen
lsowen / gist:4f51a27cc58cf56884b4
Created September 11, 2014 20:24
Example DNS-SD query
package main
import (
"fmt"
"os"
"github.com/armon/mdns"
"sync"
)
func channelHandler(wg sync.WaitGroup, ch <-chan mdns.ServiceEntry) {

Keybase proof

I hereby claim:

  • I am lsowen on github.
  • I am lsowen (https://keybase.io/lsowen) on keybase.
  • I have a public key whose fingerprint is 337C E5E0 6C9E 3677 CCC7 1A40 FECD 001B C751 40C0

To claim this, I am signing this object:

@lsowen
lsowen / tlsimap.py
Last active June 14, 2016 23:29 — forked from kiowa/tlsimap.py
Update to work with Python 2.7.3
""" Python IMAP with TLS/SSL support """
##
## Author: Alexander Brill <alex@brill.no>
## Copyright (C) 2004 Alexander Brill
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
## as published by the Free Software Foundation; either version 2
## of the License, or (at your option) any later version.
##
@lsowen
lsowen / Extend_KVM_guest.txt
Created June 28, 2016 10:19
Quick notes on size a KVM guest (which uses LVM) up
On supervisor:
lvextend -L50G /dev/vg_kvmhost01/test-01.img
virsh qemu-monitor-command util-02 --hmp "info block"
virsh qemu-monitor-command util-02 --hmp "block_resize drive-virtio-disk0 50G"
On VM:
http://unix.stackexchange.com/a/42910
@lsowen
lsowen / notes.md
Last active April 29, 2017 20:30
emacs/tmux integration
  • Emacs: shell-command-on-region
  • Command: tmux load-buffer -

export EVENT_NOEPOLL=1 tmux/tmux#416

Virsh Install Kernel Options

@lsowen
lsowen / main.go
Last active November 11, 2017 13:27
Example to create Rackspace Files TempURL with golang
package main
// Based on documentation found here: http://docs.rackspace.com/files/api/v1/cf-devguide/content/Create_TempURL-d1a444.html
import (
"crypto/hmac"
"crypto/sha1"
"encoding/hex"
"fmt"
"github.com/ncw/swift"
@lsowen
lsowen / update-dns.sh
Last active March 16, 2020 17:31
Calculate Reverse ipv6 PTR Record in Bash (using awk and sed)
function reverseIp6 {
echo "$1" | awk -F: 'BEGIN {OFS=""; }{addCount = 9 - NF; for(i=1; i<=NF;i++){if(length($i) == 0){ for(j=1;j<=addCount;j++){$i = ($i "0000");} } else { $i = substr(("0000" $i), length($i)+5-4);}}; print}' | rev | sed -e "s/./&./g"
}
$(reverseIp6 "2001:db8:85a3::8a2e:370:7334")"ip6.arpa."
#Result: 4.3.3.7.0.7.3.0.e.2.a.8.0.0.0.0.0.0.0.0.3.a.5.8.8.b.d.0.1.0.0.2.ip6.arpa.
@lsowen
lsowen / README.md
Created October 5, 2015 15:44
django-rest-framework-json-api dynamic filter relationship

I needed to be able to filter which items of a ManyRelatedField were returned, based on some attributes of the request user. Normally, all items in the relationship are returned, however I was able to override the ManyRelatedField.to_attribute() function to enable additional filtering of the relationship.

@lsowen
lsowen / hfsc-shape.sh
Last active November 17, 2022 03:41 — forked from bradoaks/hfsc-shape.sh
HFSC - linux traffic shaping's best kept secret
#!/bin/sh
# As the "bufferbloat" folks have recently re-discovered and/or more widely
# publicized, congestion avoidance algorithms (such as those found in TCP) do
# a great job of allowing network endpoints to negotiate transfer rates that
# maximize a link's bandwidth usage without unduly penalizing any particular
# stream. This allows bulk transfer streams to use the maximum available
# bandwidth without affecting the latency of non-bulk (e.g. interactive)
# streams.
@lsowen
lsowen / onvif_request.py
Last active August 29, 2023 22:52
Create valid ONVIF request to Dahua IPC-HDW2100
#!/usr/bin/env python3
import hashlib
import os
import base64
from datetime import datetime
username = "admin"