Skip to content

Instantly share code, notes, and snippets.

Turtles all the way

Marc Harter wavded

Turtles all the way
Block or report user

Report or block wavded

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View proto_inheritance.js
// Prototypal Inheritance (this function will eventually be in the JavaScript language)
if (typeof Object.create !== 'function') {
Object.create = function(o) {
function F() {}
F.prototype = o;
return new f();
View xhtml_base.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="" lang="en" xml:lang="en">
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
View singleton.js
var singleton = function() {
var privateVariable;
function privateFunction(x){
return {
firstMethod: function(a, b) {
secondMethod: function(a) {
View gist:252771
evaluates as a block — "{" and "}" — containing one labeled statement — `a:"a"`.
labeled statement, in its turn, evaluates to "a".
evaluates as an expression, where "(" and ")" are grouping operator and "{" and "}" constitute an object literal.
evaluates to this object value.
View gist:252777
/* in few words:no round brackets=function or object, round brackets:anything, arguments.callee included.diff is the left assignment */
var a = function(){return 1}(); // 1
var b = function(){return {}}(); //object
function(){return 1}(); //error
function(){return {}}(); //error
var c = (function(){return arguments.callee})(); //function
var d = (function(){return []})(); //array
View gist:253421
var a = {};
//to note: nothing is passed in and no private variables/functions/etc. on purpose
var b = (function(){
return {};
Is there any difference between a and b in regards to scope/execution? Any advantage one has over the other? (besides like arguments.callee/recursive stuff);
View geolocation.js
if (!navigator.geolocation) {
navigator.geolocation = (function (window) {
function getCurrentPosition(callback) {
// NOTE: for some reason, chaging the url is *allowed* with this service. Useful, but random
// source:
// The source is open source, as per:, but doesn't discuss specific license use. Hopefully it's just free to use - yay internet!
var geourl = '' + Math.random(),
iframe = document.createElement('iframe'),
doc, win;
View crockfordfacts.js
var sys = require("sys")
var http = require("http");
var twitter = http.createClient(80, "");
var count = 10
for (var i = 1; i <= count; i++) {
var request = twitter.request("GET", "/search.json?q=crockfordfact+OR+crockfordfacts&rpp=100&page=" + i, {"host": ""});
request.addListener('response', function(response) {
View localStorage wrapper
/* Overwrite localStorage w/ cookie-based storage if browser does not support */
if(typeof localStorage === "undefined" || localStorage === null){
function getExpiration(isRemove){
var date = new Date();
date.setTime((+date)-1000); //sometime in past
} else {
date.setTime((+date)+30758400000); //356 days ahead
View node-proxy-server
//sample proxy server for node.js from
var http = require('http');
http.createServer(function(request, response) {
var proxy = http.createClient(80, request.headers['host'])
var proxy_request = proxy.request(request.method, request.url, request.headers);
proxy_request.addListener('response', function (proxy_response) {
proxy_response.addListener('data', function(chunk) {
You can’t perform that action at this time.