Skip to content

Instantly share code, notes, and snippets.

View tlhunter's full-sized avatar
👨‍💻
coding

Thomas Hunter II tlhunter

👨‍💻
coding
View GitHub Profile
@tlhunter
tlhunter / distance-geolocation.js
Created May 18, 2017 00:07
Get the distance between two points in meters
function getDistance(p1, p2) {
var radlat1 = Math.PI * p1.lat/180;
var radlat2 = Math.PI * p2.lat/180;
var theta = p1.lng - p2.lng;
var radtheta = Math.PI * theta/180;
var dist = Math.sin(radlat1) * Math.sin(radlat2) + Math.cos(radlat1) * Math.cos(radlat2) * Math.cos(radtheta);
dist = Math.acos(dist);
dist = dist * 180 / Math.PI;
dist = dist * 60 * 1.1515 * 1.609344 * 1000;
return dist;
@tlhunter
tlhunter / average-geolocation.js
Created May 17, 2017 18:00
Calculate the center/average of multiple GeoLocation coordinates
/**
* Calculate the center/average of multiple GeoLocation coordinates
* Expects an array of objects with .latitude and .longitude properties
*
* @url http://stackoverflow.com/a/14231286/538646
*/
function averageGeolocation(coords) {
if (coords.length === 1) {
return coords[0];
}
'use strict';
/**
* Experimenting with building a better grid based entity management system
* Uses more efficient Map/Set calls, requiring modern browsers / Node.js
*/
const SPAWNS = [
{x: 1, y: 1},
{x: 1, y: 2},

Computing Needs

  • Ability to build and sign iOS Apps
  • Ability to play games in Steam library
  • Ability to develop applications on the go

Solutions

Keep Existing System ($0)

@tlhunter
tlhunter / maybe-observer.js
Created November 5, 2015 06:39
Observing and interfering with player-world interaction
'use strict';
/**
* Represents a single player
*/
let Player = function(x, y, health) {
this.events = {
encroach: [],
enter: [],
exit: []
@tlhunter
tlhunter / flip.js
Created November 2, 2015 00:06
Flips every item in a PNG spritesheet horizontally, maintaining position
#!/usr/bin/env node
/**
* Flips each item in a spritesheet horizontally, maintaining position
* @author Thomas Hunter II <[email protected]>
*
* 1) Execute `npm install lwip async`
* 2) Delete the following conditional in the lwip node_module:
* https://github.com/EyalAr/lwip/blob/1138482318e79ee6c69706b544ed5d6ffe11391c/lib/ImagePrototypeInit.js#L467
*/
var print = typeof print === 'function' ? print : console.log.bind(console);
function X() {
}
X.prototype.dispatch = function (obj) {
this[obj.type](obj);
};
var DEGREE = 20;
var level_result = createLevel(12, {data: true});
console.log(level_result);
function createLevel(user_id, level_data) {
var user = getUser(user_id);
var can_create = canCreate(user);
if (!can_create) {
return null;
}
#EXTM3U
#EXTINF:-1,Groove Salad: a nicely chilled plate of ambient beats and grooves. [SomaFM]
http://uwstream1.somafm.com:80
#EXTINF:-1,Dub Step Beyond: Dubstep, Dub and Deep Bass. May damage speakers at high volume. [SomaFM]
http://somafm.com/dubstep.pls
#EXTINF:-1,Def Con Radio: SomaFM's special mix for Def Con [SomaFM]
http://somafm.com/defcon.pls
#EXTINF:-1,The Trip: Progressive house / trance. Tip top tunes. (Formerly Tag's Trance Trip) [SomaFM]
http://somafm.com/thetrip.pls
#EXTINF:-1,Suburbs of Goa [SomaFM]
@tlhunter
tlhunter / gist:31830e88fb27bd3277fd
Created June 19, 2014 03:19
Attempting to upgrade Nginx on Debian
# http://wiki.nginx.org/Install#Official_Debian.2FUbuntu_packages
$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
nginx
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 477 kB of archives.