Skip to content

Instantly share code, notes, and snippets.

View schakko's full-sized avatar

Schakko schakko

View GitHub Profile
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtConstructor;
import javassist.CtField;
import javassist.CtMethod;
@schakko
schakko / EnvironmentSpecificHibernatePersistence.java
Created January 30, 2014 07:12
Dynamic properties inside persistence.xml
import java.util.HashMap;
import java.util.Map;
import javax.persistence.EntityManagerFactory;
import javax.persistence.spi.PersistenceProvider;
import javax.persistence.spi.PersistenceUnitInfo;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.ejb.HibernatePersistence;
@schakko
schakko / SpringContextInterceptor.java
Created October 11, 2013 05:48
Interceptor for use @Autowired in EJBs with global Spring application context
import javax.ejb.EJB;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.ejb.interceptor.SpringBeanAutowiringInterceptor;
import de.ckl.ejb.SpringContextBean;
/**
* {@link SpringContextInterceptor} can be used for autowiring Spring beans
* inside EJBs. Unlike {@link SpringBeanAutowiringInterceptor} the
@schakko
schakko / ApplicationBean.java
Created October 11, 2013 05:47
JSF @ManagedBean; will be loaded on web application startup and initializes the Spring application context
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import javax.servlet.ServletContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.ContextLoader;
@schakko
schakko / SpringContextBean.java
Created October 11, 2013 05:44
Global scoped Spring application context inside EJBs
import javax.ejb.Singleton;
import javax.enterprise.context.ApplicationScoped;
import org.springframework.context.ApplicationContext;
/**
* Global {@link ApplicationContext} holder which can be referenced inside any
* EJB/interceptor. This context is annotated with {@link Singleton} so there
* can only one application wide context be defined. Additionally, this class is
* marked as {@link ApplicationScoped}.
package de.neosit.spring.context;
import java.io.IOException;
import javax.servlet.ServletContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
package roboguice.config;
import android.app.*;
import android.content.ContentResolver;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.content.res.Resources;
@schakko
schakko / sources.list
Created February 23, 2013 11:20
sources.list for Ubuntu Server 12.10 CD-ROM install
#############################################################
################### OFFICIAL UBUNTU REPOS ###################
#############################################################
###### Ubuntu Main Repos
deb http://de.archive.ubuntu.com/ubuntu/ quantal main restricted universe multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ quantal main restricted universe multiverse
###### Ubuntu Update Repos
deb http://de.archive.ubuntu.com/ubuntu/ quantal-security main restricted universe multiverse
@schakko
schakko / check_microsoft_windows_software_raid.ps1
Last active January 24, 2023 17:24
A simple PowerShell script for retrieving the RAID status of volumes with help of diskpart. The nicer solution would be using WMI (which does not contain the RAID status in the Status field of Win32_DiskDrive, Win32_LogicalDisk or Win32_Volume for unknown reason) or using the new PowerShell API introduced with Windows 8 (wrong target system as o…
# A simple PowerShell script for retrieving the RAID status of volumes with help of diskpart.
# The nicer solution would be using WMI (which does not contain the RAID status in the Status field of Win32_DiskDrive, Win32_LogicalDisk or Win32_Volume for unknown reason)
# or using the new PowerShell API introduced with Windows 8 (wrong target system as our customer uses a Windows 7 architecture).
#
# diskpart requires administrative privileges so this script must be executed under an administrative account if it is executed standalone.
# check_mk has this privileges and therefore this script must only be copied to your check_mk/plugins directory and you are done.
#
# Christopher Klein <ckl[at]neos-it[dot]de>
# This script is distributed under the GPL v2 license.
@schakko
schakko / .zshrc
Created July 16, 2012 13:59
My .zshrc
# von http://vagubunt.wordpress.com
#
##### ENVIRONMENT
export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
export EDITOR=vim
export PAGER=less
export BROWSER=links
export LESS=-cex3M