Skip to content

Instantly share code, notes, and snippets.

💭
Throwing the dice

Bemmu Sepponen Bemmu

💭
Throwing the dice
Block or report user

Report or block Bemmu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Bemmu
Bemmu / scrambler.py
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))
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/;
}
}
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/;
}
}
}
@Bemmu
Bemmu / tally.js
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 {
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,
@Bemmu
Bemmu / gist:da5c79e9027bd3e248b7
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,
@Bemmu
Bemmu / gist:c9c7d2ddfe18601cf94a
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
View gist:c4361a8202b98ea3a806
LEADERBOARDCYCLOPEPTIDESEQUENCING(Spectrum, N)
Leaderboard ← {empty peptide}
LeaderPeptide ← empty peptide
while Leaderboard is non-empty
Leaderboard ← Expand(Leaderboard)
for each Peptide in Leaderboard
# --------------------------------------
IF SCORE(PEPTIDE, SPECTRUM) == 83:
print PEPTIDE
@Bemmu
Bemmu / gist:5c2e45c2dea007ce7763
Created Aug 5, 2014
Just a typical command line session with Python on my mac
View gist:5c2e45c2dea007ce7763
~/awesome bemmu$ python
Python 2.7.8 (default, Jul 3 2014, 06:13:58)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import hmac
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hmac.py", line 8, in <module>
from operator import _compare_digest as compare_digest
ImportError: cannot import name _compare_digest
You can’t perform that action at this time.