Skip to content

Instantly share code, notes, and snippets.

View kkarad's full-sized avatar

Konstantinos Karadamoglou kkarad

View GitHub Profile
@kkarad
kkarad / merge-2-lines.sh
Created March 20, 2014 23:27
awk merge two clusteredlines
kostas@localhost ~$ cat fix.log
2014-03-20 10:30:20,123 123456.123456789 MassQuote
2014-03-20 10:30:20,133 123456.123456789 MassQuoteAcknowledgement
2014-03-20 10:31:20,234 123456.123456789 MassQuote
2014-03-20 10:31:20,240 123456.123456789 MassQuoteAcknowledgement
kostas@localhost ~$ cat fix.log | awk '!(NR%2){printf("%s %s %s %s\n",p,$1,$2,$3)}{p=$1" "$2}'
2014-03-20 10:30:20,123 2014-03-20 10:30:20,133 123456.123456789
2014-03-20 10:31:20,234 2014-03-20 10:31:20,240 123456.123456789
#!/bin/bash
#set -x
# Prints the date difference of "start" and "end" date in milliseconds
function datediff {
startsec=$(date -d "$1" +%s)
while [[ $startsec = 0* ]]; do startsec=${startsec#0}; done
endsec=$(date -d "$2" +%s)
while [[ $endsec = 0* ]]; do endsec=${endsec#0}; done
#Taken from: http://www.binarytides.com/linux-commands-hardware-info/
#kernel and distro
cat /etc/*release
cat /proc/version
#cpu
cat /proc/cpuinfo
#memory
package org.kkarad.metrics;
import org.HdrHistogram.Histogram;
import gnu.trove.map.hash.TObjectLongHashMap;
public class Metrics {
private static final Histogram histogram = new Histogram(3600000000000L, 3);
private static TObjectLongHashMap<String> map = new TObjectLongHashMap<String>(1000, 0.5f, -1);
# for every directory run multiple commands
find . -maxdepth 1 -type d -exec sh -c "cd {} && mvn clean && cd -" \;
#when disk is out of space identify directory which occupies most space
df -h
du -s * | sort -r -n | head -n 10