Skip to content

Instantly share code, notes, and snippets.

View jhuckaby's full-sized avatar

Joseph Huckaby jhuckaby

View GitHub Profile
@jhuckaby
jhuckaby / pack-bench.js
Created August 17, 2020 00:19
Benchmarks for pixl-pack vs msgpack-lite
var msgpack = require("msgpack-lite");
var pack = require('pixl-pack');
var tests = [
[ "Null", null ],
[ "Boolean", true ],
[ "String", "Now is the time for all good men to come to the aid of their country." ],
[ "Buffer", Buffer.from("Now is the time for all good men to come to the aid of their country.") ],
[ "Number", 12345.67890 ],
[ "Object", { foo: "bar", "num": 123 } ],
@jhuckaby
jhuckaby / gist:cb0ac839cd704ec28b122555fe8c8bf8
Created October 6, 2019 06:57
Node.js ES6 Map crash after 15 million keys
<--- Last few GCs --->
[4433:0x3dc6880] 104473 ms: Scavenge 2019.9 (2024.9) -> 2019.2 (2030.1) MB, 29.9 / 0.0 ms (average mu = 0.297, current mu = 0.284) allocation failure
[4433:0x3dc6880] 104641 ms: Scavenge 2022.8 (2030.1) -> 2021.0 (2031.1) MB, 25.6 / 0.0 ms (average mu = 0.297, current mu = 0.284) allocation failure
[4433:0x3dc6880] 104766 ms: Scavenge 2023.7 (2031.1) -> 2022.3 (2032.9) MB, 40.8 / 0.0 ms (average mu = 0.297, current mu = 0.284) allocation failure
<--- JS stacktrace --->
==== JS stack trace =========================================
@jhuckaby
jhuckaby / advent-pro-regular-style.js
Created January 24, 2019 05:07
Preload single regular Advent Pro style, then render it using node-canvas
const { registerFont, createCanvas } = require('canvas');
registerFont( 'AdventPro-Regular.ttf', { family: "AdventProRegular" } );
var canvas = createCanvas( 600, 100 );
var ctx = canvas.getContext( '2d' );
ctx.fillStyle = '#ffffff';
ctx.fillRect( 0, 0, canvas.width, canvas.height );
@jhuckaby
jhuckaby / advent-pro-all-styles.js
Created January 24, 2019 05:06
Preload all Advent Pro styles, then render regular style using node-canvas
const { registerFont, createCanvas } = require('canvas');
registerFont( 'AdventPro-Bold.ttf', { family: "AdventProBold" } );
registerFont( 'AdventPro-ExtraLight.ttf', { family: "AdventProExtraLight" } );
registerFont( 'AdventPro-Light.ttf', { family: "AdventProLight" } );
registerFont( 'AdventPro-Medium.ttf', { family: "AdventProMedium" } );
registerFont( 'AdventPro-Regular.ttf', { family: "AdventProRegular" } );
registerFont( 'AdventPro-SemiBold.ttf', { family: "AdventProSemiBold" } );
registerFont( 'AdventPro-Thin.ttf', { family: "AdventProThin" } );
@jhuckaby
jhuckaby / geometry.js
Created March 28, 2015 06:21
2D Geometry Tools
// Joe's Game Geometry Tools
// Copyright (c) 2010 Joseph Huckaby
// Released under the MIT License
function _RADIANS_TO_DECIMAL(_rad) { return _rad * 180.0 / Math.PI; }
function _DECIMAL_TO_RADIANS(_dec) { return _dec * Math.PI / 180.0; }
//
// Point class
//
### Keybase proof
I hereby claim:
* I am jhuckaby on github.
* I am jhuckaby (https://keybase.io/jhuckaby) on keybase.
* I have a public key whose fingerprint is DF0B 767B 5FD8 8392 F6D4 F46C 04CB 5A33 53BF 6C11
To claim this, I am signing this object:
@jhuckaby
jhuckaby / setsigntext.js
Last active January 1, 2016 17:09
Minecraft Bukkit ScriptCraft extension for setting sign text on already placed signs. Usage: /js setsigntext(X, Y, Z, ["Hello", "There", "Line 3", "Line 4"]); Install to the ScriptCraft drone/contrib/ folder and restart the server, or type /js refresh(); to reload.
/* Set sign text on an already placed sign. */
/* Specify sign block coordinates and array of strings. */
/* This will currently only work on the main overworld on a server. */
/* Usage: /js setsigntext(-847, 63, 107, ["Hello", "There"]); */
/* Author: Joseph Huckaby, December 29, 2013 */
/* License: Public Domain */
// For ScriptCraft 1.7, uncomment this, I think:
@jhuckaby
jhuckaby / cc-news-widget.php
Created January 17, 2013 05:05
RSS News Widget for CubixCloud.com.
<?php
// RSS Feed Widget for CubixCloud
// by Joseph Huckaby
// Copyright (c) 2012 CubixCloud.com
// Insert this into your HTML:
// <iframe width="570" height="243" frameborder="0" src="cc-news-widget.php" marginwidth="0" marginheight="0" vspace="0" hspace="0" scrolling="no"></iframe>
$rss_url = 'http://blog.cubixcloud.com/feed';
@jhuckaby
jhuckaby / subl.pl
Created July 8, 2012 03:37
A better subl for launching Sublime Text 2 via the command-line (forces file to open in new window)
#!/usr/bin/perl
# A replacement for Sublime Text 2's built-in "subl" command-line utility,
# which forces files into new windows regardless of prefs.
# by Joseph Huckaby, 2012
use strict;
use Cwd qw/abs_path/;
use FileHandle;
@jhuckaby
jhuckaby / parseQueryString.js
Last active September 26, 2015 16:28
Parse query string into key/value pairs and return as object
function parseQueryString(url) {
// parse query string into key/value pairs and return as object
var query = {};
url = (url || location.search).replace(/^.*\?/, '').replace(/([^\=]+)\=([^\&]*)\&?/g, function(match, key, value) {
query[key] = decodeURIComponent(value);
return '';
} );
return query;
}