Skip to content

Instantly share code, notes, and snippets.

Pete Cleary petecleary

Block or report user

Report or block petecleary

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
petecleary / LeapHandPosition.js
Created Oct 30, 2017
Leap Motion JavaScript hand position. Simple method to collect the palm position of the first hand on every leap motion frame loop.
View LeapHandPosition.js
var handPos = { handId: '', normX: 0, normY: 0, normZ: 0, posX: 0, posY: 0, posZ: 0, rotX: 0, rotY: 0, rotZ: 0, set: false };
Leap.loop(function (frame) {
var handIds = {};
if (frame.hands === undefined) {
var handsLength = 0
} else {
var handsLength = frame.hands.length;
petecleary / UdpMessage.cs
Created Oct 17, 2017
How to send a UDP message in C#
View UdpMessage.cs
using System.Net;
using System.Net.Sockets;
string hostName = "";
int port = 5000;
string msg = "Hello";
UdpClient udpClient = new UdpClient(hostName, port);
Byte[] sendBytes = Encoding.ASCII.GetBytes(msg);
petecleary / CompassLocation.cs
Created Oct 17, 2017
Unity mobile compass controller, how to enable and rotate the transform based on the magnetic heading
View CompassLocation.cs
using System;
using UnityEngine;
using UnityEngine.UI; //required for Input.compass
public float compassSmooth = 0.5f;
private float m_lastMagneticHeading = 0f;
public class CompassController : MonoBehaviour {
// Use this for initialization
void Start () {
petecleary / trail.html
Created Oct 17, 2017
Mouse Trail on HTML Canvas
View trail.html
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<div class="parent">
<div class="container">
<canvas id="trailCanvas" width="800" height="600" style="margin:0;padding:0;z-index:500; border: 1px solid #000;"></canvas>
petecleary / location.js
Created Oct 17, 2017
In Browser location test using navigator.geolocation - example @
View location.js
var x = document.getElementById("demo");
var watchID = null;
var counter = 0;
function geo_success(position) {
counter += 1;
x.innerHTML = "Latitude: " + position.coords.latitude + ", Longitude: " + position.coords.longitude + ", Count: " + counter;
function geo_error() {
x.innerHTML = "Sorry, no position available.";
petecleary / headTracking.js
Created Oct 17, 2017
Head tracking using Tracking.Js - this example is linked into a synth made in tone.js - for more details see
View headTracking.js
window.onload = function () {
var video = document.getElementById('video');
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
var tracker = new tracking.ObjectTracker('face');
petecleary / comms.js
Created Oct 17, 2017
Web Socket - a starting point for a simple web socket communication object, sending JSON with a to value to target all or one specified user
View comms.js
var piComms = function (userName, setGlobal, pingInterval) {
'use strict';
var user = userName;
var pingTimerId;
var pingTimerInterval = (pingInterval != undefined) ? pingInterval : 5000;
setGlobal = (setGlobal != undefined && setGlobal == false);
var pub = {
setUserName: function (userName) {
petecleary / gist:5106718
Created Mar 7, 2013
CSV, MongoDB example Loops through an import CSV and writes the rows to mongo
View gist:5106718
//npm install csv
//npm install mongodb
var csv = require('csv');
var fs = require('fs');
var start =;
// Retrieve
var mongoclient = require('mongodb').MongoClient;
petecleary / gist:5063652
Last active Dec 14, 2015
localizeReader is a function that helps provides a standard way to read a resource based on a culture. It takes the object to find the value for and the culture. It will first look for the specific culture ("de-DE"), then fallback to the neutral culture ("de"), then to a default version, then pick the first in the object. It works for objects as…
View gist:5063652
var localizeReader = exports;
(function (localizeReader) {
localizeReader.get = function(obj, culture){
var c = (!culture) ? 'default': culture;
if(obj[c] !== undefined) return obj[c];
c = c.split('-')[0];
if(obj[c] !== undefined) return obj[c];
for (var prop in obj) {
return obj[prop];
You can’t perform that action at this time.