Skip to content

Instantly share code, notes, and snippets.

@BastiTee
BastiTee / background-worker-with-promises.js
Created June 7, 2016 11:36
A background FIFO job queue and worker function for node.js
/*
* We have a worker function that does some expensive task, e.g., an
* I/O task or something else.
*/
worker = function ( jobId ) {
// we need to put it into a new promise object
return new Promise(function(resolve, reject) {
// It will take something between 1 and 2 seconds.
@BastiTee
BastiTee / decrypt-laterpay-paywall-spon
Last active December 5, 2016 12:26
Script to decrypt SPON / SPIEGEL Plus articles protected by LaterPay.net (execute in browser nav bar or create a bookmark with code as target)
javascript:void function(){var e=function(t,o){if(0>o)return e(t,o+26);for(var n="",d=0;d<t.length;d++){var r=t[d],c=t.charCodeAt(d);c>=33%26%26256>=c%26%26(r=String.fromCharCode(c-1)),n+=r}return n};$(".obfuscated-content").removeClass("obfuscated-content"),$(".laterpay-under-overlay").next().removeClass(),objs=$(".obfuscated");for(var t=0;t<objs.length;++t)decoded=e(objs[t].innerText),node=$(objs[t]),node.length>0%3F(contents=node.contents(),contents.each(function(t,o){decoded=e($(o).text()),$(o).is("a")||(o.textContent=decoded)})):(decoded=e(node.text()),node.text(decoded))}();
@BastiTee
BastiTee / t-nobody-cares.sh
Created March 10, 2017 13:53
Remove all of your tweets from the command line using https://github.com/sferik/t
#!/bin/bash
[ -z $( command -v t ) ] && {
echo "'t' gem (https://github.com/sferik/t) not installed."
exit 1
}
[ -z "$1" ] && {
echo "No twitter handle (e.g. @myacc) provided."
exit 1
}
@BastiTee
BastiTee / create-combined-pa-sink.sh
Created March 18, 2017 11:59
Create a combined device for all available pulseaudio sinks
#!/bin/bash
sinkname="combined"
# check root
[ $( whoami ) == "root" ] && {
echo "-- please run as regular user."
exit 1
}
@BastiTee
BastiTee / ._d3v3_chord_diagram
Last active July 24, 2017 18:02
d3v3: Chord diagram
d3v3: Chord diagram
@BastiTee
BastiTee / ._d3v4_chord_diagram
Last active July 24, 2017 18:02
d3v4: Chord diagram
d3v4: Chord diagram
@BastiTee
BastiTee / code.java
Created August 4, 2017 10:36
A reflection-based toString()-like implementation to print out all class attributes and their values as table string
/**
* A reflection-based toString()-like implementation to print out all class
* attributes and their values as table string.
*
* @param object The object to be inspected.
* @return Table string.
*/
private static String attributesToStringTable(Object object) {
Field[] attributes = object.getClass().getDeclaredFields();
// get longest attribute name
@BastiTee
BastiTee / git-author-contributions.sh
Last active August 8, 2017 12:02
Shell script to create a author-contribution table from a git repository
#!/bin/bash
REPOSITORY="."
DAYS=30
PATTERN="*"
ORDER="d"
GITARGS=""
TABSTYLE="fancy_grid"
for cmds in tabulate git readlink; do
@BastiTee
BastiTee / ._d3v4_reusable_template
Last active August 19, 2017 09:14
d3v4: Reusable chart template
d3v4 Reusable chart template
@BastiTee
BastiTee / .gitignore
Last active August 24, 2017 06:49
A Java-method returning all combinations of elements in a list.
*.class