Skip to content

Instantly share code, notes, and snippets.


  • Earth
Block or report user

Report or block hn3000

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
hn3000 / algolia.swagger2.json
Created Mar 26, 2019
Algolia API (partial) as swagger 2.0
View algolia.swagger2.json
"$schema": "",
"swagger": "2.0",
"info": {
"title": "Swaggerized Algolia API",
"version": "1"
"basePath": "/1",
"schemes": [ "https" ],
"host": "${APPLICATION_ID}",
hn3000 / gist:8ea3eab2910fa37a9e8321f106310947
Created Nov 19, 2018
my vscode (-insiders) extensions
View gist:8ea3eab2910fa37a9e8321f106310947
$ code-insiders --list-extensions
hn3000 / shallowMerge.ts
Created Nov 13, 2018
shallow merge, one of my favourites
View shallowMerge.ts
function shallowMerge(a:any, b:any):any {
let result:any = {};
let tmp:any = {};
Object.keys(a).forEach((x) => tmp[x]=x);
Object.keys(b).forEach((x) => tmp[x]=x);
let keys = Object.keys(tmp);
for (var k of keys) {
result[k] = null != b[k] ? b[k] : a[k];
View round-to-digits.js
function roundToDigits(x,n) {
let digits = Math.ceil(Math.log(x) / Math.log(10));
let scale = Math.pow(10, n - digits);
return Math.round(x * scale)/scale;
hn3000 / numbers-by-width-in-font.html
Last active Jul 7, 2018
Sort numbers by width in Helvetica, as suggested by XKCD 2016
View numbers-by-width-in-font.html
<!doctype html>
<title>Numbers ordered by width in Helvetica</title>
body { font: 13px Helvetica; }
<h1>Sort numbers by Width</h1>
hn3000 / aggregation.ts
Created Nov 14, 2017
(pretty) generic aggregation / grouping function using reduce
View aggregation.ts
function aggregate<I, V>(
items: I[],
valueFun: (i: I) => V,
groupingFun: (i: I) => string,
combineFun: (v1: V, v2: V) => V
): ({ [g:string]: V }) {
return items.reduce(
(r: { [g: string]: V }, i: I) => {
hn3000 / gist:02d75ab05921701412cd4247f8e2e909
Created Jul 12, 2017
collection of typescript typing snippets
View gist:02d75ab05921701412cd4247f8e2e909
// make sure literal conforms to type
let var: Type = {
prop2: 123,
extra: 'value' // will give an error for extra properties
// make sure properties from type are spelled correctly
hn3000 / gist:7b6a04105017010aecb8778e28dc4b03
Last active Jul 11, 2017
include images and other resources in a repo's wiki
View gist:7b6a04105017010aecb8778e28dc4b03
1) add the resource into a folder of the wiki repository
1a) clone the wiki repo, it's git url can be found on the right hand side of wiki pages
1b) create folder, add resource, push to repo
2a) add link to resource: [link to pdf](../assets/Filename.pdf)
2b) image link: [[assets/image.png]]
View gist:af9c0584a45f71c40b1ed48ce41fe057
# List of state management libraries
hn3000 / samldecode.js
Created Apr 12, 2017
real simplistic SAML request decoder
View samldecode.js
#!/usr/bin/env node
var { Buffer } = require('buffer');
var zlib = require('zlib');
var param = process.argv[2];
var raw = Buffer.from(decodeURIComponent(param), 'base64');
var decoded = zlib.inflateRawSync(raw);
You can’t perform that action at this time.