Instantly share code, notes, and snippets.

Klaus Brunner KlausBrunner

View GitHub Profile
#!/usr/bin/env python
import paramiko
import sys
import os
client = paramiko.SSHClient()
config = paramiko.SSHConfig()
View two-main-jars-pom.xml
View wars-dist.xml
<assembly xmlns=""
<!-- A Maven assembly plugin descriptor to bundle all WAR dependencies into a zip file, including local
resource files. This is useful when you don't use EARs, but still want to package several web applications
into one big archive, plus any additional stuff (e.g. configuration files) needed for deployment. -->
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import static java.nio.file.Files.*;
* Extracts files and directories of a standard zip file to a destination directory. Requires at least Java 7.
public final class ResultFuture implements Future<Result> {
private final CountDownLatch latch = new CountDownLatch(1);
private Result value;
public boolean cancel(boolean mayInterruptIfRunning) {
return false;
View counters.cql
-- creating and using a Cassandra counter column in CQL
-- NOTE: this is CQL 2.0 syntax, it will NOT work with CQL 3 (for syntax reasons and because CQL 3.0 drops the very notion of dynamic columns...sigh)
CREATE KEYSPACE test WITH strategy_class = 'SimpleStrategy'
AND strategy_options:replication_factor = '1';
USE test;
CREATE TABLE stats (KEY text PRIMARY KEY) WITH comparator=text AND default_validation=counter;
package tv.xrm.test;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.*;
public class JacksonStreamingBindingTest {
import os
from git import Repo
import datetime as dt
import xml.etree.ElementTree as ET
repo = Repo('/home/klaus/stats/manifests')
target_file = 'manifest.xml'
assert not repo.bare

Servlets with CDI

  • get latest Jetty 9.1 archive and extract somewhere (I'll assume the Jetty root is called "jetty")
  • in jetty/lib, create a folder called "weld" and download the weld-servlet and weld-servlet-core JARs into it. For injection in listeners to work, version should be 2.2.0.Beta1 or later.
  • in jetty/modules, create a weld.mod as in this gist
  • in jetty/start.ini, add a single line containing "--module=weld" to initialise Weld

In most cases, that should be it and you can deploy any compliant CDI application, even without a web.xml. In some cases though you may need to add the old-fashioned filter entry to the web.xml. See also:

Servlets with CDI and JAX-RS 2.0 (using Jersey)

View stacktraces.txt
POST CONSTRUCT ON LISTENER CALLED test.ContextListener@1cadc928
at test.ContextListener.myPostConstructMethod(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(