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 / 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.*")
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(" ") )
@kofemann
kofemann / ldccp.lua
Last active December 18, 2015 03:59
-----
-- Sync into dCache with dccp
-- usage:
-- lsyncd -nodaemon ldccp.lua
--
dcap = {
maxProcesses = 32,
delay = 1,
action = function(inlet)
@kofemann
kofemann / post-series..sh
Last active December 22, 2015 23:59
post a series of patches into review board
#!/bin/sh
#
# post a series of patches into review board
#
#
MASTER=master
BRANCH="$(git symbolic-ref HEAD 2>/dev/null)"
BRANCH=${BRANCH##refs/heads/}
@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 / NetorkInterfaceFtracer.java
Last active January 12, 2016 15:40
btrace script
import com.sun.btrace.annotations.*;
import com.sun.btrace.aggregation.Aggregation;
import com.sun.btrace.aggregation.AggregationKey;
import com.sun.btrace.aggregation.AggregationFunction;
import static com.sun.btrace.BTraceUtils.*;
/**
* run as:
* $ su dcache -c "/opt/btrace/bin/btrace <pid> NetorkInterfaceFtracer.java"
*/
@kofemann
kofemann / dcache-namespace.md
Last active January 27, 2016 16:20
dCache namespace requirements

dCache namespace requirements

Introduction

####This document describes requirements for dCache's namespace (directory) service. It's heavily biased on current chimera implementation.

The main role of namespace in dCache is to provide a hierarchical structure to manage and file system objects, collection of objects, aka directories, and provide an access to the metadata associated with them. Every data file in dCache has an associated object in the namespace. Typically a change of object in the namespace, like changing the object name or changing objects ownership, does not changes the state of the data file in dCache. Each object in the namespace has a unique objID. We expect that objIDs are permanent, e.q. there objID will always point to the same data file independent from it location, state in the dCache and existence. The objIDs can’t be recycled and reused for new objects after deletion. Every object has a set of associated attributes. Some attributes are

@kofemann
kofemann / PnfsManagerTrace.java
Created May 18, 2016 11:19
btrace script to trace db interracions
import com.sun.btrace.annotations.*;
import com.sun.btrace.aggregation.Aggregation;
import com.sun.btrace.aggregation.AggregationKey;
import com.sun.btrace.aggregation.AggregationFunction;
import com.sun.btrace.AnyType;
import static com.sun.btrace.BTraceUtils.*;
@BTrace
public class PnfsManagerTrace {