Skip to content

Instantly share code, notes, and snippets.

Avatar

Prem Rose premasagar

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

[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 Dec 16, 2015
Async Show and Tell
View async-speakers.md

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

View escapehtml.js
// 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 Oct 11, 2015 — forked from aron/speakers.txt
Async Show and Tell
View speakers.md

[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 Oct 4, 2012
Create and pull all remote branches on a Git repository
View fetch-all.sh
#!/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
View scroll-to-target.js
// 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;
View asyncjs-conferences.json
[{"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"
View numbers.js
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;