Skip to content

Instantly share code, notes, and snippets.

View zuzzas's full-sized avatar

Andrey Klimentyev zuzzas

View GitHub Profile
@zuzzas
zuzzas / flock.sh
Last active August 29, 2015 14:24
Flock example
#!/bin/bash
# Function declaration
lock() {
exec 200>/var/lock/.myscript.exclusivelock
flock -n 200 \
&& return 0 \
|| return 1
@zuzzas
zuzzas / jstackh.pl
Last active August 29, 2015 14:24
Easily convert nid to pid (props to http://stackoverflow.com/a/1199127). Just pipe jstack output to this script.
#!/usr/bin/perl -w
while (<>) {
if (/nid=(0x[[:xdigit:]]+)/) {
$lwp = hex($1);
s/nid=/pid=$lwp nid=/;
}
print;
}