Skip to content

Instantly share code, notes, and snippets.

@menski
menski / dns.awk
Created November 29, 2011 16:20
Replace client IP address in bind log
{
split($6,A,"#")
if (!dict[A[1]])
dict[A[1]] = ++i
$6 = dict[A[1]] "#" A[2]
print $0
}
@menski
menski / score.py
Created November 29, 2011 16:24
Score algorithm tests for servload
#!/usr/bin/env python3
import math
import collections
import functools
import subprocess
MAX_SCORE = 100
@menski
menski / fakedns.py
Created March 2, 2012 20:02
Fake DNS Server
#!/bin/env python
import sys
import getopt
import socket
def response(data, ancount):
# id and flags
packet = data[:2] + '\x81\x80'
# counts
@menski
menski / .Xresources
Created March 23, 2012 23:59
Xresources for urxvt terminal with tango theme
! Cursor theme
xcursor.theme: Vanilla-DMZ
! URxvt config
URxvt*termName: rxvt-16color
URxvt.scrollBar: off
URxvt.font: xft:monaco:size=10:antialias=true
URxvt.internalBorder: 0
URxvt*selectToClipboard: true
@menski
menski / libmp4v2-2.0.patch
Created June 6, 2012 16:52
easytag-2.1.7 patch to work with libmp4v2 2.0.0
diff -rupN easytag-2.1.7/src/mp4_header.c easytag-2.1.7-patch/src/mp4_header.c
--- easytag-2.1.7/src/mp4_header.c 2011-07-04 02:59:21.000000000 +0200
+++ easytag-2.1.7-patch/src/mp4_header.c 2012-06-06 18:29:54.515139743 +0200
@@ -204,7 +204,7 @@ gboolean Mp4_Header_Read_File_Info (gcha
/* Get size of file */
ETFileInfo->size = Get_File_Size(filename);
- if ((file = MP4Read(filename, 0)) == MP4_INVALID_FILE_HANDLE )
+ if ((file = MP4Read(filename)) == MP4_INVALID_FILE_HANDLE )
{
@menski
menski / 11-truecrypt-mount.rules
Created June 7, 2012 20:39
udev truecrypt automount
KERNEL!="sd[c-z]*", GOTO="mounttruecrypt_end"
# devices
ATTRS{serial}=="5743415A4131373736393036", ENV{dir_name}="ext"
ATTRS{serial}=="NA056AG5", KERNEL=="sd?1", ENV{dir_name}="mobile"
# mounttruecrypt
ACTION=="add", ENV{dir_name}!="", SYMLINK+="%E{dir_name}", RUN+="/usr/sbin/mounttruecrypt -u menski /dev/%E{dir_name}"
ACTION=="remove", ENV{dir_name}!="", RUN+="/usr/sbin/mounttruecrypt -u menski /media/%E{dir_name} --remove"
@menski
menski / 81-thinkpad-dock.rules
Created June 7, 2012 20:43
Thinkpad udev xrandr dock event
KERNEL=="dock.0", ACTION=="change", RUN+="/usr/sbin/thinkpad-dock"
@menski
menski / gist:2959895
Created June 20, 2012 13:31
dwm 6.0 patch
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..37b1c60
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+dwm
+dwm.o
diff --git a/config.def.h b/config.def.h
index 77ff358..d22ce99 100644
@menski
menski / genipv6.py
Created July 11, 2012 20:26
Generate random IPv6 addresses
import random
import itertools
network = "2001:0db8:85a3:08d3"
N = 34 # number of permutation elements
with open('ipv6-list.txt', 'w') as f:
for addr in itertools.permutations(random.sample(range(64 ** 2), N), 4):
f.write(network + ":%04x:%04x:%04x:%04x\n" % addr)
@menski
menski / genipv6.py
Created July 11, 2012 20:50
Generate random IPv6 adresses (cartesian product)
import random
import itertools
network = "2001:0db8:85a3:08d3"
with open('ipv6-list.txt', 'w') as f:
sample = lambda x: random.sample(range(64 ** 4), x)
for addr in itertools.product(sample(100), sample(100), sample(10), sample(10)):
f.write(network + ":%04x:%04x:%04x:%04x\n" % addr)