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 / 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 / GuavaCacheMXBean.java
Created September 25, 2013 16:12
Expose Google's guava Cache vie JMX
public interface GuavaCacheMXBean {
public long getRequestCount();
public long getHitCount();
public double getHitRate();
public long getMissCount();
@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 / dcache-billing-demo.json
Last active August 29, 2015 14:01
dCache-billing-demo
{
"title": "Billing",
"services": {
"query": {
"list": {
"0": {
"query": "proto:gftp",
"alias": "GridFTP",
"color": "#7EB26D",
"id": 0,
@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 / perfect-desktop-with-sl6.md
Last active August 29, 2015 14:03
Perfect (or so) Desktop with SL 6.5 (CentOS 6.5)

Perfect (or so) Desktop with SL (CentOS) 6.5

Install from Live CD

Post-install:

Disable unneeded services:

@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];
}