Skip to content

Instantly share code, notes, and snippets.

View mapehe's full-sized avatar

Matias Heikkilä mapehe

View GitHub Profile
"""
Consider an n-player game, where each player x has influence i_x.
At each round, each pair of players x, y flip a fair coin, and the
winner gains i_x * i_y influence from the other player.
The formula ensures that stakes are proportional to influence:
Player x puts a greater stake towards a player y than player z
when i_y > i_z.
"""
@mapehe
mapehe / example.js
Last active November 2, 2022 13:38
The type of `new Date() ${operator} 0` depends on the choice of the operator.
console.log(new Date() + 0)
console.log(new Date() - 0)
@mapehe
mapehe / insert_timesheet_entries.sh
Created May 24, 2022 13:15
Script for inserting timesheets for an interval
#!/bin/bash
MONTH=05
START_DAY=01
START_DAY=28
PREPARE=$(cat << EOF
DELETE FROM timesheet_entry;
DELETE FROM timesheet;
DELETE FROM task;
@mapehe
mapehe / numpy_array_to_image.py
Last active March 13, 2022 16:38
numpy array to image
from colorsys import hsv_to_rgb
from PIL import Image
import numpy as np
SAT_MIN = 10e-4
SAT_MAX = 10e-1
def clamp(val):
return max(min(val, 1), 0)
@mapehe
mapehe / immutability.md
Created December 6, 2021 11:12
Immutable data without a blockchain

Immutable data without a blockchain

A careful read of the Nakamoto paper reveals that the original purpose of the blockchain is extremely specialized: A completely decentralized consensus among unreliable actors. I'd like to highlight the often overlooked fact that this is exactly what the blockchain is suitable for. Any change in the conditions and you are probably doing extra work. Data immutability is a good example. Recently, especially in the mainstream media, data immutability has been presented as something that has been pioneered by blockchain technology, though it's easier to achieve similar

@mapehe
mapehe / rant.md
Last active December 5, 2021 09:17
don't know why i wrote this

Rant: I'm sick and tired of cryptobros.

I'm gonna go out on a limb here and claim that the general interest in cryptocurrencies is directly proportional to the BTC/USD rate.

Remember the 2018 bubble, when everyone made delusional claims along the lines of the blockchain will replace the internet? It got so big that even a bunch of companies bought the hype. Cash was thrown at business projects that made no goddamn sense: I distinctly remember asking the Finnish MD of a major financial organization how their blockchain proof-of-concept was supposed to work. They