Skip to content

Instantly share code, notes, and snippets.

@skempken
skempken / main.py
Created February 4, 2023 11:01
Mastodon Trend Replicator Script
import json
import requests
import boto3
AUTH_TOKEN = 'APPLICATION_TOKEN_FOR_PERSONAL_INSTANCE'
TARGET_INSTANCE = 'PERSONAL_INSTANCE'
TMP_FILE = '/tmp/statuses.json'
BUCKET = 'MY_S3_BUCKET'
OBJECT_NAME = 'statuses.json'
@skempken
skempken / mastodon-instanz.md
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?

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use framework "AppKit"
use scripting additions
tell application "System Settings"
activate
current application's NSWorkspace's sharedWorkspace()'s openURL:(current application's NSURL's URLWithString:"x-apple.systempreferences:com.apple.Displays-Settings.extension")
delay 0.5
@skempken
skempken / antora-playbook.yml
Last active March 17, 2022 18:38
Supplemental UI partials to have Antora Default UI show author bylines
# snippet
ui:
supplemental_files:
# adds byline
- path: partials/article.hbs
contents: ./supplemental-ui/partials/article.hbs
- path: partials/byline.hbs
contents: ./supplemental-ui/partials/byline.hbs
@skempken
skempken / swapdisplays.sh
Created February 6, 2022 11:15
Swap displays on macOS using displayplacer
#!/bin/bash
# brew install displayplacer ;-)
displayplacer list | tail -n 1 | sed "s/(0,/(tmp,/g;s/-1920/0/g;s/tmp/-1920/g" | sh -
@skempken
skempken / Detector.java
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;
import org.springframework.web.context.support.StandardServletEnvironment;
@skempken
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 '\['`
echo CURRENT_SNAPSHOT_VERSION is: $CURRENT_SNAPSHOT_VERSION
BUILD_SNAPSHOT_VERSION=`echo $CURRENT_SNAPSHOT_VERSION | sed "s/SNAPSHOT/$BUILD_NUMBER/g"`
echo BUILD_SNAPSHOT_VERSION is: $BUILD_SNAPSHOT_VERSION
mvn -s $MVN_SETTINGS versions:set -DnewVersion=$BUILD_SNAPSHOT_VERSION
@skempken
skempken / SslHttpUtil.java
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
skempken / InMemoryDbFixture.java
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
skempken / EjbInjector.java
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 http://blog.bbv.ch/2011/03/24/ejb-dependency-injection-and-unit-testing/, 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;