Skip to content

Instantly share code, notes, and snippets.

View samshull's full-sized avatar
🎯
Focusing

Sam Shull samshull

🎯
Focusing
View GitHub Profile
@samshull
samshull / gist:fe4ea1f14396387f4f6d
Last active August 29, 2015 14:06
simplifying method_missing functionality with Proxy
var root = (function(){ return this; })();
function ProxyClass() {
if (this === root) throw Error();
var instance = this;
return Proxy.create({
get: function(receiver, name) {
console.log('get', name);
return instance[name] || (instance._get && instance._get(name, receiver)) || undefined;
},
From b26787bc203f0318161d014baea93894ca881244 Mon Sep 17 00:00:00 2001
From: Sam Shull <brickysam26@gmail.com>
Date: Tue, 20 Jul 2010 14:09:09 -0400
Subject: [PATCH] Add parenthesis to NODE_VERSION_AT_LEAST
---
src/node_version.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/node_version.h b/src/node_version.h
From ba387e2b80e4ea02652d66c2d0e689d172907719 Mon Sep 17 00:00:00 2001
From: Samuel Shull <brickysam26@samuel-shulls-computer.local>
Date: Wed, 4 Aug 2010 01:25:17 -0400
Subject: [PATCH] Add node_version.h to install
---
wscript | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/wscript b/wscript
<?php
$_Retreived = array(
"website1.com" => array(
array('60" BRAVIA LX900 Series 3D HDTV', 'website1.com', 5299.99),
array('52" BRAVIA LX900 Series 3D HDTV', 'website1.com', 4499.99),
array('46" BRAVIA LX900 Series 3D HDTV', 'website1.com', 3699.99),
array('40" BRAVIA LX900 Series 3D HDTV', 'website1.com', 2999.99)
),
"website2.com" => array(
array('Sony 3D 60" LX900 HDTV BRAVIA', 'website2.com', 5400.99),
function encode_users(data) {
var string = '';
$.each(data, function(index, info) {
string += '&users[' + index + '][onlineid]=' + encodeURIComponent(info.onlineid);
string += '&users[' + index + '][comment]=' + encodeURIComponent(info.comment);
});
return string;
}
$.ajax({
@samshull
samshull / proxy_memleak.js
Created June 24, 2011 18:37 — forked from richardms/proxy_memleak.js
Possible memory leak in node-proxy
// Run with:
// node --trace-gc proxy_memleak.js
var Proxy = require("/Users/brickysam26/Projects/node-proxy/lib/node-proxy"),
// fs = require('fs'),
util = require("util") ;
var count = 100000 ;
@samshull
samshull / stack-trace.js
Created July 18, 2011 02:13
Cross Browser javascript stack trace
function printStackTrace() {
var callstack = [];
var isCallstackPopulated = false;
try {
i.dont.exist+=0; //doesn't exist- that's the point
} catch(e) {
if (e.stack) { //Firefox
var lines = e.stack.split('\n');
for (var i=0, len=lines.length; i<len; i++) {
if (lines[i].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) {
@samshull
samshull / gist:1139560
Created August 11, 2011 12:49
better_world
def better_world
people_of_the_world.reject! do |person|
person.is_lawyer? || person.is_politician?
end
end
if (!('filter' in Array.prototype)) {
// conforms with the ECMA standard
Array.prototype.filter = function filter(fn, thisArg) {
var index = 0, length = this.length, value, returnValue = [], that = Object(this);
for (; index < length; ++index) {
if (index in that) {
value = that[index];
if (fn.call(thisArg, value, index, that)) {
returnValue.push(value);
}