Skip to content

Instantly share code, notes, and snippets.

@rck109d
rck109d / survivor.js
Created May 12, 2015 16:25
keep only the given selector's children/self/parents on the page
var survivor = '#articleText';
$('*').not($(survivor).children().andSelf().parents().andSelf()).remove();
@rck109d
rck109d / giveUnderscore.js
Created May 12, 2015 16:23
give Underscore.js
var jqs = document.createElement('script');
jqs.type = 'text/javascript';
jqs.src = '//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js';
document.body.appendChild(jqs);
@rck109d
rck109d / giveMoment.js
Created May 12, 2015 16:22
give Moment.js
var jqs = document.createElement('script');
jqs.type = 'text/javascript';
jqs.src = '//cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js';
document.body.appendChild(jqs);
@rck109d
rck109d / giveJQuery.js
Created May 12, 2015 16:21
give jQuery
var jqs = document.createElement('script');
jqs.type = 'text/javascript';
jqs.src = '//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js';
document.body.appendChild(jqs);
@rck109d
rck109d / timeTaken.groovy
Created May 12, 2015 16:19
time taken human readable duration
import groovy.time.TimeCategory
import groovy.time.TimeDuration
long started = System.currentTimeMillis()
// TODO: CODE GOES HERE
long stopped = System.currentTimeMillis()
TimeDuration timeTaken = TimeCategory.minus(new Date(stopped-started), new Date(0))
println "timeTaken $timeTaken"