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 / find_jar.java
Created October 9, 2013 10:40
find from which jar some class is taken. Example: $ java -cp .:/$CLASSPATH find_jar org.slf4j.Logger file:/xxxx/classes/slf4j-api-1.7.5.jar $
import java.security.CodeSource;
public class find_jar {
public static void main(String[] args) throws Exception {
if (args.length != 1 ) {
System.err.println("Usage: find <class name>");
System.exit(1);
}
Class c = Class.forName(args[0]);
CodeSource codeSource = c.getProtectionDomain().getCodeSource();
@kofemann
kofemann / Locks.java
Last active December 31, 2015 00:39
Locks in try-with-resource semantics
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
/**
* A utility class to use locks with try-with-resource semantics:
* <pre>
* import static Locks.withLock;
* import Locks.AutoLock;
*
@kofemann
kofemann / avg.awk
Last active August 29, 2015 14:01
Calculating Running Average with AWK
BEGIN {
avg = 0.0
sigma = 0.0
}
{
v = $1
avg = (avg*(NR - 1) + v) / NR
sigma = (sigma*(NR - 1) + v*v) / NR
}
@kofemann
kofemann / 00-Pentax-k50.lrtemplate
Created August 17, 2014 19:46
Lightroot import preset for Pentax-K50
s = {
id = "9B3C1961-C7B7-4C03-AD92-D4AE6440655B",
internalName = "00-Pentax-k50",
title = "00-Pentax-k50",
type = "Develop",
value = {
settings = {
AutoLateralCA = 1,
ChromaticAberrationB = 0,
ChromaticAberrationR = 0,
@kofemann
kofemann / Bitmap.java
Created October 9, 2014 08:44
A vector of bits backended with a byte array.
import java.util.Arrays;
public class Bitmap {
private final byte[] _bitmap;
public Bitmap(int size) {
_bitmap = new byte[size];
}
@kofemann
kofemann / dcap-vs-nfs.gp
Last active August 29, 2015 14:10
sript to plot cms job efficiency
set key off
set yrange [0:1]
set xrange [:24]
set ylabel "Efficiency (cpu/wall time)"
set xlabel "execution time (hour)"
set xtics rotate
#set xdata time
set multiplot layout 1,2 rowsfirst title "CMS job efficiency by access protocol"
stats 'w07' using 3 nooutput
@kofemann
kofemann / init-single-node-ceph.sh
Last active October 5, 2020 00:04
Single node CEPH setup
#
# Enable CEPH repos as described at http://ceph.com/docs/master/install/get-packages/#rpm
# Install ceph-deploy package
#
export DATA_DEV=sdb
export JRNL_DEV=sdc
export FS_TYPE=xfs
export CEPH_S_NODE=ceph-s
export CEPH_RELEASE=giant
@kofemann
kofemann / tshark-recepies.sh
Last active April 30, 2020 16:39
tshark recepies
dumpcap -p -q -w - -f "port 2049 or tcp portrange 7000-10000" | \
tshark -n -r - -q -Y rpc.replystat -Tfields -E header=y -e frame.time -e frame.number -e ip.src -e ip.dst -e nfs.main_opcode -e rpc.time
# show NFS nfs requests slower that 5ms
tshark -f "port 2049" -Y "rpc.time > 0.005" -i any -T fields -e frame.number -e frame.time_delta -e ip.src -e ip.dst -e col.Protocol -e rpc.time -e col.Info
@kofemann
kofemann / 10G-sysctl.conf
Last active January 18, 2025 16:00
sysctl configuration for 10GE ethernet
#
# Based on info providef at http://fasterdata.es.net/
#
# allow testing with buffers up to 64MB
net.core.rmem_max = 67108864
net.core.wmem_max = 67108864
# Enable memory auto tuning
net.ipv4.tcp_moderate_rcvbuf = 1
@kofemann
kofemann / histo.py
Last active August 25, 2018 20:24
A python script to print a histogram
#!/usr/bin/env python
"""
Print a histogram of word distribution. Takes single word per line from stdin
and prints dtrace output like histogram:
$ echo "some text with some text fields as text" | tr -s '[:space:]' '\n' | ./histo.py 10
text | 3 | ##################################################
some | 2 | #################################
with | 1 | ################