Skip to content

Instantly share code, notes, and snippets.

View K0NRAD's full-sized avatar

Hauke K0NRAD

  • 00:39 (UTC +02:00)
View GitHub Profile
@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 / 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 / add-user.txt
Created June 14, 2014 19:09
WildFly add user with different jboss.domain.base.dir
$JBOSS_HOME/bin/add-user.sh -sc /xyz/standalone/ -dc /xyz/domain/
@K0NRAD
K0NRAD / navbar_ctrl.js
Last active August 29, 2015 14:05
Handle active state of bootstrap navbar
/*
USAGE:
<div class="header">
<ul class="nav nav-pills pull-right" ng-controller="NavbarCtrl">
<li ng-class="{active: isActive('/')}"><a ng-href="#">Home</a></li>
<li ng-class="{active: isActive('/about')}"><a ng-href="#/about">About</a></li>
</ul>
<h3 class="text-muted">My APP</h3>
@K0NRAD
K0NRAD / .bash_profile
Created September 5, 2014 12:50
OSX show / hide hidden files in finder
alias showFiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app'
alias hideFiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app'