Skip to content

Instantly share code, notes, and snippets.

View kofemann's full-sized avatar
Working on the next great thing....

Tiramisu Mokka kofemann

Working on the next great thing....
View GitHub Profile
@kofemann
kofemann / mkfile.py
Created January 12, 2012 14:41
mkfile utility, like on Solaris.
#!/usr/bin/env python
"""
A small utility to create a file of specified size:
$ mkfile 100g
"""
import sys
import time
import os
@kofemann
kofemann / hexdump.py
Created April 4, 2012 15:45
A program which dumps the content of a file in HEX format
#!/usr/bin/env python
# hexdump.py
'''A program which dumps the content of a file in HEX format like:
$ ./hexdump.py hexdump.py
00000 23 21 2f 75 73 72 2f 62 69 6e 2f 65 6e 76 20 70 ...usr.bin.env.p
00010 79 74 68 6f 6e 0a 0a 69 6d 70 6f 72 74 20 6d 6d ython..import.mm
00020 61 70 0a 69 6d 70 6f 72 74 20 63 6f 6e 74 65 78 ap.import.contex
00030 74 6c 69 62 0a 69 6d 70 6f 72 74 20 73 79 73 0a tlib.import.sys.
@kofemann
kofemann / adler32.py
Last active October 15, 2021 07:57
A script to calculate adler32 checksum of given files
#!/usr/bin/env python
'''A script to calculate adler32 checksum of given files'''
BLOCKSIZE=256*1024*1024
import sys
from zlib import adler32
for fname in sys.argv[1:]:
asum = 1
with open(fname,"rb") as f:
@kofemann
kofemann / xsu.sh
Created August 16, 2012 07:37
execute command as a defiend user with X forwarding
#!/bin/sh
#
# execute command as a defiend user with X forwarding
# Example:
# xsu auser gedit /some/text/file
#
if [ $# -lt 2 ]
then
echo "Usage: xsu <user> <command> [args....]"
@kofemann
kofemann / jumbo-proxy.sh
Created November 27, 2012 20:06
scrip to produce jumbo grid proxies
#!/bin/sh
N=30
ID=`id -u`
PROXY_FILE=/tmp/x509up_u${ID}
STD_OPTS="-q -rfc --voms desy"
# gen initial proxy
voms-proxy-init ${STD_OPTS}
@kofemann
kofemann / srim-pp.py
Last active December 10, 2015 17:18
post processing of the results of SRIM COLLISON.txt files
import re
import string
import math
IN = 'COLLISON1.txt'
DELIMER = '\xb3'
KeV_in_Mev=1000
data_line_re = re.compile(".+\d+\.E\+0.*")
@kofemann
kofemann / latency.py
Last active September 21, 2018 13:01
Latency Comparison Numbers.
#!/usr/bin/env python
"""
Latency Comparison Numbers
If L1 access where a one second
based on number from https://gist.github.com/jboner/2841832
"""
@kofemann
kofemann / latency.txt
Last active September 21, 2018 13:03 — forked from jboner/latency.txt
Latency Comparison Numbers
--------------------------
CPU cycle 0.3 ns
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
import re
import string
import math
from Tkinter import Tk
from Tkinter import *
from tkFileDialog import askopenfilename, asksaveasfilename
import cStringIO
IN = 'COLLISON1.txt'
@kofemann
kofemann / decode.py
Last active December 17, 2015 10:59
dCache NFS file handle decoder
#!/usr/bin/env python
import sys
import struct
import binascii
def hexToByte(h):
bytes = []
h = ''.join( h.split(" ") )