Skip to content

Instantly share code, notes, and snippets.

View betrcode's full-sized avatar
👋

Max Wenzin betrcode

👋
View GitHub Profile
@betrcode
betrcode / remove-duplicate-logging-implementations.md
Last active December 28, 2023 10:48
How to get rid of duplicate logging implementations on classpath (slf4j, log4j12, logback)

How to find and remove duplicate logging implementations on classpath

Problem

If you have multiple logging implementations on the classpath, one will be picked in a non-deterministic ("random") way. You may see logging like this.

15:04:56.264 [ERROR] [system.err] SLF4J: Class path contains multiple SLF4J bindings.
15:04:56.265 [ERROR] [system.err] SLF4J: Found binding in [jar:file:/home/max/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-log4j12/1.7.6/6953717b9850aeb26d1b8375ca07dbd9c50eca4e/slf4j-log4j12-1.7.6.jar!/org/slf4j/impl/StaticLoggerBinder.class]
15:04:56.265 [ERROR] [system.err] SLF4J: Found binding in [jar:file:/home/max/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.2.3/7c4f3c474fb2c041d8028740440937705ebb473a/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
@betrcode
betrcode / ubuntu-clean-boot.sh
Created July 12, 2018 07:35
Clean up /boot on Ubuntu
#
# Taken from: https://askubuntu.com/questions/345588/what-is-the-safest-way-to-clean-up-boot-partition
#
# Command line method:
# First check your kernel version, so you won't delete the in-use kernel image, running:
uname -r
# Now run this command for a list of installed kernels:
@betrcode
betrcode / ubuntu-version.sh
Created July 12, 2018 07:24
Display the version of Ubuntu. Both numeric kernel, release version and release codename.
uname -r && lsb_release -a
@betrcode
betrcode / move-merge-git-repositories-and-keep-history
Created September 6, 2017 11:27
Merge Git Repositories and Preseve Commit History by Scott W Bradley
# ...First create a new empty repository on github named 'simpsons'...
# Clone all the repos to work with
$ cd ~/src
$ git clone git@github.com:scottwb/homer.git
$ git clone git@github.com:scottwb/bart.git
$ git clone git@github.com:scottwb/simpsons.git
# Copy over homer to simpsons
$ cd homer
@betrcode
betrcode / gist:ee2aa80da90f60467bff5617f6e15e03
Created June 7, 2017 12:32
Log progress of a InputStream
private static Timer logStreamProgress(CountingInputStream countingInputStream) {
final TimerTask timerTask = new TimerTask() {
int counter = 0;
@Override
public void run() {
LOGGER.info("Loaded {} in {} seconds", byteCountToDisplaySize(countingInputStream.getByteCount()), counter);
counter++;
}
};
@betrcode
betrcode / install-idea.sh
Last active March 25, 2017 12:39
Installs IntelliJ from tar.gz file on Ubuntu
#!/bin/bash
cd ~
default_download_dir=$(cat $HOME/.config/user-dirs.dirs | grep XDG_DOWNLOAD_DIR= | awk -F '=' '{print $2}' | tr -d '"')
echo "Default download dir is: ${default_download_dir}"
download_dir=${1:-$default_download_dir}
download_dir=$(eval echo $download_dir) # Expand environment variables
echo "Searching for the latest idea*.tar.gz in download dir: ${download_dir}"
@betrcode
betrcode / README.md
Created June 24, 2014 06:36
Using Python to check if remote port is open and accessible.
@betrcode
betrcode / list-to-stringified-id-list.sc
Created March 12, 2014 09:16
Convert a List[int] with integer ids to a stringified list of stringified keys in Scala
s"[${p.channels.map(id => s"'$id'").mkString(",")}]",
@betrcode
betrcode / dict-to-stringified-key-list.py
Created March 12, 2014 09:09
Convert a dict with integer keys to a stringified list of stringified keys in Python
channels = {1: 'SVT1', 2: 'SVT2', 3: 'TV3', 4: 'Kanal 4'}
str(map(str, channels.keys()))
@betrcode
betrcode / Timestamp on Windows cmd prompt
Created March 10, 2014 08:12
Timestamp on Windows cmd prompt
set PROMPT=$T $P$G