Skip to content

Instantly share code, notes, and snippets.

View premasagar's full-sized avatar

Prem Rose premasagar

View GitHub Profile
var windowSearch = window.location.search,
devMode = /^\?dev[\W\/]?/.test(windowSearch);
cmd(
devMode ? 'jquery.js' : 'jquery.min.js'
);
<time datetime="2012-06-08" class="event-start-date">
<abbr title="June">JUN</abbr>
<span>8</span>
<span>2012</span>
</time>
.lanyrd-series-upcoming-conference time.event-start-date {
}
.lanyrd-series-upcoming-conference time.event-start-date abbr {
var arrayMethods = {};
Object.getOwnPropertyNames(Array.prototype).forEach(function(methodName){
arrayMethods[methodName] = Array.prototype[methodName];
});
function extend(target/*, any number of source objects*/){
var i = 1,
len = arguments.length,
withPrototype = arguments[len-1] === true,
obj, prop;
target || (target = {});
for (; i < len; i++){
obj = arguments[i];
if (typeof obj === 'object'){
function round(num, decimalplaces){
return Number(num.toFixed(decimalplaces));
}
function randomInt(length){
return Math.ceil((length || 2) * Math.random()) - 1;
}
function randomRange(min, max){
return Math.random() * (max - min) + min;
[{"conference":{"hash_tags":["#asyncjs"],"twitter_account":"@asyncjs","api_urls":{"conference":"http://lanyrd.asyncjs.com/2012/asyncjs-onecanvas-2/","speakers":"http://lanyrd.asyncjs.com/2012/asyncjs-onecanvas-2/speakers/","trackers":"http://lanyrd.asyncjs.com/2012/asyncjs-onecanvas-2/trackers/","attendees":"http://lanyrd.asyncjs.com/2012/asyncjs-onecanvas-2/attendees/","staff":"http://lanyrd.asyncjs.com/2012/asyncjs-onecanvas-2/staff/"},"name":"[Async]: One Canvas - part two","end_date":"2012-09-27","url":"http://asyncjs.com/onecanvas-2/","short_url":"http://lanyrd.comchpcp","topics":[{"web_url":"http://lanyrd.com/topics/art/","name":"Art","api_urls":{"topic":"http://lanyrd.asyncjs.com/topics/art/"}},{"web_url":"http://lanyrd.com/topics/hack-day/","name":"Hack Day","api_urls":{"topic":"http://lanyrd.asyncjs.com/topics/hack-day/"}},{"web_url":"http://lanyrd.com/topics/html5/","name":"HTML5","api_urls":{"topic":"http://lanyrd.asyncjs.com/topics/html5/"}},{"web_url":"http://lanyrd.com/topics/javascript/","name"
// e.g. scrollToTarget(document.getElementById('foo'));
function offset(target){
var left = 0,
top = 0;
while (target && target !== document.body){
if (target.offsetLeft){
left += target.offsetLeft;
top += target.offsetTop;
@premasagar
premasagar / fetch-all.sh
Created October 4, 2012 12:06
Create and pull all remote branches on a Git repository
#!/bin/bash
# http://stackoverflow.com/a/4754797/165716
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master`; do
git branch --track ${branch##*/} $branch
done
git pull --all
@premasagar
premasagar / speakers.md
Last active October 11, 2015 12:18 — forked from aron/speakers.txt
Async Show and Tell

[Async's][async] [2012 International Show n' Tell][event]

Thursday 8th November, 2012

☞ [Full info on the Async website][event]
✈ Sign up to attend [on the event's Lanyrd page][event-lanyrd].

Speakers gist

Would you like to speak on the night? you’ll have five minutes on the night to tell us about something… a project, a library, a technique, a story, or anything else about JavaScript, related tech (HTML, CSS, SVG, etc), or the wider world of web.

// Helper function to escape a string for HTML rendering
// from Tasket project
function escapeHTML(string) {
return string.replace(/&(?!\w+;)/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}