Skip to content

Instantly share code, notes, and snippets.

# well'd do nested arrays, N rows inside an N-sized column (or vice versa)
# Then you can refer to a single spin with lattice[x][y]
# One approach, most obvious
N = 10
lattice = []
for x in range(N):
lattice.append([])
@arsatiki
arsatiki / driver.sh
Created January 3, 2018 08:57
Kansalaisaloitteiden seurantaskripti
ALOITE_ID=2730
RESOLUTION=300
(while true; do
curl -w "\n" -s https://www.kansalaisaloite.fi/api/v1/supports/$ALOITE_ID;
sleep $RESOLUTION;
done)|jq -rf total.jq
@arsatiki
arsatiki / demons.md
Created January 26, 2017 23:15
How I deal with my demons and the new US president

The Sun was shining. I was on a beautiful beach in Las Palmas, staring at my phone. My kids had gone ahead to play in the surf. They'd run and shout and be exactly as adorable as kids on a beach can be. I was looking at my phone. I felt anxious about the news from the US. I didn't smile or enjoy the weather. I was refreshing Twitter on the damn phone.

After some minutes the ridiculousness of the situation forced me finally leave the phone behind and join my family playing in the sea. My brain started to do all the important things a relaxed brain should be doing. About half an hour later, when I was sitting in the sand and watching the kids play, I realized I had a new demon in my head.

I don't use the term demon here in any religious sense. Rather, they are insistent thoughts (or thought patterns) that keep looping in my mind, eat up all my energy, and tie my stomach into one large knot. I'll explain the naming later, but I'll have to detour to personal history first.

import socket
from struct import Struct
VERSION = 3
CLIENT_MODE = 3
LI = 0
NTP = Struct("!4c 3I 4Q I 16s")
@arsatiki
arsatiki / gist:43c8767117a4aa5c9429
Created January 6, 2016 09:30
dmesg output for dance mats
ugen0.3: <vendor 0x1430> at usbus0
uhub4: <vendor 0x1430 product 0x1000, class 9/1, rev 1.10/3.13, addr 3> on usbus0
uhub4: 3 ports with 3 removable, bus powered
ugen0.4: <RedOctane> at usbus0
uhid0: <RedOctane RedOctane USB Pad, class 0/0, rev 1.10/3.13, addr 4> on usbus0
2015/04/06 20:21:36 [FF0000FF: ff0000ff] [Name: ff ff ff ff ff ff ff ff ff ff ()] [Unk: ffff]
Time: 2015-03-09 17:55:49 +0200 EET: Distance: 8 m, Duration: 25s
Offset: 599 points (19168 B), Size: 2 points (64 B)
SPDMAX: 0.2 km/h, SPDAVG: 0.2 km/h, CAL: 2
[7d 00]
CO2 0.0 kg
HRMMax: 0, HRMAvg: 0
[00 00 00 00 00 00 00 00 7d 00 00 00 00 00 00 00] (starts with # of POIs, length?)
2015/04/06 20:21:36 [FF0000FF: ff0000ff] [Name: ff ff ff ff ff ff ff ff ff ff ()] [Unk: ffff]
Huom!
Inttien inttimäisyys on vain oletus, koska ne näyttävät heksana pieniltä little endian inteiltä.
Jos haluat, voit tulkita esim 5:n heksarimpsuna 05 00 00 00.
Time: 2015-03-09 17:55:49 +0200 EET: Distance: 8, Duration: 25s
Offset: 599 tracks (19168 B), Size: 2 tracks (64 B)
HRMMax: 0, HRMAvg: 0
Ints: 0, 0, 125, 0
02 00 02 00 02 00 7d 00 00 00 # Täysin tuntemattomat
>>> liitot.table(PS, KOK, KD, SDP, VIHR, KESK + RKP, VAS)
Olli Rehn (KESK-RKP) 455821
Alexander Stubb (KOK) 390112
Paavo Väyrynen (KESK-RKP) 227910
Jussi Halla-aho (PS) 222102
Liisa Jaakonsaari * (SDP) 212211
Sirpa Pietikäinen * (KOK) 195056
Heidi Hautala (VIHR) 160967
Merja Kyllönen (VAS) 160818
Anneli Jäätteenmäki * (KESK-RKP) 151940
@arsatiki
arsatiki / outrun.awk
Last active August 29, 2015 13:57
Outrun problem in AWK
function max(a, b) {
return a > b? a: b;
}
$1 == "#" {
print "Seed", $3
next;
}
{
@arsatiki
arsatiki / ball.elm
Created January 25, 2014 11:23
Cats and mice
import Mouse
import Window
ball = {x = 0.0, y = 0.0 }
type Pair = (Float, Float)
unit (x, y) = let d = sqrt(x^2 + y^2) in (x/d, y/d)
(-->) {x, y} (tx, ty) = unit (tx - x, ty - y)