Skip to content

Instantly share code, notes, and snippets.

function instantiate(Type, locals) {
var Constructor = function() {},
instance, returnedValue;
// Check if Type is annotated and use just the given function at n-1 as parameter
// e.g. someModule.factory('greeter', ['$window', function(renamed$window) {}]);
Constructor.prototype = (isArray(Type) ? Type[Type.length - 1] : Type).prototype;
instance = new Constructor();
returnedValue = invoke(Type, instance, locals);
@lukaszewczak
lukaszewczak / decodeHtml
Created April 30, 2014 12:34
Decodes HTML entities
// Decodes HTML entities in a browser-friendly way
// See http://stackoverflow.com/questions/1912501/\
// unescape-html-entities-in-javascript
// convert browser entities like & into a displayed character like &.
decodeHtml = function ( str ) {
return $('<div/>').html(str || '').text();
};
@lukaszewczak
lukaszewczak / gist:11229871
Created April 23, 2014 19:50
bower - exit code of #128
git config --global url."https://".insteadOf git://
Reference: https://github.com/bower/bower/issues/50
@lukaszewczak
lukaszewczak / image_load
Last active August 29, 2015 14:00
Add the class bigImg to all images with height greater than 100 upon each image load
$( "img.userIcon" ).load(function() {
if ( $( this ).height() > 100) {
$( this ).addClass( "bigImg" );
}
});