Skip to content

Instantly share code, notes, and snippets.

@deleteme
deleteme / poll.coffee
Created April 21, 2014 18:54
poll.coffee
# Periodically call the condition promise, resolves when the condition resolves
poll = (condition, interval=1000, timeout=60000)->
promise = Q.promise (resolve, reject)->
start = _.now()
test = ->
_duration = _.now() - start
if _duration > timeout
reject "Polling timeout of #{ timeout }ms exceeded."
else
Q.fcall(condition).then resolve
// define ds, which adds to a queue
// must be included in <head>, before anything else.
function ds(){
(ds.q = ds.q || []).push(arguments);
return ds;
}
// process queue, included at the end of vendored js
function run(args){
var module = args[0]();
var ids = $('.thumbs').map(function(){
var $thumb = $(this);
return $thumb.data('release_id');
});
$.ajax(yourOptionsIncludingIds)
// Media Queries in Sass 3.2
//
// These mixins make media queries a breeze with Sass.
// The media queries from mobile up until desktop all
// trigger at different points along the way
//
// And important point to remember is that and width
// over the portrait width is considered to be part of the
// landscape width. This allows us to capture widths of devices
// that might not fit the dimensions exactly. This means the break
alert('not secure');
@deleteme
deleteme / unique strings.js
Created December 4, 2012 19:25
unique new york
function unique(array){
var unique = [];
for (var i = 0, l = array.length; i < l; i++){
if (unique.indexOf(array[i]) === -1)
unique.push(array[i]);
}
return unique;
}
@deleteme
deleteme / gist:4162194
Created November 28, 2012 16:02 — forked from madrobby/gist:4161897
Retina screen media query
@media (min--moz-device-pixel-ratio: 1.5),
(-o-min-device-pixel-ratio: 3/2),
(-webkit-min-device-pixel-ratio: 1.5),
(min-device-pixel-ratio: 1.5),
(min-resolution: 144dpi),
(min-resolution: 1.5dppx) {
/* Retina rules! */
}
{
"my_custom_field_data": { "omg": "bar" }
}
window.exports={};
window.imported={};
// synchronous require for CommonJS
function require(name){
if (!window.imported[name]){
var xhrObj = createXMLHTTPObject();
// open and send a synchronous request
xhrObj.open('GET', name + ".js", false);
xhrObj.send('');
var test = 'test!';