Skip to content

Instantly share code, notes, and snippets.

View bdkent's full-sized avatar

Brian Kent bdkent

  • Engineer @ Coursera
  • USA
  • 11:04 (UTC -04:00)
View GitHub Profile
@lukejones
lukejones / fix-logitech-bluetooth-lag.md
Last active April 4, 2025 07:15
Fix Logitech MX Master / Keys 3S Bluetooth Lag on MacOS

For those who get issues with input lag on their bluetooth devices, do the following to remove the lag.

  1. Open up Terminal.app (Applications > Utilities > Terminal)
  2. Run the command sudo pkill bluetoothd (just copy and paste that into Terminal).
  3. Hit Return/Enter.
  4. Enter your macOS user password (the one you sign in to your Mac with).
  5. Hit Return/Enter.
  6. Wait for a few moments while the Bluetooth receiver resets and all the devices restart.

Thread Pools

Thread pools on the JVM should usually be divided into the following three categories:

  1. CPU-bound
  2. Blocking IO
  3. Non-blocking IO polling

Each of these categories has a different optimal configuration and usage pattern.

@galan
galan / import-letsencrypt-java.sh
Last active August 9, 2024 12:34
Imports the letsencrypt certificates into the java keystore
#!/bin/bash -e
# JAVA_HOME can be passed as argument if not set
if [ ! -d $JAVA_HOME ]; then
JAVA_HOME=${1}
fi
KEYSTORE=$JAVA_HOME/jre/lib/security/cacerts
if [ ! -f "$KEYSTORE" ]; then
echo "Keystore not found in '$KEYSTORE'"
exit 1

Explaining Miles's Magic

Miles Sabin recently opened a pull request fixing the infamous SI-2712. First off, this is remarkable and, if merged, will make everyone's life enormously easier. This is a bug that a lot of people hit often without even realizing it, and they just assume that either they did something wrong or the compiler is broken in some weird way. It is especially common for users of scalaz or cats.

But that's not what I wanted to write about. What I want to write about is the exact semantics of Miles's fix, because it does impose some very specific assumptions about the way that type constructors work, and understanding those assumptions is the key to getting the most of it his fix.

For starters, here is the sort of thing that SI-2712 affects:

def foo[F[_], A](fa: F[A]): String = fa.toString
@demisx
demisx / angularjs-providers-explained.md
Last active December 26, 2024 05:39
AngularJS Providers: Constant/Value/Service/Factory/Decorator/Provider
Provider Singleton Instantiable Configurable
Constant Yes No No
Value Yes No No
Service Yes No No
Factory Yes Yes No
Decorator Yes No? No
Provider Yes Yes Yes

Constant

@jboner
jboner / latency.txt
Last active July 25, 2025 09:04
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD