Skip to content

Instantly share code, notes, and snippets.

View hdon's full-sized avatar

Donny Viszneki hdon

View GitHub Profile
@hdon
hdon / aljebr.formats.js
Created December 5, 2014 15:17
Javascript library for working with algebra and descendent calculuses
var util = require('./util')
, KeyValueStore = util.KeyValueStore
, aljebr = require('./aljebr')
;
function serializeExpression(expression)
{
var eqNesting = 0;
function recurse(expression, parentOperator)
{
@hdon
hdon / common.py
Created December 5, 2014 15:09
Find Minecraft servers with the lowest latency!
from urllib2 import Request, urlopen
class ServerList():
listName = None
def __init__(self, data):
self.headers = { 'User-Agent': 'Mozilla/5.0' }
self.servers = data['servers']
if self.listName is None:
raise NotImplementedError("ServerList must override listName")
@hdon
hdon / scanner.js
Created December 5, 2014 13:36
A toy I wrote for Urban Terror
#!/usr/bin/gsr
var prg = "./ioUrbanTerror.i386";
//prg = "/usr/bin/env";
const PTRSIZE = 8;
const ffi = require("gffi");
const signal = require("signal");
const {ByteArray,ByteString} = require("binary");
const {include} = require("./include");
const {Reader} = require("./readline");
@hdon
hdon / HDReflect.js
Created December 5, 2014 13:34
Part of an old mod system I wrote for Minecraft
/* MakeHDReflect() reads Mincraft Coder Pack files (MCP) to build mappings
* between Notchian names (Java classes with obfuscated class, method,
* and field names, released to the public by Mojang) and "human" names
* (names chosen by reverse engineers.)
*
* It returns an object that allows you to inspect its procedure and also
* to begin writing "human" Javascript code!
*
* This function returns an object. Below is a description of each property
* you can expect to find in that object.
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()';
2169 if (!OBJ_DEFINE_PROPERTY(cx, obj, ATOM_TO_JSID(atom),
(gdb) print *((JSObject*)fun)->map->ops
$63 = {newObjectMap = 0xb7f140a6 <js_NewObjectMap>,
destroyObjectMap = 0xb7f14080 <js_DestroyObjectMap>,
lookupProperty = 0xb7f11364 <js_LookupProperty>,
defineProperty = 0xb7f1274c <js_DefineProperty>,
getProperty = 0xb7f110b2 <js_GetProperty>,
setProperty = 0xb7f1092a <js_SetProperty>,
getAttributes = 0xb7f115f8 <js_GetAttributes>,
setAttributes = 0xb7f127f8 <js_SetAttributes>,