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);
# Lists all remote repositories
git remote -v
# Adds a new remote repsitory
git remote add koshuke git://github.com/kohsuke/hudson.git
# Removes a remote repository
git remote rm koshuke
# Fetches all commits from a remote
set branch=main
set workspace=C:\workspace\
set depot=//depot/my-project/
p4 diff -se | p4 -x - edit
p4 diff -sd | p4 -x - delete
dir C:\workspace /b /s /a-d | p4 -x - add
dir %workspace%%branch%\project-x /b /a-d | p4 -x - add
host% cd /path/to/the/parent/tree
host% du -sk * | sort -rn
hotst%df -h
less -M -e file.log file.log.? file.log.??
cat file.log file.log.? file.log.?? | less -M -N
@kkarad
kkarad / ClasspathFileListPrinter.java
Last active September 24, 2015 12:28
Prints all resources in classpath
package org.kkarad;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
public class PanelViewer {
public static void main(String[] args) {
JFrame frame = new JFrame("Gui Test");
frame.getContentPane().setLayout(new FlowLayout());
//frame.add(new PerspectivePanel());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();