Skip to content

Instantly share code, notes, and snippets.

cwleonard /
Created Sep 19, 2018
dynamically set a GoDaddy DNS record
myip=`curl -s -X GET | jq -r .ip`
recip=`curl -s -X GET "$domain/records/A/$aname" -H "accept: application/json" -H "Authorization: sso-key $key:$secret" | jq -r .[0].data`
cwleonard / hooked.js
Last active Aug 29, 2015
Used with the microservice framework to calculate the date of Easter for a given year.
View hooked.js
module['exports'] = function easter(hook) {
var year = hook.params.year;
hook.debug("i am going to calculate the date of Easter for " + year);
// using the "Meeus/Jones/Butcher" algorithm
var a = year % 19;
var b = Math.floor(year/100);
var c = year % 100;
var d = Math.floor(b/4);
cwleonard / jspolygon.js
Created Aug 30, 2014
Convex Polygon Intersection
View jspolygon.js
* This is the Point constructor. Polygon uses this object, but it is
* just a really simple set of x and y coordinates.
function Point(px, py) {
this.x = px;
this.y = py;
cwleonard / ansiconsole.js
Last active Dec 25, 2015
Create an emulation of a VT100 terminal on a web page, with ANSI graphics support. Have old ANSI art laying around? Showcase it on the web, dynamically. It doesn't have blink support, yet. You can see it in use here: ( with sample ANSIs from an old BBS I helped run back in the 90's.
View ansiconsole.js
var MAX_ROW = 30;
var BLANK = " ";
var BLACK = 0;
var RED = 1;
var GREEN = 2;
var YELLOW = 3;
var BLUE = 4;
var MAGENTA = 5;
var CYAN = 6;
You can’t perform that action at this time.