Skip to content

Instantly share code, notes, and snippets.

View imbcmdth's full-sized avatar

Jon-Carlos Rivera imbcmdth

View GitHub Profile
@imbcmdth
imbcmdth / target.js
Created March 9, 2012 00:03
A Better "AppDev University - Full Stack Web Development"
var asymHumanoidBodyParts = [["head", 3],
["left-eye", 1],
["left-ear", 1],
["mouth", 1],
["nose", 1],
["neck", 2],
["left-shoulder", 3],
["left-upper-arm", 3],
["chest", 10],
["back", 10],
@imbcmdth
imbcmdth / gist:2958401
Created June 20, 2012 06:14
Example IIFE
(function(global) { // global is == to window
"use strict"; // Tells JS engine to warn you about silly things you've done
var myVariable = 10;
function internalFunction(val) {
return myVariable * val;
}
global.externalFunction = function(num){
<html>
<head>
<title>IIFE App</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<input type="button" id="idButton" value="Click Me!">
<div id="idOutput"></div>
<script type="text/javascript" src="LoadIIFE.js"></script>
</body>
<html>
<head>
<title>IIFE App</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<input type="button" id="idButton" value="Click Me!">
<div id="idOutput"></div>
<script type="text/javascript" src="LoadIIFE.js"></script>
</body>
var parent = {a:2, b:33};
var ChildMaker = function(){};
ChildMaker.prototype = parent;
var child = new ChildMaker();
parent.c = 2;
child.c; // 2
var require = function(require){
var NM = function(){
var src = process.binding('natives');
src = Object.keys(src).reduce(function(ret, key){
ret[key] = src[key];
return ret;
}, {});
var NM = function NativeModule(id) {
this.filename = id + '.js';
var locations = JSON.parse(body);
locations = _.first(locations, 10);
_.map(locations, function(loc) {
geocoder.geocode(loc.loc_address + ',' + loc.loc_city + ',' + loc.loc_state + ',' + loc.loc_zip, function(err, data) {
if (err)
errorHandler(err);
// console.log(data.results[0].geometry.location);
loc.location = data.results[0].geometry.location;
// done();
return loc;
@imbcmdth
imbcmdth / deepCopy.js
Created September 12, 2012 19:47
Robust deep copying of objects w/ support for cycles
var deepCopy = (function () {
var funcBlacklist = ['caller', 'arguments', 'prototype' ],
primitiveCloner = makeCloner(clonePrimitive),
cloneFunctions = {
'[object Null]': primitiveCloner,
'[object Undefined]': primitiveCloner,
'[object Number]': primitiveCloner,
'[object String]': primitiveCloner,
'[object Boolean]': primitiveCloner,
'[object RegExp]': makeCloner(cloneRegExp),
@imbcmdth
imbcmdth / gist:3881651
Created October 12, 2012 21:35
Javascript this quiz
// current scope is global..
function Test(n) {
this.test = n;
var bob = function (n) {
this.test = n;
};
this.fn = function (n) {
@imbcmdth
imbcmdth / gist:3922630
Created October 20, 2012 08:02
JAMMING!
> jm???in
Here's what I found:
[ 'jamming' ]
>