Instantly share code, notes, and snippets.

💭
Throwing the dice

Bemmu SepponenBemmu

💭
Throwing the dice
• Sort options
Created May 9, 2019
Test implementation of a polynomial scrambler used in modems and fax machines
View scrambler.py
 # Test implementation of a polynomial scrambler used in modems and fax machines as explained in # http://i56578-swl.blogspot.com/2018/03/scrambling-and-descrambling.html class PolynomialScrambler(): def __init__(self, degrees): self.degrees = sorted(degrees) self.step = 0 self.bits = [0] * max(degrees) def state(self): return " ".join(map(str, self.bits))
Last active Aug 16, 2018
View AB test for Candy Japan product packaging
 #!/usr/bin/python # We send candy shipments in batches in 2 week intervals. Each list here shows which customers received # each batch, starting from Nov 28th 2015. When a number goes missing, it means that the customer canceled # their subscription. When a number appears, it means that a new customer joined. shipping_lists = [ [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 18, 19, 21, 22, 24, 26, 27, 30, 31, 33, 34, 36, 37, 40, 42, 45, 46, 49, 50, 51, 52, 56, 57, 58, 59, 61, 64, 66, 67, 68, 70, 71, 72, 73, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 89, 93, 94, 95, 96, 98, 99, 101, 103, 104, 105, 106, 109, 110, 111, 112, 118, 122, 124, 125, 127, 129, 130, 131, 132, 134, 135, 137, 140, 141, 142, 143, 145, 146, 149, 150, 152, 153, 154, 156, 158, 160, 163, 164, 166, 167, 168, 169, 170, 171, 173, 175, 177, 179, 180, 182, 184, 187, 188, 189, 190, 191, 192, 193, 196, 197, 198, 200, 201, 203, 205, 206, 207, 208, 209, 210, 211, 213, 215, 216, 218, 219, 220, 223, 224, 225, 226, 227, 228, 229, 230, 232, 236, 237,
Last active Sep 19, 2017
Highlighting tally
View tally.js
 // I had to write this code in just a few minutes to get it ready while my article was still trending. // I decided to exclude anyone not on desktop Chrome to avoid spending time on browser issues. // Here I am trying to test if the user is on desktop Chrome. function onDesktopChrome() { var pattern = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i; var isMobile = pattern.test(navigator.userAgent); if (isMobile) { return false; } else {
Created Jul 21, 2017
Foo
View gist:9e7e81da499d91b95f0a1723dca2e964
 server { error_log /tmp/nginx-error-8001.log; access_log /tmp/nginx-access-8001.log; listen 8001; rewrite ^/plik\$ /plik/ redirect; location /plik/ { proxy_pass http://localhost:8080/; } }
Created Jul 21, 2017
plikd nginx config
View gist:99938574151c3efa282730fa662e85dc
 http { server { error_log /tmp/nginx-error-8001.log; access_log /tmp/nginx-access-8001.log; listen 8001; location ~ /plik(/?.*) { proxy_pass http://localhost:8080/; } } }
Created Feb 16, 2016
BigQuery for most popular countries on Hacker News
View gist:da5c79e9027bd3e248b7
 SELECT b.country, SUM(score) as total_score, SUM(a.c) as mention_count, ROUND(SUM(score) / SUM(a.c), 2) as avg_score FROM ( SELECT a.word, SUM(a.score) AS score,
Last active Feb 16, 2016
Mapping strings to country codes
View gist:c9c7d2ddfe18601cf94a
 AD,Andorra AD,Andorran AE,United Arab Emirates AE,Emirati AE,Emirian AE,Emiri AE,UAE AF,Afghanistan AF,Afghan AF,Afghani
Created Nov 7, 2014
View gist:c4361a8202b98ea3a806