Skip to content

Instantly share code, notes, and snippets.

View espadrine's full-sized avatar

Thaddée Tyl espadrine

View GitHub Profile
@espadrine
espadrine / README.md
Created February 12, 2021 18:52
Birthday paradox on Slack username colors.

You might know the birthday problem: “it only takes 23 people so that two have the same birthday”.

But do you know the Slack username color problem?

Slack gives random colors to each user in compact view. But there’s only 51 colors to choose from, so as soon as you are 9 in a channel, odds are that two share the same color.

BEGIN MESSAGE.
Tx74RVCgXiswTvD yeKGImuFXka2Y2x JKalxOHiQXtBEl7 qPCoctF82Th5Gpi
0lnxdLk5s0Tjzuk v4cuJ7BDnCjTCKq 6Xr2MZHgg6UyBLH zqZDdsfvbTLAC6D
CifYELzwhOiJaIA 8uXBbOLbUUhC4MD ox0043eX0QUhQbG zamauzRNZReGGDG
7hg8Hz4u226E7Ic bW4xOd900EAZRvN Mjs7629HFxl.
END MESSAGE.
@espadrine
espadrine / OutputBigCrush
Last active April 19, 2020 13:03
Harmonoise PRNG
./harmonoise-big-crush
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Starting BigCrush
Version: TestU01 1.2.3
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
***********************************************************
Test smarsa_SerialOver calling smultin_MultinomialOver
@espadrine
espadrine / rr.sh
Created January 1, 2019 12:30
Trying to use rr for debugging https://github.com/espadrine/tree-array
$ rr record cargo test
rr: Saving execution to trace directory `/home/tyl/.local/share/rr/cargo-4'.
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running target/debug/deps/bench_insert-8cb017bd9e593f1f
running 5 tests
test tests::bench_insert_list ... ok
test tests::bench_insert_vec ... ok
test tests::test_insert_list ... ok
test tests::test_insert_tree_array ... FAILED
@espadrine
espadrine / new.js
Last active March 20, 2016 12:05
Potential new ScoutCamp API
// Server demo. `node app [PORT [https]]`
// © 2011-2016 Thaddée Tyl, Jan Keromnes. LGPL.
let port = +process.argv[2] || +process.env.PORT || 1234
let camp = require('./lib/camp.js')
let sc = camp.start({port: port, secure: process.argv[3] === 'https'})
console.log('http://[::1]:' + port)
// Templating demo: /template.html?title=Hello&info=[Redacted].
sc.path('template.html')
@espadrine
espadrine / perl6.js
Created June 19, 2015 11:30
Perl6 CodeMirror syntax highlighting mode
// Parts from Ace; see <https://raw.githubusercontent.com/ajaxorg/ace/master/LICENSE>
CodeMirror.defineMode("perl6", function(cmCfg, modeCfg) {
// Fake define() function.
var moduleHolder = Object.create(null);
// Given a module path as a string, create the canonical version
// (no leading ./, no ending .js).
var canonicalPath = function(path) {
return path.replace(/\.\//, '').replace(/\.js$/, '');

Keybase proof

I hereby claim:

  • I am espadrine on github.
  • I am espadrine (https://keybase.io/espadrine) on keybase.
  • I have a public key whose fingerprint is 4AE5 032E 679C D54C 0AA1 6520 BF5F 9DA7 282E F842

To claim this, I am signing this object:

@espadrine
espadrine / watcher-no-dotfile.patch
Created October 30, 2014 15:31
Remove dot files from ember-cli sane watcher's reach
--- node_modules/ember-cli/node_modules/broccoli-sane-watcher/index.js
+++ node_modules/ember-cli/node_modules/broccoli-sane-watcher/index.js
@@ -76,20 +76,19 @@
this.watched[dir] = watcher;
};
-Watcher.prototype.onFileChanged = function (filePath, root) {
- if (this.options.verbose) console.log('file changed', filePath);
- this.scheduleBuild(path.join(root, filePath));
-};
@espadrine
espadrine / sync-stdin.js
Created September 12, 2014 11:32
How to read stdin synchronously in nodejs.
var fs = require('fs');
// Returns a buffer of the exact size of the input.
// When endByte is read, stop reading from stdin.
function getStdin(endByte) {
var BUFSIZE = 256;
var buf = new Buffer(BUFSIZE);
var totalBuf = new Buffer(BUFSIZE);
var totalBytesRead = 0;
var bytesRead = 0;
@espadrine
espadrine / argument.txt
Created September 9, 2014 23:54
Classoid
Arguably, in `page.inadequate.css`, this `.left` class should be `.block.left`, and `.right-on-hover` ought to be `.block.right-on-hover`, or something like that.
Still, creating name conflicts is a trap made hard to avoid.
Using namespaces eases the process. Classoids provide hierarchical classes. In this example, our rules related to `left` specifically on a `button` only apply on a `button` classoid; the `left` class does not apply to it. This avoids the name clashing.
(Unfortunately, CSS namespaces is already a thing, extended from XML namespaces, not what we want. I picked the term "classoid", because it is like a class.)
The example is contrived, but the problem is present. See also the last slides here <http://www.slideshare.net/stubbornella/object-oriented-css>.