Skip to content

Instantly share code, notes, and snippets.

View hencjo's full-sized avatar

Henrik Sjöstrand hencjo

View GitHub Profile
@hencjo
hencjo / Debouncer.java
Created August 16, 2018 09:11
Key-based Debouncer for Java
package debouncer;
import java.util.HashMap;
import java.util.concurrent.locks.ReentrantLock;
/**
* Utility class guarding a task to be execute by a single thread synchronized on some key.
*
* Other threads can try to schedule execution of task while the task is executing on the original thread.
* The first thread to do so will block and subsequently get unblocked to execute the task again as soon
@hencjo
hencjo / gist:0710d51c5ba51e0aeb2d905f1e3a38f3
Created February 13, 2018 13:27
Xorg: Two keyboards with different keyboard layout.
# Use xinput to find your keyboards.
$ xinput
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=11 [slave pointer (2)]
⎜ ↳ TPPS/2 IBM TrackPoint id=12 [slave pointer (2)]
⎜ ↳ Logitech Performance MX id=14 [slave pointer (2)]
⎜ ↳ E-Signal USB Gaming Keyboard id=16 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
import java.util.function.Function;
import static java.util.Objects.requireNonNull;
public class SumTypeDemo {
//Evaluate
private static int evaluate(Expression expression) {
return expression.expression.destruct(
constant -> constant.value,
add -> evaluate(add.a) + evaluate(add.b),

Keybase proof

I hereby claim:

  • I am hencjo on github.
  • I am hencjo (https://keybase.io/hencjo) on keybase.
  • I have a public key whose fingerprint is 0ED3 422A 8A83 44D9 AFA8 9555 F3E4 0507 6AC8 541D

To claim this, I am signing this object: