Skip to content

Instantly share code, notes, and snippets.

View schakko's full-sized avatar

Schakko schakko

View GitHub Profile
@schakko
schakko / reordering_postgres_rows_and_fixing_gaps.md
Last active December 1, 2018 10:07
Reordering of Postgres table rows and fixing gaps afterwards

This describes a naive implementation how to fix missing gaps after a reordering. Table tbl contains two columns. The position column is of type decimal to make the reordering easier.

CREATE TABLE tbl(key varchar(255), position decimal(5,4));

We fill the table with the following statements

INSERT INTO tbl values('A', 1.0);
INSERT INTO tbl values('B', 2.0);
INSERT INTO tbl values('C', 3.0);
@schakko
schakko / monitord.xml
Last active October 1, 2015 11:52
XML configuration for monitord, using POCSAG and ActiveMQ failover. It uses snd_aloop as input device.
<?xml version="1.0" encoding="ISO-8859-1">
<monitordconfig version="1.0">
<name>monitord</name>
<logfile>/var/log/monitord.log</logfile>
<loglevel>DEBUG</loglevel>
<soundcard num="1">
<device>plughw:Loopback,0,0</device>
<status>1</status>
<baud>48000</baud>
<name>Loopback</name>
@schakko
schakko / autounattend.xml
Created April 24, 2015 11:13
Hard disk configuration for installing Windows 2012 R2 in VirtualBox without hitting the 0x80042565 error
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<!-- only relevant information to install Windows 2012 R2 in VirtualBox without hitting 0x80042565 error -->
<settings pass="windowsPE">
<component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DiskConfiguration>
<WillShowUI>OnError</WillShowUI>
<Disk wcm:action="add">
<DiskID>0</DiskID>
<WillWipeDisk>true</WillWipeDisk>
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;