Skip to content

Instantly share code, notes, and snippets.


Mark Penner mnpenner

View GitHub Profile
kitek / gist:1579117
Created Jan 8, 2012
NodeJS create md5 hash from string
View gist:1579117
var data = "do shash'owania";
var crypto = require('crypto');
eirikbacker / addEventListener-polyfill.js
Created Jun 3, 2012
addEventListener polyfill for IE6+
View addEventListener-polyfill.js
//addEventListener polyfill 1.0 / Eirik Backer / MIT Licence
(function(win, doc){
if(win.addEventListener)return; //No need to polyfill
function docHijack(p){var old = doc[p];doc[p] = function(v){return addListen(old(v))}}
function addEvent(on, fn, self){
return (self = this).attachEvent('on' + on, function(e){
var e = e || win.event;
e.preventDefault = e.preventDefault || function(){e.returnValue = false}
e.stopPropagation = e.stopPropagation || function(){e.cancelBubble = true}
magnetik / php-cli.php
Created Jun 20, 2012
Php command line parser
View php-cli.php
function parseArguments()
$out = array();
foreach($argv as $arg)
if(substr($arg, 0, 2) == '--')
$eqPos = strpos($arg, '=');
if($eqPos === false)
aknosis / calendar.twig
Created Oct 22, 2012
Table based calendar only using Twig
View calendar.twig
time can be any string acceptable by, the
template will output that time's month.
If you don't want to pass in a date you can set time like this:
{% set time = "now"|date("U") %}
{% set time = "December 2012"|date("U") %}
How ever you want to output items onto the calendar is a different issue,
but I'd assume pushing everything into an array numerically indexed by that day:
iso2022jp / base94.c
Created Nov 11, 2012
base94 encoder/decoder
View base94.c
#include "base94.h"
void base94_encode(const unsigned char *plain, unsigned char *code) {
// high * 2^64 | low
unsigned long long value
= ((unsigned long long)plain[1] << 56) | ((unsigned long long)plain[2] << 48)
| ((unsigned long long)plain[3] << 40) | ((unsigned long long)plain[4] << 32)
aaronpowell / selectMany.js
Created Nov 19, 2012
LINQ SelectMany in JavaScript
View selectMany.js
Array.prototype.selectMany = function (fn) {
return (x, y) { return x.concat(y); }, []);
// usage
console.log([[1,2,3], [4,5,6]].selectMany(function (x) { return x; })); //[1,2,3,4,5,6]
console.log([{ a: [1,2,3] }, { a: [4,5,6] }].selectMany(function (x) { return x.a; }));
willurd /
Last active Jan 29, 2023
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
jeppeburchardt / msbuild node gyp
Created Jul 17, 2013
node gyp msbuild misssing registry warning MSB8003: Could not find WindowsSDKDir variable from the registry. TargetFrameworkVersion or PlatformToolset may be set to an invalid version number
View msbuild node gyp
call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x86
call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x64
danneu / base66.clj
Last active Aug 1, 2018
base66 encoder/decoder (encodes integer to url-friendly characters)
View base66.clj
(def digits
(seq (str "0123456789"
(def radix (count digits))
(defn encode
"Encodes Long to String."
kmcallister / rust-backtrace
Last active Jan 16, 2016
Run a Rust program and print a stack backtrace on failure (old)
View rust-backtrace
### NOTE ### You probably don't need this anymore!
# Usage: rust-backtrace ./my-rust-prog args...
exec gdb -batch -n -x /dev/fd/3 --args "$@" 3<<ENDGDB
set height 0
set breakpoint pending on