Skip to content

Instantly share code, notes, and snippets.

Avatar

Jami Pekkanen jampekka

View GitHub Profile
@jampekka
jampekka / mind.py
Last active Nov 4, 2021
Simple The Mind type game
View mind.py
import random
import selectors
import sys
total_cards = 100
cards_per_player = 3
deck = list(range(1, total_cards + 1))
random.shuffle(deck)
View kunta2021.py
import pandas as pd
hs_poll_perc = {
'kok': 19.6,
'ps': 18.0,
'sdp': 17.9,
'kesk': 12.7,
'vihr': 11.1,
'vas': 8.2,
'rkp': 4.6,
View geom_model.py
import numpy as np
import matplotlib.pyplot as plt
def compensatory_radius(estimate_dispersion, R):
cosarg = estimate_dispersion/R**2
# Cos will go negative when arg > pi/2. arg < 0 makes no sense, so no need to worry about that.
# Trigonometry breaks down for this at pi/2? Could probably have some sort of analytical
# continuation if needed, however pi/2 dispersion leading to center seems implausible for a
# model.
r_2 = R*np.cos(cosarg)
View gist:61685ec5a0d8180f5ad54de937335283
Loppuiko historian loppu:
Historian loppuun (1992)
Lätkän MM-kultaan (1995)
Sokalin tapaus (1996)
Dot-com-romahdukseen (1995)
Dianan kuolema (1997)
WTO-iskuihin (1999)
WTC-iskuihin (2001)
Pentagon-iskuihin (2001)
@jampekka
jampekka / v4l2_hang.c
Created Sep 17, 2014
v4l2src hangs on Gstreamer 1.0 but works on 0.10
View v4l2_hang.c
/**
Hangs after two frames with gstreamer 1.0:
gcc -o v4l2_hang1.0 `pkg-config gstreamer-1.0 --cflags --libs` v4l2_hang.c && ./v4l2_hang1.0
Works fine with 0.10
gcc -o v4l2_hang0.10 `pkg-config gstreamer-0.10 --cflags --libs` v4l2_hang.c && ./v4l2_hang0.10
*/
#include <gst/gst.h>
#include <stdio.h>
@jampekka
jampekka / activity.py
Created Apr 2, 2017
/r/place activity animated heatmap
View activity.py
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats
import pyximport; pyximport.install()
from pixcount import pixcount
import scipy.ndimage
data = np.load('diffs.npy')
ts = data[:,0]
frames = 1000
View uvccap.cpp
#include <opencv2/opencv.hpp>
#include <string>
using namespace cv;
int main(int argc, char **argv) {
int camno = 0;
if(argc > 2) {
camno = std::atoi(argv[1]);
}
View gstabstime.c
/*
* GStreamer
* Copyright (C) 2006 Stefan Kost <ensonic@users.sf.net>
* Copyright (C) 2017 Jami Pekkanen <jami.pekkanen@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
View sigsync.py
import numpy as np
import scipy.interpolate
import scipy.signal
def match_sampled_brutal(ts1, haystack, ts2, needle, minlen=100):
dt = np.median(np.diff(ts1))
ts1_base = ts1[0]
ts1 = ts1 - ts1_base