Skip to content

Instantly share code, notes, and snippets.

View schakko's full-sized avatar

Schakko schakko

View GitHub Profile
@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;
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 / gambio_xtc_converter.php
Created April 5, 2011 13:26
gambio_xtc_converter
<?php
// Gambio to XTC image converter - PHP pseudocode - not tested
// Gambio product table
$sql = "SELECT id, products_name FROM gambio.products_description"
$rows = mysql_fetch_assoc(mysql_query($sql))
foreach ($rows as $row) {
// match string, e.g "printer (white)"
if (preg_match("/^(.*)\((.*)\)(.*)$", $row['products_name'], $arrMatches)) {
$color = $arrMatches[2]; // third element contains color
// do something with color, e.g
@schakko
schakko / simple_dsl.domain
Created June 27, 2011 13:15
Simple DSL with Xtext
domaene de.ckl.blog
entity Gruppe {
attribute id: int not-null primary-key
attribute name: string
reference has-many: BenutzerInGruppe with-alias:"BenutzerInGruppen"
}
entity BenutzerInGruppe {
@schakko
schakko / gist:1444002
Created December 7, 2011 18:31
DSL for protyping application w/integrated function point analysis
grammar de.ckl.Mydsl with org.eclipse.xtext.common.Terminals
generate mydsl "http://www.ckl.de/Mydsl
Model:
(domains+=Domain)*;
Operation:
(OperationContainer | OperationCreate | OperationList | OperationEdit | OperationDelete)
;
@schakko
schakko / database_migration.xml
Created December 23, 2011 15:00
Database migration workflow sample in XML
<db-workflow>
<defaults>
<var key="server">test</var>
<var key="test">${server}_name</var>
</default>
<workflows>
<workflow name="update">
<vars>
<ask_for var="server" />
<ask_for var="user" />
@schakko
schakko / build.xml
Created December 23, 2011 15:13
Database migrations with Ant
<?xml version="1.0" encoding="UTF-8"?>
<project name="db-worklflow" default="update">
<property name="db.server">remote_db_server</property>
<property name="db.database"></property>
<property name="db.username">root</property>
<property name="db.password">root</property>
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<target name="sql_execute_command" description="Executes exactly one SQL command and returns it output as 'latest_sql_result'">
<if>
@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 / server.js
Created May 5, 2012 16:48
DNS not working in forked processes
var cp = require('child_process'),
dns = require('dns');
/** server.js */
// *does* work
dns.resolve4('www.google.com', function(err, addresses) {
console.log("Resolved from service.js");
console.log(addresses);
});
@schakko
schakko / authentication.yml
Created July 16, 2012 11:44
Enable Active Directory support for Gitorious with correct Domain format
# Gitorious config/authentication.yml with Active Directory support
# This is based on https://gitorious.org/gitorious/mainline/merge_requests/181
production:
# Disable database authentication altogether
#disable_default: true
# additional methods, an array of hashes
methods:
- adapter: Gitorious::Authentication::LDAPAuthentication