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 csv | |
def MergeUpdate(dataDict, update): | |
for li in update: | |
#print (li['ElectorNumber'], li['ElectorCreatedMonth'], li['ElectorChangedMonth'], li['ElectorDeletedMonth']) | |
electNum = li['ElectorNumber'].strip() | |
if int(li['ElectorCreatedMonth']) or int(li['ElectorChangedMonth']): |
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
//2D Line-line intersection using determinants | |
//by Tim Sheerman-Chase, 2016 | |
//Released under CC0 | |
#include <iostream> | |
#include <cmath> | |
#include <assert.h> | |
using namespace std; | |
/** Calculate determinant of matrix: |
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
#By Tim Sheerman-Chase 2016 | |
#Released under the CC0 license | |
from __future__ import print_function | |
import itertools, copy | |
class RunningAverage(object): | |
def __init__(self): | |
self.Val = 0.0 | |
self.Count = 0 |
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
#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 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
//2D implementation of the Ramer-Douglas-Peucker algorithm | |
//By Tim Sheerman-Chase, 2016 | |
//Released under CC0 | |
//https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm | |
#include <iostream> | |
#include <cmath> | |
#include <utility> | |
#include <vector> | |
#include <stdexcept> |
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
<!-- You may use this under the terms of https://creativecommons.org/publicdomain/zero/1.0/ --> | |
<?php | |
if (isset($_POST["action"])) | |
{ | |
$ok = true; | |
$errorMsg = Null; | |
$from_email = $_POST["email"]; | |
if (!filter_var($from_email, FILTER_VALIDATE_EMAIL)) { | |
$ok = false; | |
$errorMsg = "Invalid email format"; |
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
#Line-plane intersection | |
#By Tim Sheerman-Chase | |
#This software may be reused under the CC0 license | |
#Based on http://geomalgorithms.com/a05-_intersect-1.html | |
from __future__ import print_function | |
import numpy as np | |
def LinePlaneCollision(planeNormal, planePoint, rayDirection, rayPoint, epsilon=1e-6): |
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
#pyellipse by Tim Sheerman-Chase (C) 2021 | |
#Calculate circumference of an ellipse in python (both exact and approximate approaches) | |
#This source code may be used under the CC0 license https://creativecommons.org/publicdomain/zero/1.0/ | |
# | |
#For the best exact circumference, use EllipseCircumAdlaj2012 | |
# | |
#For good approximations that are faster to compute, see EllipseCircumRamanujan2ndApprox and EllipseCircumJacobsenWaadeland1985 | |
# | |
#Incidentally, scipy has a function to exactly calculate it: | |
# C = 4.0*a*special.ellipe(e*e) |
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
# A script to group delivery areas into routes of roughly similar size. | |
import csv | |
from sklearn import cluster | |
from pyproj import Proj, transform | |
import numpy as np | |
from matplotlib import pyplot as plt | |
class EqualWeightClustering(object): |
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
#!/bin/python | |
#Based on: EERTREE: An Efficient Data Structure for Processing Palindromes in Strings | |
#by Mikhail Rubinchik and Arseny M. Shur https://arxiv.org/pdf/1506.04862.pdf | |
#Useful: https://medium.com/@alessiopiergiacomi/eertree-or-palindromic-tree-82453e75025b#.ofgt2r7xn | |
#Port of https://github.com/zimpha/algorithmic-library/blob/master/string-utility/eertree.cc | |
#to python by TimSC. zimpha kindly allowed me to release this code under the CC0 license. | |
from __future__ import print_function |
NewerOlder