Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View Bemmu's full-sized avatar
💭
Writing Roblox games

Bemmu Sepponen Bemmu

💭
Writing Roblox games
View GitHub Profile
@Bemmu
Bemmu / gptdot.md
Created December 5, 2022 02:59
ChatGPT tries to prove that a · b != b · a

Yes, the order of the vectors in the dot product matters. The dot product is defined as the sum of the element-wise products of the two vectors. If you switch the order of the vectors, the element-wise products will be different, and therefore the dot product will also be different. Here's an example:

Suppose we have two vectors a and b with the following elements:

a = [1, 2, 3]
b = [4, 5, 6]

If we take the dot product of a and b in the standard order, we get:

@Bemmu
Bemmu / scrambler.py
Created May 9, 2019 06:59
Test implementation of a polynomial scrambler used in modems and fax machines
# 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))
#!/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 / tally.js
Last active September 19, 2017 18:24
Highlighting tally
// 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 {
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/;
}
}
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 / gist:da5c79e9027bd3e248b7
Created February 16, 2016 07:00
BigQuery for most popular countries on Hacker News
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 February 16, 2016 17:59
Mapping strings to country codes
AD,Andorra
AD,Andorran
AE,United Arab Emirates
AE,Emirati
AE,Emirian
AE,Emiri
AE,UAE
AF,Afghanistan
AF,Afghan
AF,Afghani
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 August 5, 2014 00:09
Just a typical command line session with Python on my mac
~/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