Skip to content

Instantly share code, notes, and snippets.

View matham's full-sized avatar

Matt Einhorn matham

View GitHub Profile
@matham
matham / async_threads_test.py
Created December 14, 2017 01:29
timing of python trio external thread interactions
import threading
import queue as stdlib_queue
import trio
class Executor(object):
_thread = None
name = 'Executor'
// sdl2_test2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#define _USE_MATH_DEFINES
#include <cmath>
#include <SDL2/SDL.h>
# in the host you should have installed cuda 8, then in the host on the command line do
sudo apt install nvidia-modprobe
wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.1/nvidia-docker_1.0.1-1_amd64.deb
sudo dpkg -i /tmp/nvidia-docker*.deb && rm /tmp/nvidia-docker*.deb
# in a seperate terminal run the nvidia server, it needs to remain running:
sudo nvidia-docker-plugin
# if you got a port already running error or similar, it's already running in the background so you can continue
# Back in the main terminal test nvidia-smi
from os import environ
environ['KIVY_CLOCK'] = 'interrupt'
environ['SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS'] = '0'
from time import clock
from kivy.uix.label import Label
from kivy.app import App
from kivy.clock import Clock
from kivy.core.window import Window
from kivy.graphics import Color, Point, Fbo, Rectangle
@matham
matham / log
Created January 24, 2017 08:58
This file has been truncated, but you can view the full file.
[INFO]: Will compile for the following archs: armeabi-v7a
[INFO]: Found Android API target in $ANDROIDAPI
[INFO]: Available Android APIs are (22, 23, 25)
[INFO]: Requested API target 22 is available, continuing.
[INFO]: Found NDK dir in $ANDROIDNDK
[INFO]: Got NDK version from $ANDROIDNDKVER
[INFO]: Using Google NDK r13b
[INFO]: Found virtualenv at E:\Python\Python27-x64\Scripts\virtualenv.exe
[INFO]: Found the following toolchain versions: ['4.9']
[INFO]: Picking the latest gcc toolchain, here 4.9
Matthew Einhorn@Dove-TDSkope MINGW64 /g/Python/py4a/builds
$ CCACHE_DISABLE=1 time p4a apk --package=org.example.myapp --name "My application" --version 0.1 --bootstrap=sdl2 --requirements=python2 --storage-dir=/g/python/py4a/builds/storage --arch=armeabi-v7a
--debug
[INFO]: Will compile for the following archs: armeabi-v7a
[INFO]: Found Android API target in $ANDROIDAPI
['E:\\Android\\sdk\\tools\\android.bat', 'list'] None
[INFO]: Available Android APIs are (23, 25)
[INFO]: Requested API target 23 is available, continuing.
[INFO]: Found NDK dir in $ANDROIDNDK
[INFO]: Got NDK version from $ANDROIDNDKVER
def schmitt_trigger(up, high, down, low, data):
'''up is the value that when we're in low state and we hit the up value we'll go into up (going up) state.
high is the value that when we're in up state and we hit the high value we'll go into high state.
down is the value that when we're in high state and we hit the down value we'll go into down (going down) state.
low is the value that when we're in down state and we hit the low value we'll go into low state.
data is list of data values.
'''
result = []
for s, val in enumerate(data):
if val < low:
'''
Widget animation
================
This example demonstrates creating and applying a multi-part animation to
a button widget. You should see a button labelled 'plop' that will move with
an animation when clicked.
'''
from os import environ
environ['KIVY_CLOCK'] = 'interrupt'
from os import listdir
from os.path import join, splitext
from re import match
import re
import numpy as np
import operator
from glitter.logger import DataLogger
filename_pat = re.compile('Carvone Trial([0-9]+) +([0-9]+)_updated_\\.h5')
import csv
import numpy as np
import matplotlib.pylab as plt
import matplotlib
from datetime import datetime
def import_data(filename, n_wheels):
with open(filename) as fh:
reader = csv.reader(fh, delimiter='\t')