Skip to content

Instantly share code, notes, and snippets.

View premasagar's full-sized avatar

Prem Rose premasagar

View GitHub Profile
@premasagar
premasagar / strictify.sh
Last active August 29, 2015 14:27
prepend "use strict"
FILE=path/to/file.js && echo '"use strict";\n' | cat - $FILE > /tmp/out && mv /tmp/out $FILE
Pablo.load('example.svg', function(){
this.children().each(function(el){
console.log(el.nodeName, Pablo(el).attr());
});
})
@premasagar
premasagar / speakers.md
Last active December 21, 2015 07:09
Async Show and Tell speaker's list

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

Thursday 7th November, 2013

☞ [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 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.

@premasagar
premasagar / async-speakers.md
Last active December 16, 2015 20:09
Async Show and Tell

[Async's][async] [3rd Birthday Show n' Tell][event]

Thursday 23rd May, 2013

☞ [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, that’s 300 seconds, to tell us about something… a project, a library, a technique, a story, or anything else on JavaScript and its techy friends (HTML, CSS, SVG, animated GIFs), 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;');
}
@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.

@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
// 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;
[{"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"
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;