Skip to content

Instantly share code, notes, and snippets.

@magro
magro / HelloMorphia.java
Created December 16, 2010 00:01
A hello world that shows how to use morphia with an immutable id type
import java.net.UnknownHostException;
import org.apache.commons.lang.builder.ToStringBuilder;
import com.google.code.morphia.Datastore;
import com.google.code.morphia.Morphia;
import com.google.code.morphia.annotations.Entity;
import com.google.code.morphia.annotations.Id;
import com.google.code.morphia.converters.SimpleValueConverter;
import com.google.code.morphia.converters.TypeConverter;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.channels.Channels;
import java.time.Instant;
import java.util.stream.Collectors;
public class Blocking {
@magro
magro / kryo-compat-report_2.22_to_2.23-20131201.010510-27.html
Last active December 29, 2015 08:09
Compatibility report created by Java API Compliance Checker (http://ispras.linuxbase.org/index.php/Java_API_Compliance_Checker) via `$ japi-compliance-checker ../libs/kryo-2.22.jar ../libs/kryo-2.23-20131125.093430-23.jar`
<!-- kind:binary;verdict:incompatible;affected:30.5;added:18;removed:131;type_problems_high:60;type_problems_medium:0;type_problems_low:0;method_problems_high:0;method_problems_medium:0;method_problems_low:0;tool_version:1.3.5 -->
<!-- kind:source;verdict:incompatible;affected:30.5;added:18;removed:131;type_problems_high:60;type_problems_medium:0;type_problems_low:0;method_problems_high:0;method_problems_medium:0;method_problems_low:0;tool_version:1.3.5 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="kryo, compatibility" />
<meta name="description" content="Compatibility report for the kryo library between 2.22 and 2.23-20131201.010510-27 versions" />
<title>
kryo: 2.22 to 2.23-20131201.010510-27 compatibility report
@magro
magro / 4_complexity.png
Last active December 27, 2015 03:59
Assets for: play! framework presentation notes blog post
4_complexity.png
@magro
magro / SpringSecurityUserRegistration.java
Last active December 21, 2015 21:48
A custom kryo serializer for the Spring Security User class - for memcached-session-manager's kryo serialization. Can be registered as customConverter in the msm config (see https://code.google.com/p/memcached-session-manager/wiki/SetupAndConfiguration), s.th. like: <Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager" ... tra…
package de.javakaffee.web.msm.serializer.kryo;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;
@magro
magro / jboss.log
Created August 16, 2013 14:15
Log output of hibernate4 sample (https://github.com/magro/jboss-as-quickstart/tree/master/hibernate4) deployment in JBoss EAP 6.1 with TRACE level enabled for JPA
14:54:45,887 INFO [org.jboss.as.repository] (management-handler-thread - 1) JBAS014900: Content added at location /opt/jboss-eap-6.1_official/standalone/data/content/0a/40dca46c50291b27bf1fafe382d0a2be4994cf/content
14:54:45,901 INFO [org.jboss.web] (ServerService Thread Pool -- 51) JBAS018224: Unregister web context: /jboss-as-hibernate4
14:54:45,917 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 54) JBAS011403: Stopping Persistence Unit Service 'jboss-as-hibernate4.war#primary'
14:54:45,919 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 54) HHH000227: Running hbm2ddl schema export
14:54:45,921 INFO [org.jboss.weld.deployer] (MSC service thread 1-5) JBAS016009: Stopping weld service for deployment jboss-as-hibernate4.war
14:54:45,925 INFO [org.hibernate.tool.hbm2ddl.SchemaExport] (ServerService Thread Pool -- 54) HHH000230: Schema export complete
14:54:45,946 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-9) JBAS010409: Unbound data sour
@magro
magro / JmxInitListener.java
Last active December 16, 2015 04:09
This class allows you to start a jmx connector server in a way that allows to connect from the outside through a firewall: the rmi communication is bound to specific ports. Additionally this solution allows you to start several jvms with the same port configurations, as the rmi registry and the connector server will be bound to a specific ip add…
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@magro
magro / nginx-debug-backtick.log
Last active December 15, 2015 08:12
snippets for blog post on SCSs integration with nginx and insights into SSI handling
2015/12/14 22:18:49 [debug] 2356#0: *976 ssi include: "/breadcrumb/1001212364/De`Longhi Cappuccino Thermo-Gläser doppelwandig 2 Stück"
2015/12/14 22:18:49 [debug] 2356#0: *976 http subrequest "/breadcrumb/1001212364/De`Longhi Cappuccino Thermo-Gläser doppelwandig 2 Stück?"
2015/12/14 22:18:49 [debug] 2356#0: *976 http posted request: "/breadcrumb/1001212364/De`Longhi Cappuccino Thermo-Gläser doppelwandig 2 Stück?"
2015/12/14 22:18:49 [debug] 2356#0: *976 http proxy header:
"GET /breadcrumb/1001212364/De`Longhi%20Cappuccino%20Thermo-Gl%c3%a4ser%20%20doppelwandig%202%20St%c3%bcck HTTP/1.1
2015/12/14 22:18:49 [debug] 2356#0: *976 http finalize request: -4, "/breadcrumb/1001212364/De`Longhi Cappuccino Thermo-Gläser doppelwandig 2 Stück?" a:0, c:7
2015/12/14 22:18:49 [debug] 2356#0: *976 http proxy status 400 "400 Bad Request"
2015/12/14 22:18:49 [debug] 2356#0: *976 http proxy header: "X-Error: Illegal character in path at index 25: /breadcrumb/1001212364/De`Longhi%20Cappuccino%20Thermo-Gl%c3%a4ser%20%20doppe
@magro
magro / Proxy.scala
Created September 30, 2015 10:07
Scala proxy for lazy values
import java.util.concurrent.atomic.AtomicReference
import scala.reflect.ClassTag
import java.lang.reflect.{Proxy => JProxy, Method, InvocationHandler}
/**
* Creates a proxy for a lazy value, in a project moving to dependency injection this
* was meant to replace legacy stuff where at app start time dependencies were loaded
* too early.
*
@magro
magro / MorphiaEmbeddedInheritanceTest.java
Created January 5, 2012 15:00
Test that shows a issue of morphia with an inheritance stucture of @Embedded objects.
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
import com.google.code.morphia.Morphia;
import com.google.code.morphia.annotations.Converters;
import com.google.code.morphia.annotations.Embedded;
import com.google.code.morphia.annotations.Entity;
import com.google.code.morphia.annotations.Id;