Skip to content

Instantly share code, notes, and snippets.

View Raynos's full-sized avatar

Jake Verbaten Raynos

View GitHub Profile
var Dialog = function () {
...
}
Dialog.prototype.appendChild = function (item) {
item.parentNode = this;
this.childNodes.push(item);
};
var Button = function () {
@Raynos
Raynos / Name.js
Created November 7, 2011 12:54 — forked from Gozala/weak-map.js
Namespacing shim for ES5
if (typeof(Name) === 'undefined') {
(function(global) {
"use strict";
function defineNamespace(object, namespace) {
var privates = Object.create(object),
base = object.valueOf;
Object.defineProperty(object, 'valueOf', {
value: function valueOf(value) {
@Raynos
Raynos / SomeKlass.js
Created November 9, 2011 20:07
OO utilities
var SomeKlass = (function () {
var privates = Name();
return {
public_method: public_method,
public_prop: 42,
constructor: constructor
};
function public_method() {
// optional typing for function parameters
// Allows you to use a string literal in front of the variable name
// This string literal must be a valid [[Class]] value
// And the function when invoked should throw a type error if the argument passed // in doesn't have the correct [[Class]] value
// If an argument is not passed in, the function should not throw an error
function Func("Function" f, "Array" arr) {
return f(arr);
}
@Raynos
Raynos / bootstrap.js
Created November 13, 2011 11:49
Arch demo
// bootstrap starts the server, does shit
module.exports = function (app) {
var routes = readdirSync("/routes");
routes.forEach(function (name) {
require("/routes/" + name)(app);
});
// MOAR bootstrap
// init database connections
// configure server
class Blog extends Controller {
submit() {
// logic
}
}
@Raynos
Raynos / super.js
Created November 15, 2011 14:10
Super, not so hard
// super simply snips the current objects [[Prototype]] out of the chain.
// It then continues to operate on the object and places that [[Prototype]] back in the chain when
// we are done.
var Base = {
super: function(method) {
var _proto = this.__proto__;
var args = [].slice.call(arguments, 1);
this.__proto__ = _proto.__proto__;
try {
{ [Error: getaddrinfo ENOENT]
code: 'ENOTFOUND',
errno: 'ENOTFOUND',
syscall: 'getaddrinfo',
error: 'socket',
'status-code': 500,
scope: 'request',
request:
{ method: 'PUT',
headers: [Object],
error { [Error: getaddrinfo ENOENT]
code: 'ENOTFOUND',
errno: 'ENOTFOUND',
syscall: 'getaddrinfo',
error: 'socket',
'status-code': 500,
scope: 'request',
request:
{ method: 'GET',
headers:
var Model = require("./model.js"),
error = require("error"),
pd = require("pd");
var UserModel = pd.make(Model,{
get: function _get(id, cb) {
this.nano.get(id,
error.whitelist(function _errors(err) {
if (err.syscall === 'getaddrinfo') {
UserModel.get(id, cb);