Skip to content

Instantly share code, notes, and snippets.

View peterwallhead's full-sized avatar
👨‍💻
coding all the things

Peter Wallhead peterwallhead

👨‍💻
coding all the things
View GitHub Profile
@peterwallhead
peterwallhead / UUID.php
Last active December 23, 2015 04:09 — forked from dahnielson/UUID.php
<?php
/**
* UUID class
*
* The following class generates VALID RFC 4211 COMPLIANT
* Universally Unique IDentifiers (UUID) version 3, 4 and 5.
*
* UUIDs generated validates using OSSP UUID Tool, and output
* for named-based UUIDs are exactly the same. This is a pure
* PHP implementation.
@peterwallhead
peterwallhead / k-means-clustering.php
Last active December 29, 2015 21:08
K-Means Clustering with PHP. Original source http://phpir.com/clustering and downloadable via http://phpir.com/user/files/cluster.zip
<?php
$data = array(
array(0.05, 0.95),
array(0.1, 0.9),
array(0.2, 0.8),
array(0.25, 0.75),
array(0.45, 0.55),
array(0.5, 0.5),
array(0.55, 0.45),
var json = {
data: ['a','bunch','of','things']
};
var otherData = {
things: [],
madness: {}
};
json.data.forEach(function(data,index,array){
@peterwallhead
peterwallhead / 0_reuse_code.js
Created October 1, 2015 23:49
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#
# Controlling an RC car via webcam (well, so far, just tracking it...)
#
# Requires OpenCV 2.0 and Python 2.6
#
import cv
def find_car(image):
@peterwallhead
peterwallhead / dns-record-sets.md
Last active August 31, 2016 04:46
DNS record sets for my new side project domains (that use Servercrew as email host and Mailgun for transactional email)

A Record:

  • *.example.com > IP
  • example.com > IP

MX Record:

  • example.com > 40:webmail.servercrew.com.au

CNAME Record:

  • email.example.com > mailgun.org
.box {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
/* A version of https://github.com/johnwargo/Seeed-Studio-Relay-Board/blob/master/seeed_relay_test.py in C for use with https://www.seeedstudio.com/Raspberry-Pi-Relay-Board-v1.0-p-2409.html */
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <wiringPiI2C.h>
int deviceRegMode1 = 0x06;
int deviceRegData = 0xff;
@peterwallhead
peterwallhead / compre.py
Created July 12, 2018 20:29 — forked from soruly/compre.py
Compare two images using OpenCV and SIFT in python
import cv2
import sys
import os.path
import numpy as np
def drawMatches(img1, kp1, img2, kp2, matches):
rows1 = img1.shape[0]
cols1 = img1.shape[1]
rows2 = img2.shape[0]