Skip to content

Instantly share code, notes, and snippets.

View spedy's full-sized avatar

Klemen Strušnik spedy

View GitHub Profile
"""
koda: b2
skupina: b
calibration_num_letters: =calibration8 level, max_num_letters?
time_calibration_num_letters: average time of elapsed time
choice: int(bool(["results"]["choice"] == "hard"))
correct: ["results"]["expsolved"]
time: ["results"]["elapsedTime"]
"""
def contains_sequence(array, sequence):
for idx in range(len(array)):
if idx + len(sequence) > len(array):
return False
if array[idx:idx+len(sequence)] == sequence:
return True
# Tests
tests = {
"contains_sequence": {
@spedy
spedy / gist:8bd2ed26ecdd3c1a3e9a75d90b4f8a5f
Last active September 22, 2016 22:33
django + csrf + ajax
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
import numpy as np
from sklearn.metrics import precision_recall_curve
import matplotlib.pyplot as pl
recall, precision, thresholds = precision_recall_curve(np.array(np_y_true), np.array(np_y_scores))
pl.plot(recall, precision)
pl.xlabel('Recall')
pl.ylabel('Precision')
pl.ylim([0.0, 1.05])
pl.xlim([0.0, 1.0])
import matplotlib.pyplot as pl
recall, precision, thresholds = precision_recall_curve(np.array(np_y_true), np.array(np_y_scores))
pl.plot(recall, precision)
pl.xlabel('Recall')
pl.ylabel('Precision')
pl.ylim([0.0, 1.05])
pl.xlim([0.0, 1.0])
pl.title('Precision-Recall')
pl.savefig("{0}_{1}.png".format(kernel, k))
from freenect import sync_get_depth as get_depth, sync_get_video as get_video
import cv2
import time
import numpy as np
import pickle
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)
def save_file(frame, idx):
cv2.imwrite("data/rgb{}.jpeg".format(idx), frame["rgb"])