Skip to content

Instantly share code, notes, and snippets.

View lisp-ceo's full-sized avatar
🎯
Focusing

James Meldrum lisp-ceo

🎯
Focusing
View GitHub Profile
@lisp-ceo
lisp-ceo / V8ArgumentEvalution
Created July 12, 2013 15:55
#Node.js IRC user asserted V8 evaluates the arguments global differently based on whether a function has default arguments specifed
function YoloSwaggins(){
console.log(arguments);
};
function BilboBaggins ( args ) {
console.log(arguments);
@lisp-ceo
lisp-ceo / gist:5985648
Last active December 19, 2015 16:39
Interesting quirks in the TypeScript compiler. Will invoke closures instead of vanilla functions.
(function (workers) {
var Waiter = (function () {
function Waiter(messageid, delegate) {
this.messageid = messageid;
this.delegate = delegate;
}
return Waiter;
})();
workers.Waiter = Waiter;
})(appex.workers || (appex.workers = {}));
// Lessons in order of operations behaviour in JS
this.get( 'bottlings' ).getRequiredUpdates() + (this._requiresUpdate() ) ? 1 : 0;
this.get( 'bottlings' ).getRequiredUpdates() + ((this._requiresUpdate() ) ? 1 : 0);
@lisp-ceo
lisp-ceo / underscore_objec_deep_copy
Created July 31, 2013 21:43
Underscore's extend does not recursively copy child dependencies. This sucks if you want to create a deep copy of an object. This functionality doesn't exist.
var _ = require( 'underscore');
var obj1 = {
item : {
yolo : {
swag : {
trill : true
}
}
}
@lisp-ceo
lisp-ceo / underscore_objec_deep_copy
Last active December 20, 2015 11:49
Underscore's extend does not recursively copy child dependencies. This sucks if you want to create a deep copy of an object. This functionality doesn't exist.
var _ = require( 'underscore');
var obj1 = {
item : {
yolo : {
swag : {
trill : true
}
}
}
@lisp-ceo
lisp-ceo / BackboneSyncSempahores
Created August 9, 2013 16:00
Backbone.Model.fetch does not support the silencing of sync events. Further, ES5 lacks generator expressions, as such semaphore implementations require some hacks. Semaphores are useful in this context as populating a model with data from multiple sources is a model operation.
var Yolo = Backbone.Model.extend({
sweetMethods : function...
...
sem : {
requiredSyncs : 2,
syncedSyncs : 0
},
@lisp-ceo
lisp-ceo / JSBootstrap.js
Created August 27, 2013 18:28
Small-scale web applications often need a good bootstrap for JavaScript. Here's a light-weight bootstrapping script for AOP/Event-driven apps
/**
*
* Site-Wide JavaScript - application-specific
*
* @author James Meldrum
*
* The functionality for each page type is stored
* in a hash of functions to be called by the router.
*
* Frequent use of AOP
@lisp-ceo
lisp-ceo / WritingJSONToHTML.html
Created August 29, 2013 15:45
Writing blocks of JSON to a document can be a good way to save a DB call. The script block increases the size of the document but it means JavaScript functions can proceed from the DOMContent event, not the Load. Here is some pseudo HTML for how you can access it from your file.
<html>
<head>
<script type='text/javascript'>
window.wineData = {
..
};
</script>
</head>
<body>
<script type='text/javascript'>
@lisp-ceo
lisp-ceo / gist:6638500
Created September 20, 2013 14:32
Instantiating new classes over HTTP
(function f(a,o){o=o.__proto__;return o?f(a.concat(http://o.constructor.name ),o):a})([],document.body)
@lisp-ceo
lisp-ceo / grunt-contrib-concat.js
Created October 6, 2013 18:47
14:36 < Leon> I'm looking at running concat on all js in a Symfony2 bundle. And it would be nice to be able to group them by the bundle name 14:37 -!- thealphanerd [~thealphan@pdpc/supporter/student/thealphanerd] has joined #grunt 14:38 < b3tamax> Leon: grunt-contrib-concat? 14:40 < Leon> Yes that's what I'm trying to use, the question is how do…
concat : {
AppBundle : {
src : [],
dest : ""
},
AdminBundle : {
src : [],
dest : ""
},
CommonBundle : {