This file contains 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 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 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 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 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++) |
This file contains 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
#!/usr/bin/env python | |
#Draw OS grid squares in OSM format | |
from ostn02python.OSGB import * | |
from ostn02python.OSTN02 import * | |
pointStore = [] | |
vertLines = {} | |
out = file("grid.osm", "wt") |
This file contains 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
#include <string> | |
#include <fstream> | |
#include <vector> | |
int ReadFileContents(const char *filename, int binaryMode, std::string &contentOut) | |
{ | |
contentOut = ""; | |
std::ios_base::openmode mode = (std::ios_base::openmode)0; | |
if(binaryMode) | |
mode ^= std::ios::binary; |
This file contains 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 string | |
def BinToHex(a): | |
return "".join(["%02x" % ord(ch) for ch in a]) | |
def HexToBin(a): | |
out = [] | |
for i in range(0, len(a), 2): | |
twoChrs = a[i:i+2] | |
v = string.atoi(twoChrs, 16) |
This file contains 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
function relativeBearing(b1Rad, b2Rad) | |
{ | |
b1y = Math.cos(b1Rad); | |
b1x = Math.sin(b1Rad); | |
b2y = Math.cos(b2Rad); | |
b2x = Math.sin(b2Rad); | |
crossp = b1y * b2x - b2y * b1x; | |
dotp = b1x * b2x + b1y * b2y; | |
if(crossp > 0.) | |
return Math.acos(dotp); |
This file contains 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 os | |
from ftplib import FTP | |
if __name__ == "__main__": | |
ftp = FTP('ftp.debian.org') # connect to host, default port | |
ftp.login() # user anonymous, passwd anonymous@ | |
ftp.cwd('debian') # change into "debian" directory | |
outFile = open("out.txt", "wt") | |
ftp.retrlines('LIST', lambda x: outFile.write(x+os.linesep)) # list directory contents |
OlderNewer