Skip to content

Instantly share code, notes, and snippets.

Avatar

Jonas Berlin xkr47

View GitHub Profile
@xkr47
xkr47 / log4j.properties
Created Aug 29, 2013
log4j configuration with different colors for different log levels - also works with Eclipse Ansi Console: http://mihai-nita.net/2013/06/03/eclipse-plugin-ansi-in-console/
View log4j.properties
log4j.debug=false
# Default level is INFO
log4j.rootLogger=INFO,StdoutErrorFatal,StdoutWarn,StdoutInfo,StdoutDebug,StdoutTrace
# and for com.some.package.* log everything
log4j.logger.com.some.package=TRACE
log4j.appender.StdoutErrorFatal=org.apache.log4j.ConsoleAppender
log4j.appender.StdoutErrorFatal.layout=org.apache.log4j.PatternLayout
@xkr47
xkr47 / README.md
Last active Oct 19, 2020
Script for moving/renaming files/directories arbitrarily in whole git history of single branch, using perl expressions
View README.md

Install into PATH e.g. $HOME/bin/ as "git-filter-mv" and chmod a+rx git-filter-mv

It works with any special characters in filenames like tabs and linefeeds. It works with empty commits.

Based on example from git-filter-branch manpage.

If you want to print debug messages, use STDERR e.g. print STDERR "File: $_\n";

Examples:

@xkr47
xkr47 / xkr-clipboard.pl
Created Oct 6, 2015
rxvt-unicode: Enable Ctrl-Insert/Ctrl-Shift-c to copy to CLIPBOARD (as opposed to PRIMARY) selection. Pasting works by Meta-<middle button>
View xkr-clipboard.pl
#! perl
# Store this file as /usr/lib/urxvt/perl/xkr-clipboard
#
# To enable, add to ~/.Xresources:
#
# URxvt.perl-ext-common: default,xkr-clipboard
# URxvt.iso14755: false
# URxvt.keysym.Shift-Control-C: perl:clipboard:copy
# URxvt.keysym.Control-Insert: perl:clipboard:copy
@xkr47
xkr47 / letsencrypt-jetty.sh
Last active Sep 26, 2020
How to use Letsencrypt certificate & private key with Jetty
View letsencrypt-jetty.sh
# input: fullchain.pem and privkey.pem as generated by the "letsencrypt-auto" script when run with
# the "auth" aka "certonly" subcommand
# convert certificate chain + private key to the PKCS#12 file format
openssl pkcs12 -export -out keystore.pkcs12 -in fullchain.pem -inkey privkey.pem
# convert PKCS#12 file into Java keystore format
keytool -importkeystore -srckeystore keystore.pkcs12 -srcstoretype PKCS12 -destkeystore keystore.jks
# don't need the PKCS#12 file anymore
@xkr47
xkr47 / git-alias.sh
Last active Sep 25, 2020
"git alias" command for adding/removing/editing git aliases conveniently
View git-alias.sh
#!/bin/bash
set -eo pipefail
usage () {
cat <<'EOF'
usage:
git alias [<options>]
git alias [<options>] name
git alias [<options>] name newvalue
@xkr47
xkr47 / README.md
Last active Aug 3, 2020
Logitech TrackMan Marble FX scroll wheel patch for the Linux kernel
View README.md

Logitech TrackMan Marble FX scroll wheel patch for the Linux kernel

NOTE I now have a standalone driver available here which is easier to install: https://github.com/xkr47/marblefx

This patch alters the usbmouse kernel driver to support a "scroll wheel mode" using the fourth button (the red button) when connected through a "ID 04d9:1400 Holtek Semiconductor, Inc. PS/2 keyboard + mouse controller" usb-to-ps2 adapter. No idea how things work with other adapters.

It seems the fourth button generates events, but the state of the button is not represented in any bits (at least by said usb-to-ps2 adapter).

@xkr47
xkr47 / DynamicCertOptions.java
Last active Jul 28, 2020
An attempt to support TLS SNI in vertx with dynamic reconfiguration support
View DynamicCertOptions.java
import io.vertx.core.Vertx;
import io.vertx.core.net.KeyCertOptions;
import javax.net.ssl.*;
import java.net.Socket;
import java.security.*;
import java.security.cert.X509Certificate;
public class DynamicCertOptions implements KeyCertOptions {
@xkr47
xkr47 / focusrite-scarlett-linux.md
Last active Jul 20, 2020
Focusrite Scarlett Linux support 2019-07-29
View focusrite-scarlett-linux.md

Focusrite Scarlett Linux support 2019-07-29

1st gen <2012

  • Solo
  • Studio
  • 2i2
  • 2i4
  • 6i6 1235:8012 since Linux 3.19
@xkr47
xkr47 / Cargo.toml
Last active Jun 19, 2020
Seriously funny rust error message
View Cargo.toml
[package]
name = "x"
version = "0.1.0"
edition = "2018"
[dependencies]
dbus = "0.8.1"
@xkr47
xkr47 / cvsignore2git.sh
Last active Apr 5, 2020
cvsignore -> gitignore converter
View cvsignore2git.sh
#!/bin/sh
if [ ! -d .git ]; then
echo ERROR: Please run this in the root of the git repository
exit 1
fi
cat > .gitignore <<'EOF'
# CVS global ignores
RCS
You can’t perform that action at this time.