Skip to content

Instantly share code, notes, and snippets.

View smathot's full-sized avatar

Sebastiaan Mathot smathot

View GitHub Profile
@smathot
smathot / pygame-vlc.py
Created December 26, 2011 12:26
Use VLC to play videos on a PyGame surface
import os
import sys
import vlc
import pygame
def callback(self, player):
print
print 'FPS =', player.get_fps()
print 'time =', player.get_time(), '(ms)'
@smathot
smathot / clickplot.py
Created March 10, 2012 13:31
Clickable interactive matplotlib figure
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from matplotlib import pyplot
import numpy as np
class ClickPlot:
"""
A clickable matplotlib figure
@smathot
smathot / subplotexample.py
Created March 5, 2012 16:08
Matplotlib subplot example
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from matplotlib import pyplot
import numpy as np
fig = pyplot.figure()
xData = np.linspace(0, 4*np.pi)
yData = np.sin(xData)
@smathot
smathot / timestamp.py
Created December 30, 2011 00:18
A simple timing checker for OpenSesame (paste in inline_script)
from openexp.canvas import canvas
c1 = canvas(self.experiment)
c2 = canvas(self.experiment)
c3 = canvas(self.experiment)
soa = 0 # The desired SOA. 0 = fastest possible
N = 10 # Nr of repetitions
w = self.get('width')
h = self.get('height')
@smathot
smathot / bawsfactor.py
Created April 13, 2017 10:46
A script to calculate the Baws Factor from the JASP model comparison tabel.
#!/usr/bin/env python3
# coding=utf-8
import sys
from datamatrix import io, DataMatrix
INPUTCSV = sys.argv[-1]
---
API: 2
OpenSesame: 3.0.6
Platform: posix
---
set width 1024
set transparent_variables "no"
set title "KidsTest"
set synth_backend "legacy"
set subject_parity "even"
@smathot
smathot / xytouv.py
Last active February 22, 2016 11:24
import numpy as np
def uvtoxy(u, v, Bu=1.4, A=3., Bv=1.8):
u = np.array(u, dtype=float)
v = np.array(v, dtype=float)
R = A * np.sqrt(np.exp(2*u/ Bu) - (2*np.exp(u/Bu)*np.cos(v/Bv)) + 1)
phi = np.arctan2(
(np.exp(u/Bu)*np.sin(v/Bv)),
((np.exp(u/Bu)*np.cos(v/Bv))-1)
@smathot
smathot / atom-locale
Created January 3, 2016 10:55
Script to start Atom with non-English spellchecking on Linux
#!/bin/bash
# Usage:
# atom-locale [locale]
# Example (for French):
# atom-locale fr_FR
# Important note:
# This permanently changes the locale for atom spellchecker.
# To reset back to English, start with en_US locale.
ATOM_HUNSPELL_FOLDER="/opt/atom/resources/app.asar.unpacked/node_modules/spell-check/node_modules/spellchecker/vendor/hunspell_dictionaries"
HUNSPELL_FOLDER="/usr/share/hunspell"
@smathot
smathot / gist:5353595
Created April 10, 2013 10:46
UnicodeError fix for _stimulus.py
def __init__(self, log_comment=None):
"""Create a stimulus.
Keyword arguments:
log_comment -- the comment for the event log file (str) (optional)
"""
self._id = Stimulus._id_counter
Stimulus._id_counter += 1
@smathot
smathot / voicekey.py
Created November 23, 2015 09:36
OpenSesame voicekey
import pyaudio
import wave
import sys
import struct
import math
TAP_THRESHOLD = 0.050
FORMAT = pyaudio.paInt16
SHORT_NORMALIZE = (1.0/32768.0)
CHANNELS = 2