Skip to content

Instantly share code, notes, and snippets.

View hdon's full-sized avatar

Donny Viszneki hdon

View GitHub Profile
@hdon
hdon / bug-20170416
Created April 16, 2017 23:11
bug-20170416
hdon@behemoth:~/src/git/bug-20170416$ cat foobarbaz.c
#include <stdlib.h>
#include <string.h>
typedef struct foo {
size_t *bar;
} foo;
int main(int argc, char **argv) {
foo baz;
hdon@behemoth:~/src/git$ git init trailstest
Initialized empty Git repository in /home/hdon/src/git/trailstest/.git/
hdon@behemoth:~/src/git$ cd trailtest
bash: cd: trailtest: No such file or directory
(reverse-i-search)`': ^C
hdon@behemoth:~/src/git$ cd trailstest
hdon@behemoth:~/src/git/trailstest$ yo
? 'Allo Don! What would you like to do? Trails
Make sure you are in the directory you want to scaffold into.
@hdon
hdon / database.json
Created March 6, 2017 20:33
Connecting to MySQL with Knex
{
"host": "xxxxxxxxxx"
, "user": "xxxxxxxxxx"
, "password": "xxxxxxxxxxxxxxxxxxxx"
, "database": "xxxxxxxxxxxxxxxxx"
}
@hdon
hdon / natstrings
Created August 20, 2016 22:03
IPv4 NAT string substitution
#!/usr/bin/env python
import sys, re
def s2ip(s):
a, b, c, d = map(int, s.split('.'))
return (a << 24) | (b << 16) | (c << 8) | d
def ip2s(n):
return '%d.%d.%d.%d' % (
(n >> 24)
,(n >> 16)& 255
@hdon
hdon / Gruntfile.js
Last active September 15, 2015 16:16
grunt-browserify-sourcemap-line-offset-2-bug
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
browserify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
, browserifyOptions: {
debug: true /* generate source maps */
}
}
donny@pacemates:~/gpsee/narwhal-old$ js test.js
policies:
Policy:
function Policy() {
this.identity = true;
this.requirepath = new SearchPath;
this.filejail = "/";
}
instance:
identity:
donny@teamspace:~/gpsee/src$ gsr -ddzz crash.js
JS exception #147 - uncaught exception: gpsee.module.ca.page.binary.ByteArray.setProperty.type: cannot apply this method to gpsee.module.ca.page.binary.ByteArray-type object
Failed loading program module 'crash.js': module initialization failed
donny@teamspace:~/gpsee/src$ ./embrace/gpsee-js/gpsee-js
js> const binary = require("binary")
js> binary.ByteArray.prototype.sort
function sort() {
[native code]
}
js> binary.ByteArray.prototype.sort = function(){return 'buzz off'}
/** Implements ByteArray.toArray() */
static JSBool ByteArray_toArray(JSContext *cx, uintN argc, jsval *vp)
{
return gpsee_throw(cx, CLASS_ID "toArray.unimplemented: this method is not yet implemented!");
}
/** Implements ByteArray.toString() */
static JSBool ByteArray_toString(JSContext *cx, uintN argc, jsval *vp)
{
return gpsee_throw(cx, CLASS_ID "toString.unimplemented: this method is not yet implemented!");
}
'#!/usr/bin/gsr -zzdd'
/* A pure Javascript reference implementation of ServerJS's binary ByteArray
* class for reference, implementation, and testing purposes.
*
* For more info see: https://wiki.mozilla.org/ServerJS/Binary/B
*/
/* Do we have modules? */
if (('function' == typeof require) && require("binary")) {
#! /usr/bin/gsr -zzdd
const ByteString = require("binary").ByteString;
const Binary = require("binary").Binary;
/* Provide some scaffolding for individual tests */
var testUtils = {
/* eq compares two or more values and expects that they will pass an equality test without type coercion (===) */
'eq': function() {
if (arguments.length < 2) throw 'too few arguments to testUtils.eq()';