Skip to content

Instantly share code, notes, and snippets.

View jampekka's full-sized avatar

Jami Pekkanen jampekka

View GitHub Profile
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
gistup
/*
* 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.
*
#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]);
}
@jampekka
jampekka / activity.py
Created April 2, 2017 20:56
/r/place activity animated heatmap
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
@jampekka
jampekka / v4l2_hang.c
Created September 17, 2014 20:08
v4l2src hangs on Gstreamer 1.0 but works on 0.10
/**
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 / gist:61685ec5a0d8180f5ad54de937335283
Last active May 27, 2021 16:28
Historian lopun havinat
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)
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)
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,
@jampekka
jampekka / mind.py
Last active November 4, 2021 09:40
Simple The Mind type game
import random
import selectors
import sys
total_cards = 100
cards_per_player = 3
deck = list(range(1, total_cards + 1))
random.shuffle(deck)