This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Send image data to v4l2loopback using python | |
#Remember to do sudo modprobe v4l2loopback first! | |
#Released under CC0 by Tim Sheerman-Chase, 2013 | |
import fcntl, sys, os | |
from v4l2 import * | |
import time | |
import scipy.misc as misc | |
import numpy as np |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import struct | |
huffmanSegment = '\xFF\xC4\x01\xA2\x00\x00\x01\x05\x01\x01\x01\x01'\ | |
'\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02'\ | |
'\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x01\x00\x03'\ | |
'\x01\x01\x01\x01\x01\x01\x01\x01\x01\x00\x00\x00'\ | |
'\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09'\ | |
'\x0A\x0B\x10\x00\x02\x01\x03\x03\x02\x04\x03\x05'\ | |
'\x05\x04\x04\x00\x00\x01\x7D\x01\x02\x03\x00\x04'\ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Extract a small area from an OSM file | |
#by Tim Sheerman-Chase, 2013 | |
#You may reuse this file under the terms of CC0 | |
#https://creativecommons.org/publicdomain/zero/1.0/ | |
import xml.parsers.expat as expat | |
import pickle, bz2 | |
from xml.sax.saxutils import escape, quoteattr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Demonstration of multipart/x-mixed-replace decoding to get MJPEG frames from web server | |
#by Tim Sheerman-Chase 2014 | |
#This code may be used under the terms of the CC0 license | |
#https://creativecommons.org/publicdomain/zero/1.0/ | |
import pycurl | |
class HandleJpegData(object): | |
def __init__(self): | |
self.count = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import struct, sys, os | |
#----------------------------------------------------------- | |
#--- Block recoverer program for bzip2 -- | |
#--- bzip2recover.py -- | |
#----------------------------------------------------------- | |
# This program is bzip2recover, a program to attempt data | |
# salvage from damaged files. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Reading and writing tests | |
//Release under CC0 by Tim Sheerman-Chase, 2014 | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <vector> | |
#include <list> | |
#include <iostream> | |
#include <string> | |
using namespace std; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This script does test reads and writes to a file. | |
#Release under CC0 by Tim Sheerman-Chase, 2014 | |
#This script fails on my computer but not on others. Weird. | |
import random, time, pickle, sys | |
import numpy as np | |
def MultiRead(handle, maxLen): | |
buff = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random, math | |
def FindPrimes(lowLimit, highLimit): | |
cand = list(range(lowLimit, highLimit)) | |
for i in range(2,lowLimit): | |
current = i * int(math.floor(lowLimit / i)) | |
while current < highLimit: | |
if current in cand: | |
cand.remove(current) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Recursively compare files in two folders | |
#by Tim Sheerman-Chase, 2014 | |
#Released under the CC0 license | |
import sys, os, hashlib | |
def CheckFolderPair(fo1, fo2, stats): | |
fiList1 = os.listdir(fo1) | |
for fina in fiList1: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void NaiveIir(const vector<float> &b, const vector<float> &a, const vector<float> &in, vector<float> &out) | |
{ | |
//IIR filtering, unoptimised | |
//Call like scipy's lfilter | |
//http://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.lfilter.html | |
out.resize(0); | |
out.resize(in.size()); | |
for(int i=0; i < in.size(); i++) |