Skip to content

Instantly share code, notes, and snippets.

skempken /
Last active August 29, 2015 13:58
Java class that initializes a HttpClient using X.509-certificate-based client authentication.
import org.apache.http.client.HttpClient;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.SingleClientConnManager;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;
skempken / gist:58fb4ab2751299adc390
Created November 12, 2014 14:55
Fix Build Number with Maven
# update version number - get current version and replace "SNAPSHOT" with BUILD_NUMBER
# Download plugins first
mvn -s $MVN_SETTINGS org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version
# Determine current number in offline mode
CURRENT_SNAPSHOT_VERSION=`mvn -o -s $MVN_SETTINGS org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -v '\['`
mvn -s $MVN_SETTINGS versions:set -DnewVersion=$BUILD_SNAPSHOT_VERSION
skempken / pom.xml
Last active January 2, 2016 09:29
JBoss Repositories required to download JBoss 5.1.0.GA via Maven
<project xmlns="" xmlns:xsi=""
skempken /
Created January 13, 2014 14:59
Class that simulates the EJB Dependency Injection mechanism. May be used to inject mock implementations in tests. Originally based on, but enhanced for subclassing.
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
skempken /
Created January 13, 2014 15:02
Creates a JPA EntityManager in code with a H2 in-memory database based on entity classes.
import org.hibernate.ejb.Ejb3Configuration;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import java.util.Collection;
import java.util.Properties;
public class InMemoryDbFixture {
private String scope;
skempken /
Last active June 15, 2021 15:15
Find all annotated classes in a package using Spring
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.type.filter.AnnotationTypeFilter;
skempken /
Created February 6, 2022 11:15
Swap displays on macOS using displayplacer
# brew install displayplacer ;-)
displayplacer list | tail -n 1 | sed "s/(0,/(tmp,/g;s/-1920/0/g;s/tmp/-1920/g" | sh -
skempken / antora-playbook.yml
Last active March 17, 2022 18:38
Supplemental UI partials to have Antora Default UI show author bylines
# snippet
# adds byline
- path: partials/article.hbs
contents: ./supplemental-ui/partials/article.hbs
- path: partials/byline.hbs
contents: ./supplemental-ui/partials/byline.hbs
skempken /
Last active November 24, 2022 10:30
There, and back again - die eigene Mastodon-Instanz

There, and back again - die eigene Mastodon-Instanz

Dieser Text fasst Überlegungen und Beobachtungen zusammen, die dazu geführt haben, auf eine eigene Mastodon-Instanz um- und wieder zurückzuziehen.

"Remember, kids: The only difference between screwing around and science is writing it down!"

-- Adam Savage (Mythbusters)

Warum hin?

skempken /
Created February 4, 2023 11:01
Mastodon Trend Replicator Script
import json
import requests
import boto3
TMP_FILE = '/tmp/statuses.json'
OBJECT_NAME = 'statuses.json'