Skip to content

Instantly share code, notes, and snippets.

View premasagar's full-sized avatar

Prem Rose premasagar

View GitHub Profile
@premasagar
premasagar / tim-lite-cached-min.js
Created March 18, 2011 05:53
Tim (lite, cached), renamed to timLiteCached, for including in perf tests at http://jsperf.com/dom-vs-innerhtml-based-templating/111
var timLiteCached=function(){function i(b,e){return b.replace(m,function(g,c){for(var j=c.split("."),k=j.length,h=e,f=0;f<k;f++){h=h[j[f]];if(f===k-1)return h}})}var m=RegExp("{{\\s*([a-z0-9_][\\.a-z0-9_]*)\\s*}}","gi"),d={},l=window.JSON;return l?function(b,e){var g=l.stringify(e),c=d[b]&&d[b][g];if(c)return c;d[b]||(d[b]={});return c=d[b][g]=i(b,e)}:i}();
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl http://npmjs.org/install.sh | sh
@premasagar
premasagar / jsonpx.html
Created June 29, 2011 17:43
Wrap random content (e.g. HTML source code) in a JSONP-transportable JavaScript string
<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>jsonpx-ify</title>
<script src=jquery.js></script>
<script src=jsonpx.js></script>
<style>
label, textarea, input, button {
@premasagar
premasagar / blur.html
Created July 1, 2011 13:28
SVG blur filter
<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>SVG Blur</title>
</head>
<body>
<h1>SVG filters: blurring</h1>
@premasagar
premasagar / ufo.js
Created September 12, 2011 09:49 — forked from jimpurbrick/ufo.js
An alien abductor for the asyncjs.com JavaScript Jungle.
jj.createCreature("ufo", function (creature) {
"use strict";
var captured = {},
positionFactor = 0.005,
$ = jj.jQuery,
SEARCH = 1,
CHASE = 2,
CAPTURE = 3,
RETURN = 4,
@premasagar
premasagar / hasSearchParam.js
Created September 12, 2011 10:10
Detect search parameter in window location
function hasSearchParam(param, value){
var pattern = "^[\?&]" + param +
(typeof value === "undefined" ? "($|[=&])" : "=" + value + "($|&)");
return (new RegExp(pattern)).test(window.location.search);
}
// e.g. hasSearchParam("debug") on http://example.com?debug
// e.g. hasSearchParam("foo", "bar") on http://example.com?foo=bar
@premasagar
premasagar / animLoopX.js
Created September 24, 2011 00:47 — forked from louisremi/animLoopX.js
Animation loop with requestAnimationFrame
// Cross browser, backward compatible solution
(function( window, Date ) {
// feature testing
var raf = window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.msRequestAnimationFrame ||
window.oRequestAnimationFrame;
window.animLoop = function( render, element ) {
var running, lastFrame = +new Date;
[{"conference":{"hash_tags":["#asyncjs"],"twitter_account":"@asyncjs","api_urls":{"conference":"http://lanyrd.asyncjs.com/2012/asyncjs-kirin/"},"name":"[Async]: Introducing Kirin, a new mobile platform","end_date":"2012-02-23","url":"http://asyncjs.com/kirin/","short_url":"http://lanyrd.com/cgdgz","dates":"23rd February 2012","online_conference":false,"schedule_url":"","web_url":"http://lanyrd.com/2012/asyncjs-kirin/","place":{"name":"Brighton","woeid":"13911","place_type":"Town","web_url":"http://lanyrd.com/places/brighton/","slug":"brighton","api_url":"http://lanyrd.asyncjs.com/places/brighton/"},"start_date":"2012-02-23","tagline":"","slug":"asyncjs-kirin"},"attendees":[{"user":{"username":"ac94","name":"Aron","avatar_url":"http://a1.twimg.com/profile_images/750527058/tape_normal.png","twitter_id":"11131532","web_url":"http://lanyrd.com/people/ac94/","api_urls":{"user":"http://lanyrd.asyncjs.com/people/ac94/"}}},{"user":{"username":"premasagar","name":"Premasagar Rose","avatar_url":"http://a0.twimg.com/pro
@premasagar
premasagar / gist:2659105
Created May 11, 2012 11:30 — forked from almost/gist:2659046
index.js that auto-loads other modules in same directory
var fs = require('fs'), path = require('path');
// Load all exported objects into a single module.
fs.readdirSync(__dirname).forEach(function (filename) {
var fullpath = path.join(__dirname, filename), resource,
module;
if (fullpath !== __filename && 'js' === fullpath.split('.').pop() && '.' !== fullpath[0]) {
module = require(fullpath);
exports[filename.split('.')[0]] = module;
@premasagar
premasagar / octocat.svg
Created May 29, 2012 20:54 — forked from milligramme/octocat.svg
Github octocat avatar, SVG format
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.