Skip to content

Instantly share code, notes, and snippets.

@invernizzie
invernizzie / seamless-iframe.js
Created November 11, 2014 20:23
Cross-browser seamless iframe
// This script uses jQuery to resize an iframe to its content's height and
// the max of viewport width or content width.
// A selector for a container in the iframe with a given with (not <body>
// nor <html>) is required.
(function($) {
function getViewportWidth() {
return $(window).width();
}
@invernizzie
invernizzie / condition.js
Created March 28, 2013 05:05
Using RequireJS's shim configuration to sequentially load modules that determine define's dependencies.
define(function () {
return Math.random() >= 0.5;
});
@invernizzie
invernizzie / inherit.js
Last active December 16, 2015 02:09
Inheritance models that provides: - Use of the new operator. - Proper prototype chain and public methods attached to the prototype. - Private methods (through Function.prototype.call or Function.prototype.apply). - Class._super_ attribute to access base class' prototype (for calling super-methods easily).
var inherit = function (init) {
var base, ctor;
base = this;
ctor = function () {
if (typeof init === 'function') {
init.apply(this, arguments);
}
};
@invernizzie
invernizzie / ArtistsController.groovy
Created March 2, 2012 19:31 — forked from anonymous/ArtistsController.groovy
Test "featured should return all artists' info"
package com.fdvs.bandwdth
import grails.converters.JSON
import static java.net.HttpURLConnection.*
class ArtistController {
private static final String ERROR_MANDATORY_ID = 'Must receive artist id'
def facebookService
for (track in topTracks) {
if (videos.size() >= 10) break
// Hacer algo X
videos << trackVideo
}
def eachUntil = { collection, Closure condition, Closure closure ->
for (value in collection) {
if (condition()) break
closure(value)
}
}
topTracks?.eachUntil ({ video.size() >= 10 }, {trackName ->
// Hacer algo X
videos << trackVideo