NOTE: 534 stars, 106 forks. I love you all. Please contribute tips and edits back to this cheat sheet -- email's will.sargent@gmail.com and you can treat gists like git repositories and send git diffs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(function () { | |
return Math.random() >= 0.5; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var inherit = function (init) { | |
var base, ctor; | |
base = this; | |
ctor = function () { | |
if (typeof init === 'function') { | |
init.apply(this, arguments); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (track in topTracks) { | |
if (videos.size() >= 10) break | |
// Hacer algo X | |
videos << trackVideo | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |