Skip to content

Instantly share code, notes, and snippets.

@olivergondza
olivergondza / d.jsf
Created June 17, 2011 21:28
JOE syntax highlight file for D programming language
# JOE syntax highlight file for D programming language
=Idle
=Bad bold red
=Comment green
=Constant cyan
=Escape bold cyan
=Type bold
=Keyword bold
=Brace magenta
@olivergondza
olivergondza / DefaultArgs.php
Created May 29, 2012 17:24
Testcase for undocumented PHP feature allowing to use default argument values in the middle of the argument list
<?php
/**
* Declarations of necessary classes and functions
*/
class ClassA {}
class ClassB {}
class ClassC {}
function argsFirst (
@olivergondza
olivergondza / refre.sh
Created July 11, 2013 19:42
Refresh FS based Jenkins update center
#!/bin/bash
if [ $# -ne 1 ]; then
echo "No update_center_id provided" >&2
echo "Usage: $0 <update_center_id>" >&2
exit 1
fi
rm -r /var/www/$1/*
@olivergondza
olivergondza / .bashrc
Last active February 23, 2019 10:36
Shell env
#!/bin/bash
# Set a default shell prompt:
function promptcmd() {
ret=$?
rst='\[\e[0m\]'
if [[ $ret = 0 ]]; then
color='\[\e[0;32m\]'
ret=''
else
@olivergondza
olivergondza / jps-monitor.sh
Last active August 29, 2015 14:12
jps-monitor
#!/bin/sh
# Make periodic snapshots of running java processes.
#
# ./jps-monitor.sh jmap -heap
# ./jps-monitor.sh jmap -heap %s # PID of monitored process will be used for %s
target="jps-monitor/"
rm -rf $target
mkdir -p $target
@olivergondza
olivergondza / query.groovy
Last active August 29, 2015 14:15
Dumpling query to group threads by locks involved - not sure it is of any use
waitingTo = [:]
waitingOn = [:]
acquired = [:]
D.runtime.threads.each {
it.acquiredLocks.each { al ->
if (acquired[al]) {
acquired[al] << it;
} else {
acquired[al] = [it];

DRAFT: Threaddump analysis with Dumpling

Final version

Dumpling CLI is fully scriptable, console based tool for threaddump analysis. It is GitHub hosted project available under the terms of MIT license. It values maximal flexibility, reliability and convenience. How can it help you?

Installation

Dumpling CLI is distributed in a form of a self contained jar file hosted on OSS Sonatype maven repository. Preferred way to install it is using dumpling.sh script:

@olivergondza
olivergondza / gist:7ff7350ccc1d97aa3fee
Created April 30, 2015 10:29
True zip can not be interrupted while in Stream.cat
"A thread" prio=10 tid=47477949280256 nid=14753
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x5f77a1e28> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:156)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1987)
at de.schlichtherle.truezip.io.Streams.cat(Streams.java:210)
at de.schlichtherle.truezip.io.Streams.copy(Streams.java:71)
at de.schlichtherle.truezip.file.TFile.cp(TFile.java:2744)
at de.schlichtherle.truezip.file.TFile.cp(TFile.java:2817)
@olivergondza
olivergondza / gist:ba0d967c5f5616f6baf5
Created June 7, 2015 16:28
Detect non-static classes in java code
for f in `find $1 -iname *.java`; do
out=`grep "class\ " $f | grep -v -e "[[:space:]]*\*" -e "[[:space:]]//" | sed '1d' | grep -v -e static`
if [ $? == 0 ]; then
echo $f
echo $out | grep --color=auto class
fi
done
lr = D.load.threaddump(D.args[0]).threads
rr = D.load.threaddump(D.args[1]).threads
lhs = lr.toSet().collectEntries { [it.nid, it] };
rhs = rr.toSet().collectEntries { [it.nid, it] };
/*
println "New:"
rhs.each { nid, thread ->
if (lhs[nid] == null) {
println thread.header;