Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am friek on github.
  • I am johanmulder (https://keybase.io/johanmulder) on keybase.
  • I have a public key whose fingerprint is A8A4 FB7C 97CD BE67 D2B6 55A2 697A 9950 066D 90F3

To claim this, I am signing this object:

@friek
friek / pem_to_keystore.sh
Created June 13, 2014 19:28
Converting a PEM certificate to a Java keystore
#!/bin/bash -x
# Extracted from http://stackoverflow.com/a/8224863/578745
# Name this whatever you want it to be named in the key store.
alias_name="localhost"
# First convert the pem to pkcs12 format
# The CA file contains the public certificate of the CA
# which signed the certificate. It apparently needs a name.
openssl pkcs12 \
@friek
friek / module.xml
Created June 12, 2014 08:36
Wildfly MySQL XA configuration
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file needs to be placed in wildfly_dir/modules/system/layers/base/com/mysql/main.
The mysql connector needs to go there as well.
-->
<module xmlns="urn:jboss:module:1.1" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.25.jar"/>
</resources>
<dependencies>
@friek
friek / pom.xml
Created April 22, 2014 20:58
Basic pom.xml for arquillian profiles for both the embedded weld ee container and the Wildfly app server
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>nl.localhost.test</groupId>
<artifactId>arquillian</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
@friek
friek / jboss-as7-mysql-ds.xml
Last active January 1, 2016 18:59
jboss-as7-mysql-ds.xml is part of the standalone.xml in which the MySQL datasource is defined. module.xml is the XML file necessary for configuring the MySQL connector module for JBoss AS 7.1.1. This file needs to be stored in $JBOSS_HOME/modules/com/mysql/main along with mysql-connector-java-5.1.25.jar.
<subsystem xmlns="urn:jboss:domain:datasources:1.0">
<datasources>
<datasource jndi-name="java:jboss/datasources/MySQLDS" pool-name="MySQLDS" enabled="true">
<connection-url>jdbc:mysql://*hostname*:3306/*dbname*?characterEncoding=UTF-8</connection-url>
<driver>com.mysql</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<min-pool-size>2</min-pool-size>
<max-pool-size>10</max-pool-size>
<prefill>true</prefill>
@friek
friek / mysqldefault.ini
Created October 14, 2013 20:03
Useful default MySQL settings.
[mysqld]
; Default server character set
character-set-server = utf8
; Bind to all addresses (including IPv6).
bind-address = ::
[mysql]
; Default client character set.
default-character-set = utf8
@friek
friek / SortMap.java
Last active December 17, 2015 00:38
Sort a map by value.
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
* Shamelessly stolen from
* http://stackoverflow.com/questions/109383/how-to-sort-a-mapkey-value-on-the-values-in-java/2581754#2581754
@friek
friek / skip_maven_jars.xml
Created April 13, 2013 21:12
Exclude certain jars in a maven war build.
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<!-- Exclude servlet-api-2.5.jar from the lib dir -->
<packagingExcludes>WEB-INF/lib/servlet-api-2.5.jar</packagingExcludes>
<!-- Exclude all log4j jars from the lib dir -->
<packagingExcludes>WEB-INF/lib/*log4j*.jar</packagingExcludes>
@friek
friek / JunitSkipTest.java
Last active December 16, 2015 04:49
Skip JUnit test conditionally
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
import org.junit.BeforeClass;
import org.junit.Test;
public class JunitSkipTest
{
@BeforeClass
public static void setUpTest()
{
@friek
friek / tomcat-jndi-c3p0-mysql.xml
Created March 26, 2013 22:14
Tomcat JNDI configuration for mysql and C3P0 pooling. Also runs an anti-idle query to prevent MySQL from disconnecting idle connections.
<Resource acquireIncrement="1" auth="Container" driverClass="com.mysql.jdbc.Driver"
factory="org.apache.naming.factory.BeanFactory"
idleConnectionTestPeriod="600" initialPoolSize="2"
jdbcUrl="jdbc:mysql://<server>:3306/<dbname>?characterEncoding=UTF-8"
maxIdleTime="300" maxPoolSize="3" minPoolSize="1" name="jdbc/<resource_name>"
password="<password>" preferredTestQuery="SELECT 1"
testConnectionOnCheckout="true" type="com.mchange.v2.c3p0.ComboPooledDataSource"
user="<username>" />