Skip to content

Instantly share code, notes, and snippets.

View JensRantil's full-sized avatar

Jens Rantil JensRantil

View GitHub Profile
@JensRantil
JensRantil / FirstName.java
Created February 8, 2014 09:25
As close as one can get to a Java typedef. That is, wrapping a type. Lots of boilerplate code for something that could be so short and concise.
/**
* A first name.
* <p>
* In other programming languages, you would be able to write something like
* <code>
* typedef FirstName String;
* </code>
*/
public class FirstName {
private String firstName;
description "my application"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 360 180
setuid myuser
setgid mygroup
chdir /my/directory
exec /bin/sleep 60
description "my application"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 360 180
setuid myuser
setgid mygroup
script
chdir /my/directory
exec java -jar /srv/my.jar
@JensRantil
JensRantil / NullcheckAbstractionsExamples.java
Last active August 29, 2015 14:03
Nullcheck abstraction ideas.
public class NullcheckAbstractionsExamples {
public void Example1( ) {
NullablePair pair;
pair = Nullables.pair(myObject1.getProperty(), myObject2.getProperty());
if (pair.anyNull())
return pair.compare();
pair = Nullables.pair(myObject1.getProperty().getSubProperty(), myObject2.getProperty().getSubProperty());
if (pair.anyNull())
@JensRantil
JensRantil / gist:0d905461cf018c5e1ab7
Created July 30, 2014 19:46
Broken SSL verification Datastax
root@precise64:/etc/apt/sources.list.d# curl -L https://debian.datastax.com/debian/repo_key | sudo apt-key add -
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
More details here: http://curl.haxx.se/docs/sslcerts.html
curl performs SSL certificate verification by default, using a "bundle"
of Certificate Authority (CA) public keys (CA certs). If the default
bundle file isn't adequate, you can specify an alternate file
@JensRantil
JensRantil / gist:ec43622c26acb56e5bc9
Created August 5, 2014 12:19
Issue with ALLOW FILTERING
cqlsh:tink> CREATE TABLE a(a uuid, b timeuuid, c uuid, PRIMARY KEY (a,b));
cqlsh:tink> INSERT INTO a(a,b,c) VALUES (48ecda32-b32a-43ae-bd30-ecf4819fb83c, 468ee710-1bd2-11e4-b2a2-0179c71c52ea, 73e54e00-ad66-4f88-8dd8-92bc1c648e9d);
cqlsh:tink> INSERT INTO a(a,b,c) VALUES (48ecda32-b32a-43ae-bd30-ecf4819fb83c, 468ee711-1bd2-11e4-b2a2-0179c71c52ea, 2fdb7e7a-cf9d-43a4-aa86-7820336fc363);
cqlsh:tink> INSERT INTO a(a,b,c) VALUES (48ecda32-b32a-43ae-bd30-ecf4819fb83c, 468ee712-1bd2-11e4-b2a2-0179c71c52ea, 18551ae7-b117-4b41-b5fa-fd233e2425dd);
cqlsh:tink> SELECT * FROM a;
a | b | c
--------------------------------------+--------------------------------------+--------------------------------------
48ecda32-b32a-43ae-bd30-ecf4819fb83c | 468ee710-1bd2-11e4-b2a2-0179c71c52ea | 73e54e00-ad66-4f88-8dd8-92bc1c648e9d
48ecda32-b32a-43ae-bd30-ecf4819fb83c | 468ee711-1bd2-11e4-b2a2-0179c71c52ea | 2fdb7e7a-cf9d-43a4-aa86-7820336fc363
@JensRantil
JensRantil / gist:f040e900edc8a2ee6192
Created August 19, 2014 09:36
spring-data-cassandra init example
package com.project.common.config;
t
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import org.springframework.cassandra.core.keyspace.CreateKeyspaceSpecification;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.cassandra.config.CassandraClusterFactoryBean;
import org.springframework.data.cassandra.config.CassandraSessionFactoryBean;
@JensRantil
JensRantil / intrusion-presentation.txt
Last active August 29, 2015 14:07
Intrusion presentation (present with `tpp`)
--withborder
--author Jens Rantil, Tink AB
--title Intrusion
--date 2014-10-06
--center If a bad day strikes you.
--newpage goal
--heading Agenda
@JensRantil
JensRantil / gist:555272209a1505a592dc
Created November 3, 2014 10:46
Jetty Bug Monitor Bug #recurse
ERROR [Monitor for Jetty bugs] 2014-11-03 11:45:16,269 JettyBugMonitor.java (line 108) Jetty bug monitor failed
java.lang.NullPointerException
at org.apache.hadoop.mapred.JettyBugMonitor.isJettySelectorThread(JettyBugMonitor.java:218)
at org.apache.hadoop.mapred.JettyBugMonitor.getJettyThreadIds(JettyBugMonitor.java:205)
at org.apache.hadoop.mapred.JettyBugMonitor.waitForJettyThreads(JettyBugMonitor.java:182)
at org.apache.hadoop.mapred.JettyBugMonitor.doRun(JettyBugMonitor.java:114)
at org.apache.hadoop.mapred.JettyBugMonitor.run(JettyBugMonitor.java:102)
@JensRantil
JensRantil / number_width_histogram.py
Created December 27, 2014 12:17
Script that generated histograms over number widths. See http://jensrantil.github.io for an article about this.
import pylab as p
import subprocess
import argparse
from collections import Counter
import numpy as np
import itertools
# See http://jensrantil.github.io/line-styles-in-matplotlib.html.
icolors = itertools.cycle('bgrcmykw')