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
#ifndef _RUNNING_AVERAGE_H | |
#define _RUNNING_AVERAGE_H | |
#include <vector> | |
#include <iostream> | |
#include <cmath> | |
using namespace std; | |
class RunningAverage | |
{ |
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
<!-- 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 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
sudo -u postgres createuser gisuser | |
sudo -u postgres dropdb egypt-osm | |
sudo -u postgres createdb --encoding=UTF8 --owner=gisuser egypt-osm | |
sudo pluma /etc/postgresql/9.3/main/pg_hba.conf | |
change to use md5 authentication for local connections | |
sudo service postgresql restart |
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
#By Tim Sheerman-Chase | |
#Released under CC0 license | |
class InsertionSortedList(): | |
#Yay! I have re-invented insertion sort! | |
def __init__(self): | |
self._vals = [] | |
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
#2D Triangle-Triangle collisions in python | |
#Release by Tim Sheerman-Chase 2016 under CC0 | |
import numpy as np | |
def CheckTriWinding(tri, allowReversed): | |
trisq = np.ones((3,3)) | |
trisq[:,0:2] = np.array(tri) | |
detTri = np.linalg.det(trisq) | |
if detTri < 0.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
//2D Triangle-Triangle collisions in C++ | |
//Release by Tim Sheerman-Chase 2016 under CC0 | |
#include <vector> | |
#include <iostream> | |
#include <stdexcept> | |
using namespace std; | |
typedef std::pair<double, double> TriPoint; |
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
//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 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
//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 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
from PIL import Image | |
import os | |
for fina in os.listdir("."): | |
finas = os.path.splitext(fina) | |
if finas[1] != ".png": continue | |
img = Image.open(fina) | |
img.save(finas[0]+".jpg") | |
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 | |
import math | |
#https://gamedev.stackexchange.com/questions/23625/how-do-you-generate-tileable-perlin-noise | |
dirs = [(math.cos(a * 2.0 * math.pi / 256), | |
math.sin(a * 2.0 * math.pi / 256)) | |
for a in range(256)] | |
def surflet(gridX, gridY, x, y, hashfunc): | |
distX, distY = abs(x-gridX), abs(y-gridY) |