Skip to content

Instantly share code, notes, and snippets.

View veloce's full-sized avatar

Vincent Velociter veloce

  • lichess.org
  • France
View GitHub Profile
@jtmcdole
jtmcdole / ntz.dart
Last active March 27, 2023 04:52
Number of Trailing Zeros - Dart Edition
/// Returns the number of trailing zeros in a 32bit unsigned integer.
///
/// Hacker's Delight, Reiser's algorithm.
/// "Three ops including a "remainder, plus an indexed load."
///
/// Works because each bit in the 32 bit integer hash uniquely to the
/// prime number 37. The lowest set bit is returned via (x & -x).
ntz32(int x) {
assert(x < 0x100000000, "only 32bit numbers supported");
return _ntzLut32[(x & -x) % 37];

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.

@webcss
webcss / mithril-touch.js
Last active May 26, 2020 15:34
mithril-touch, consume touch and mouse events evenly with mithril
/*****************************************
/* DOM touch support module
/*****************************************/
if (!window.CustomEvent) {
window.CustomEvent = function (event, params) {
params = params || { bubbles: false, cancelable: false, detail: undefined };
var evt = document.createEvent('CustomEvent');
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
return evt;
};
@staltz
staltz / introrx.md
Last active January 4, 2025 04:18
The introduction to Reactive Programming you've been missing