Skip to content

Instantly share code, notes, and snippets.

View XerxesNoble's full-sized avatar
🔋

Xerxes XerxesNoble

🔋
View GitHub Profile
function measure(lat1, lon1, lat2, lon2){ // generally used geo measurement function
const { PI, cos, sin, sqrt, atan2 } = Math // math fns
const R = 6378.137 // Radius of earth in KM
// PI is equivilant to 180 degrees, so divide PI by 180
// and you get how many radians constitute a single degree
const radsInSingleDegree = (PI / 180)
// Get the amount of radians between the two coordinates
const [dLat, dLon] = [
(lat2 * radsInSingleDegree) - (lat1 * radsInSingleDegree),
(lon2 * radsInSingleDegree) - (lon1 * radsInSingleDegree),
@XerxesNoble
XerxesNoble / gist:d2fa36d9b54cc667c2ae90d84f3cb9cc
Created July 18, 2017 00:18 — forked from chrsgrffth/gist:c2b33896138aa1894cfd
Forward Port 80 to 3000 for Node.js (from StackOverflow)
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
@XerxesNoble
XerxesNoble / animate_values.js
Last active March 9, 2024 13:07
Basic javascript linear value animation that can accept easing functions and provides update & complete callbacks
/**
* @desc Basic linear value animation that can accept simple easing functions and provides update & complete callbacks
* @param {Object} values - Object with numerical values. eg. { value1: 0, value2: 20, someKey: 55 }
* @param {Number} duration - How long (in milliseconds) the animation will be
* @param {Object} options - target values, update callback & complete callback
* @param {Function} [options.onComplete=(values) => values] - Callback that fires once animation is complete
* @param {Function} [options.onUpdate=(values) => values] - Callback that fires when animation frame updates
* @param {Function} [options.ease=(t) => t] - easing method eg. https://gist.github.com/gre/1650294
* @example
*
@XerxesNoble
XerxesNoble / 0_reuse_code.js
Created January 25, 2016 20:25
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