Skip to content

Instantly share code, notes, and snippets.

View dotproto's full-sized avatar

Simeon Vincent dotproto

View GitHub Profile
@dotproto
dotproto / binary-utils.js
Last active December 30, 2015 23:18
Utilities for working with binary values in JavaScript.
// Numbers greater than (Math.pow(2,32) - 1) are subject to unexpected results
// bit-level operations. For example,
//
// (Math.pow(2,32) >> 1 === 0) // True
// (Math.pow(2,32) + 1 >> 1 === 0) // True
// (Math.pow(2,32) + 2 >> 1 === 1) // True
//
// As such, all methods defined here will throw an error on values above this safe limit.
var INT_MAX = Math.pow(2, 32) - 1;
var BYTE_MAX = 8;
@dotproto
dotproto / introducing_gloggy.md
Last active January 4, 2016 02:29
POST: Introducing Gloggy

Introducing Gloggy

Gloggy is a super simple (albiet terribly named) blogging system that runs on top of GitHub's Pages and Gists features.

Introducing Gloggy

Gloggy is a super simple (albiet terribly named) blogging system that runs on top of GitHub's Pages and Gists features.

@dotproto
dotproto / gloggy_fork.md
Last active February 14, 2024 01:55 — forked from dotproto/introducing_gloggy.md
POST: This is a test of a multi-line gist description. This is totally a hack. I'm sorry GitHub.

Introducing Gloggy

Gloggy is a super simple (albiet terribly named) blogging system that runs on top of GitHub's Pages and Gists features.

@dotproto
dotproto / app.js
Last active August 29, 2015 14:01 — forked from kelsin/app.js
var express = require('express');
var app = express();
// Load routes
require('./src/routes')(app);
@dotproto
dotproto / include.js
Last active February 14, 2024 01:55
Module-root relative file includes for Node.js
var fs = require('fs');
var path = require('path');
var parentModulePath = path.dirname(module.parent.filename);
// Recursively traverse up a given path tree checking for a file's existence.
function rstat(dir, filename, endPath) {
// End the search at endPath if provided, otherwise default to root
endPath = endPath || path.resolve('/');
var target = path.join(dir, filename);
@dotproto
dotproto / block-1.js
Created July 28, 2014 23:40
This is only a test
(function() {
console.log("You're the best around");
console.log("Nothing's ever gonna keep you down");
})()
@dotproto
dotproto / apply.js
Last active February 14, 2024 01:55
Function application as a service
function buildApply() {
var args = Array.prototype.slice.call(arguments, 0);
var fn = args.shift();
// proxy function
return function bindProxy() {
var proxyArgs = Array.prototype.slice.call(arguments, 0);
return fn.apply(null, args.concat(proxyArgs));
}
}

Keybase proof

I hereby claim:

  • I am svincent on github.
  • I am simeon (https://keybase.io/simeon) on keybase.
  • I have a public key whose fingerprint is 9C9B 5CCA 4B4A A1EE 69E3 2BCF 0CE9 6BFE 064E 3BFC

To claim this, I am signing this object:

@dotproto
dotproto / getPushIdTimestamp.js
Last active February 14, 2024 01:54
Convert a Firebase Push ID into Unix time (https://gist.github.com/mikelehen/3596a30bd69384624c11/)
var getPushIdTimestamp = (function getPushIdTimestamp() {
var PUSH_CHARS = '-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz';
return function getTimestampFromId(id) {
var time = 0;
var data = id.substr(0, 8);
for (var i = 0; i < 8; i++) {
time = time * 64 + PUSH_CHARS.indexOf(data[i]);
}