Skip to content

Instantly share code, notes, and snippets.

@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" );
}
});
@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 / 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();
};
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);
function invoke(fn, self, locals){
var args = [],
$inject = annotate(fn),
length, i,
key;
....
return fn.apply(self, args);
function factory(name, factoryFn) { return provider(name, { $get: factoryFn }); }
function service(name, constructor) {
return factory(name, ['$injector', function($injector) {
return $injector.instantiate(constructor);
}]);
}
(function () {
'use strict';
angular
.module('import')
.service('DataService', DataService);
DataService.$inject = ['$http'];
function SomeService () {
this.someMethod = function () {
};
}
angular
function AnotherService () {
var AnotherService = {};
AnotherService.someValue = '';
AnotherService.someMethod = function () {
};
return AnotherService;
}
npm -g install weinre