Skip to content

Instantly share code, notes, and snippets.

View kkarad's full-sized avatar

Konstantinos Karadamoglou kkarad

View GitHub Profile
@kkarad
kkarad / BaseSpringTest.java
Last active March 6, 2019 07:41
SpringTest setup example with mock properties loaded during context initialization
package ork.kkarad.examples;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.mock.env.MockPropertySource;
# 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
@kkarad
kkarad / fixtail.sh
Last active December 18, 2015 11:09
tail -f fix.log | tr '\1' '|' | grep "whatever"
@kkarad
kkarad / Identifiable.java
Last active December 10, 2015 23:38
Implementation of the ReversedEnumMap as described at: http://www.javaspecialists.co.za/archive/Issue113.html. The implementation uses google-guava as a dependency but it can be easily removed.
public interface Identifiable<T> {
T getId();
}
@kkarad
kkarad / PrintDnsCacheExpiryTime.java
Last active September 26, 2015 05:47
Find jvm's default dns cache expiry time
public class Foo {
public static void main(String[] args) {
System.out.println(sun.net.InetAddressCachePolicy.get());
}
}
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();
@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;
less -M -e file.log file.log.? file.log.??
cat file.log file.log.? file.log.?? | less -M -N
host% cd /path/to/the/parent/tree
host% du -sk * | sort -rn
hotst%df -h
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