Skip to content

Instantly share code, notes, and snippets.

View mikaelhg's full-sized avatar
🏠
Working from home

Mikael Gueck mikaelhg

🏠
Working from home
View GitHub Profile
@mikaelhg
mikaelhg / DaoUsage.java
Created November 26, 2011 10:08
Spring Data JPA example snippets
@Autowired
private ExampleDao dao;
model.put("examples", dao.findAll());
model.put("comedies", dao.findByNameLike("%y%"));
@mikaelhg
mikaelhg / CustomizableExpressionTraceInterceptor.java
Created November 29, 2011 18:57
Customizable Expression Trace Interceptor
package gumi.spring;
import java.util.HashMap;
import java.util.Map;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.logging.Log;
import org.springframework.aop.interceptor.AbstractTraceInterceptor;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
@mikaelhg
mikaelhg / basics.md
Created July 24, 2012 20:29
Ethical professional developers optimize for business results

Ethical professional developers optimize for business results per unit of resources over product or project lifecycles, balanced risk profiles over project portfolios, and the ablity to scale investment into a given project both up and down as the business environment changes.

Let's break this down.

Ethics

The virtue of a professional acting ethically is that this allows for trust in working relations between colleagues and organizations, which in turn makes working together significantly more efficient, as there is significantly less need to verify and control. The profession of software development has plenty of in-house codes of conduct, as well as the codified ACM "Software Engineering Code of Ethics and Professional Practice".

Many of the everyday ethical questions break down to the form: should I do A which is best for me, B which is best for my employer, or C which is best for the client. Very rarely you add D, best for our society, when C is clearly detrimental to the society. Unless D is releva

public class Foo {
public void test1() {
long timeout = System.currentTimeMillis() + 500;
int i = 0;
while (System.currentTimeMillis() < timeout) {
System.out.println(i++);
try {Thread.sleep(50);} catch (Exception ex) {}
}
}
@mikaelhg
mikaelhg / Boot.scala
Created September 22, 2012 09:28
Scalate PlantUML + ditaa macro
package scalate
import org.fusesource.scalamd.{MacroDefinition, Markdown}
import java.util.regex.Matcher
import org.fusesource.scalate.wikitext.Pygmentize
import org.fusesource.scalate._
import util.Log
import net.sourceforge.plantuml.{FileFormat, FileFormatOption, SourceStringReader}
import java.io.ByteArrayOutputStream
import java.nio.charset.StandardCharsets
@mikaelhg
mikaelhg / fix-vb-mouse-glitch.sh
Created November 20, 2012 11:49
Fix VirtualBox mouse jump glitch
#!/bin/bash
# Fix glitching mouse with VirtualBox + Ubuntu 12.10:
# https://bbs.archlinux.org/viewtopic.php?id=145960&p=2
# https://www.virtualbox.org/ticket/10853
# https://bugs.freedesktop.org/show_bug.cgi?id=54353
xinput set-prop "VirtualBox mouse integration" "Coordinate Transformation Matrix" 0.5 0 0 0 0.5 0 0 0 1.0
xinput set-prop "VirtualBox mouse integration" "Coordinate Transformation Matrix" 1.0 0 0 0 1.0 0 0 0 1.0
@mikaelhg
mikaelhg / mysql_to_jpa.py
Created November 25, 2012 11:37
Automatically generate / reverse engineer a MySQL database and generate Scala JPA classes for tables
#!/usr/bin/python
# -*- coding: utf-8 -*-
from sqlalchemy import create_engine
from sqlalchemy.engine import reflection
from datetime import datetime
engine = create_engine('mysql://username:@localhost/foobar')
insp = reflection.Inspector.from_engine(engine)
@mikaelhg
mikaelhg / FIXME.txt
Last active December 11, 2015 22:59
Fix some Camel Jetty documentation examples
http://camel.apache.org/jetty.html
incorrect:
<bean id="jetty" class="org.apache.camel.component.jetty.JettyHttpComponent">
<property name="socketConnectorProperties">
<properties>
<property name="acceptors" value="4"/>
<property name="maxIdleTime" value="300000"/>
</properties>
</property>
@mikaelhg
mikaelhg / AutocloseableDemo.java
Created February 13, 2013 08:27
AutocloseableDemo
package com.gueck.dogdash;
public class AutocloseableDemo {
private static class CreateException extends RuntimeException {}
private static class CloseException extends RuntimeException {}
private static class OperationException extends RuntimeException {}