Skip to content

Instantly share code, notes, and snippets.

View jarek-przygodzki's full-sized avatar

Jarek Przygódzki jarek-przygodzki

View GitHub Profile
import java.io._
import java.net._
object Main {
trait StreamTypeInferencer[A, B]
object StreamTypeInferencer {
implicit object InputStreamInputStream
extends StreamTypeInferencer[InputStream, InputStream]
implicit object InputStreamBufferedInputStream
extends StreamTypeInferencer[BufferedInputStream, InputStream]
@benelog
benelog / ConnectionMonitor.java
Last active September 3, 2021 19:18
Btrace scripts
import static com.sun.btrace.BTraceUtils.*;
import com.sun.btrace.BTraceUtils.Aggregations;
import com.sun.btrace.BTraceUtils.Sys;
import com.sun.btrace.aggregation.Aggregation;
import com.sun.btrace.aggregation.AggregationFunction;
import com.sun.btrace.annotations.BTrace;
import com.sun.btrace.annotations.Duration;
import com.sun.btrace.annotations.Kind;
import com.sun.btrace.annotations.Location;
import com.sun.btrace.annotations.OnEvent;
@etorreborre
etorreborre / gist:1371518
Created November 16, 2011 21:40
Tagged Epochtime and Daytime
package object time {
// Unboxed newtypes, credit to @milessabin and @retronym
type Tagged[U] = { type Tag = U }
type @@[T, U] = T with Tagged[U]
class Tagger[U] { def apply[T](t : T) : T @@ U = t.asInstanceOf[T @@ U] }
def tag[U] = new Tagger[U]
trait Day
@nicerobot
nicerobot / jstatd.sh
Created November 18, 2011 00:01
Run jstatd w/o error 'access denied (java.util.PropertyPermission java.rmi.server.ignoreSubClasses write)'
#!/bin/sh
policy=${HOME}/.jstatd.all.policy
[ -r ${policy} ] || cat >${policy} <<'POLICY'
grant codebase "file:${java.home}/../lib/tools.jar" {
permission java.security.AllPermission;
};
POLICY
jstatd -J-Djava.security.policy=${policy} &
@jasonrudolph
jasonrudolph / git-branches-by-commit-date.sh
Created February 12, 2012 20:40
List remote Git branches and the last commit date for each branch. Sort by most recent commit date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
@jzi96
jzi96 / Oracle delete all tables in schema.sql
Created May 23, 2012 06:05
Oracle delete all tables in schema (data)
SET SERVEROUTPUT ON
exec dbms_output.enable(1000000);
DECLARE
v_typ VARCHAR2(32);
v_name VARCHAR2(32);
v_constraint VARCHAR2(32);
v_sql VARCHAR2(100);
CURSOR c_objekte IS
SELECT typ, NAME
@jboner
jboner / latency.txt
Last active May 13, 2024 12:48
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
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 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@ralfstx
ralfstx / comp-repo.sh
Created June 8, 2012 10:16
Tool to maintain p2 composite repositories
#!/bin/bash
#
# Tool to maintain p2 composite repositories
USAGE="Usage:
`basename "$0"` <repo-dir> [options] operation, operation ...
Options:
--name <repo name>
the repository name
--eclipse <eclipse install dir>
@nicoulaj
nicoulaj / clean-hsperfdata.sh
Created August 7, 2012 15:08
Clean Java hsperfdata files
#!/bin/sh
# Looks for /tmp/hsperfdata_* files leaved by unclean Java processes
# shutdowns and remove them.
# This should be executed by a user without sufficient rights to delete
# other users files...
for hsperfdata in /tmp/hsperfdata_*/*; do
ps -p `basename ${hsperfdata}` &> /dev/null || rm -vf $hsperfdata
done