Skip to content

Instantly share code, notes, and snippets.

@andrebrait
andrebrait / kodi.service
Created May 10, 2021
Start KODI on graphical interface startup/desktop login, useful for Raspberry Pi users
View kodi.service
# This is useful for those who want to have KODI running on startup, but still want to use a full desktop (e.g. Raspbian).
# This will make KODI run as soon as the graphical interface (be it X or Wayland) starts up and the user logs in
# It will only start KODI after the network and remote shares have been started up
[Unit]
Description = Kodi Media Center
After = remote-fs.target network-online.target graphical.target
Wants = graphical.target
[Service]
User = pi
@andrebrait
andrebrait / keychron_linux.md
Last active Oct 7, 2022
Keychron keyboards on Linux + Bluetooth fixes
View keychron_linux.md

Here is the best setup (I think so :D) for K-series Keychron keyboards on Linux.

Most of these commands have been tested on Ubuntu 20.04 and should also work on most Debian-based distributions. If a command happens not to work for you, take a look in the comment section.

Make Fn + F-keys work

Keychron Keyboards on Linux use the hid_apple driver (even in Windows/Android mode), both in Bluetooth and Wired modes. By default, this driver uses the F-keys as multimedia shortcuts and you have to press Fn + the key to get the usual F1 through F12 keys.

View keybase.md

Keybase proof

I hereby claim:

  • I am andrebrait on github.
  • I am andrebrait (https://keybase.io/andrebrait) on keybase.
  • I have a public key ASBOK9lU4evQpiRR5-G9MvCsgzR_aklowmFSyP-aAm43-wo

To claim this, I am signing this object:

View bad-benchmarks-result.txt
Running: distance
[ ~29975598 ops/ms ]
Running: constant
[ ~421092 ops/ms ]
Running: nothing
[ ~274938 ops/ms ]
View bad-benchmarks.java
static double distance(double x1, double y1, double x2, double y2) {
double dx = x2 - x1;
double dy = y2 - y1;
return Math.sqrt((dx * dx) + (dy * dy));
}
static double constant(double x1, double y1, double x2, double y2) {
return 0.0d;
}
View constant-2.java
@Benchmark
public void testMethod(MyState state, Blackhole blackhole) {
int sum1 = state.a + state.b;
int sum2 = state.a + state.a + state.b + state.b;
blackhole.consume(sum1);
blackhole.consume(sum2);
}
View constant-1.java
@State(Scope.Thread)
public static class MyState {
public int a = 1;
public int b = 2;
}
@Benchmark
public int testMethod(MyState state) {
int sum = state.a + state.b;
return sum;
View sum-4.java
@Benchmark
public int testMethod() {
int sum = 3;
return sum;
}
View sum-3.java
@Benchmark
public void testMethod(Blackhole blackhole) {
int a = 1;
int b = 2;
int sum = a + b;
blackhole.consume(sum);
}
View sum-2.java
@Benchmark
public int testMethod() {
int a = 1;
int b = 2;
int sum = a + b;
return sum;
}