Skip to content

Instantly share code, notes, and snippets.

View K0NRAD's full-sized avatar

Hauke K0NRAD

  • 09:28 (UTC +02:00)
View GitHub Profile
@K0NRAD
K0NRAD / RAM disk on OSX
Created August 6, 2013 09:19
create a RAM disk on OSX
# size in GB * 1024 * 2048 -> 3GB * 1024 * 2048 -> 6291456
diskutil erasevolume HFS+ "ramdisk" `hdiutil attach -nomount ram://6291456`
@K0NRAD
K0NRAD / GetLocationOfClassTest.java
Last active August 29, 2015 13:56
Where does the JVM a class loaded
public class GetLocationOfClassTest {
@Test
public void getClasspathOfClass() throws Exception {
String locationOfThisClass = getLocationOfClass(this.getClass());
String locationOfJUnit4Class = getLocationOfClass(JUnit4.class);
String expectedLocationOfThisClass = "/Users/<User>/Documents/project.java/studies/target/test-classes/";
String expectedLocationOfJUnit4Class = "/Users/<User>/.m2/repository/junit/junit/4.11/junit-4.11.jar";
@K0NRAD
K0NRAD / JoinerTest.java
Created February 9, 2014 13:00
guava joiner examples
@Test
public void testJoiner() throws Exception {
List<String> texts = Lists.newArrayList("eins", null, "drei", "vier", "fünf", "sechs", "sieben", null);
String joined;
String expected;
joined = Joiner.on(";")
.skipNulls()
.join(texts);
@K0NRAD
K0NRAD / unlock.sql
Created February 9, 2014 20:21
Unlock Oracle user account
SELECT username, account_status FROM dba_users;
ALTER USER <user> ACCOUNT UNLOCK;
ALTER USER <user> IDENTIFIED BY <password>;
SELECT profile FROM dba_users WHERE username = <user>;
ALTER profile DEFAULT LIMIT FAILED_LOGIN_ATTEMPTS UNLIMITED PASSWORD_LIFE_TIME UNLIMITED;
@K0NRAD
K0NRAD / DateFormatFunction.java
Created February 10, 2014 07:02
guava DateFormatFunction
public class DateFormatFunction implements Function<Date,String> {
private String format;
public formatFunction(String format) {
this.format = format;
}
@Override
public String apply(Date date) {
@K0NRAD
K0NRAD / EProductivityPlanType.java
Created February 12, 2014 18:20
Jave EE usage of @qualifier #- create type enum #- create qualifier annotation #- create service interface #- create implementations of service interface #- inject and use qualifier annotation to specify the correct service
public enum EProductivityPlanType {
TARGET, ACTUAL
}
@K0NRAD
K0NRAD / iban.groovy
Created March 23, 2014 20:24
create iban number
// 11111111112222222222333333
// 01234567890123456789012345
// |--------------------------|
// ABCDEFGHIJKLMNOPQRSTUVWXYZ
// DE = 1314, FR = 1527, IT = 1829
def iban(bic, ban, country) {
ban = ban.padLeft(10,'0')
bic = bic.padLeft(8,'0')
def checkSum = "${(98 - new BigInteger(bic+ban+country+'00').remainder(97))}".padLeft(2, '0')
@K0NRAD
K0NRAD / securityDomainPassword.cmd
Created March 24, 2014 20:45
Create password for WildFly security domain
@echo off
set classpath=modules\system\layers\base\org\picketbox\main\picketbox-4.0.20.Final.jar
set mainclass=org.picketbox.datasource.security.SecureIdentityLoginModule
java -classpath %classpath% %mainclass% %1
@K0NRAD
K0NRAD / beans.xml
Created March 29, 2014 22:58
Empty beans.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="all">
</beans>
@K0NRAD
K0NRAD / added_archetypes_idea.txt
Last active October 13, 2015 12:57
Add archetypes stored in IntelliJ IDEA on Mac
On a Mac, the path is ~/Library/Caches/IntelliJIdea14/Maven/Indices/UserArchetypes.xml