Skip to content

Instantly share code, notes, and snippets.


Rakesh Pai rakeshpai

View GitHub Profile
rakeshpai / bitflipper.js
Created Jul 9, 2016
Code to randomly turn on or off an LED. With an extremely useful HTTP API. Uses Espruino, running on an ESP8266 (ESP-03).
View bitflipper.js
var wifi = require("Wifi"),
ledPin = D14,
buttonPin = D0,
ssid = "...",
password = "...";
var led = (function() {
var pulseIntervalHandle,
rakeshpai / gulpfile.js
Last active Oct 13, 2015
Browserify + Uglify + Espruino using Gulp
View gulpfile.js
var gulp = require("gulp"),
browserify = require("browserify"),
source = require("vinyl-source-stream"),
buffer = require("vinyl-buffer"),
uglify = require("gulp-uglify"),
through = require("through2"),
port = "/dev/cu.wchusbserial410",
espruino = require("node-espruino").espruino({comPort: port});
View primes.js
var primes = [2];
var n = 3; // The number we are testing. Will be incremented.
function checkNextNumber() {
// It's sufficient to check if there are any prime factors up to sqrt(n)
var limitForChecking = Math.floor(Math.sqrt(n));
rakeshpai / index.html
Created Feb 20, 2013
Opera .stack / .stacktrace madness
View index.html
<!doctype html>
<script src="stackgen.js"></script>
try {
} catch(e) {
ex = e;
throw e;
rakeshpai / foo.js
Created Jan 19, 2013
Code to replicate a potential bug with Firefox when using the crossorigin attribute on script tags. When using crossorigin="anonymous", if the server doesn't set access-control headers, Firefox doesn't evaluate the external script, even though it's downloaded. Thus, alert(foo) breaks with a ReferenceError if the server doesn't send the access-co…
View foo.js = 3;
rakeshpai / errorception-meta.html
Created Nov 23, 2012
Sending meta information to Errorception
View errorception-meta.html
_errs.meta = {
email: "",
sessionId: 4138727492,
lovesCats: true
rakeshpai / gist:4134122
Created Nov 23, 2012
Closure compiler optimizations
View gist:4134122
// Original
var getElementsByTagName = "getElementsByTagName";
var links = document[getElementsByTagName]("link"),
anchors = document[getElementsByTagName]("a"),
iframeContents = "...<script>var whatever = document." + getElementsByTagName + "('whatever');</script>...";
// becomes
rakeshpai / gist:2867569
Created Jun 4, 2012
Email by @Airtel_Presence
View gist:2867569
Dear Mr Pai,
Thank you for writing to airtel.
This is with reference to your e-mail dated 04th June 2012, wherein; you
highlighted your concern regarding website blocking for your airtel
account number 15793484.
We regret for the inconvenience caused to you.
rakeshpai / beacon.inlined.js
Created Apr 3, 2012
Trying out with contents inlined
View beacon.inlined.js
var _errs=["##EC##"];
(function(f,n){function r(d,a){d=d.contentWindow||d.contentDocument;d.document&&(d=d.document);;d.write(a);d.close()}function s(d,a){a=(""+a).replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&quot;");return"<input type='hidden' name='"+d+"' value='"+a+"' />"}function o(d){l&&clearTimeout(l);l=setTimeout(t,200);d._when=p;q.push(d);try{if("ot"==m){for(var a,h=d.callee,e=/function\s*([\w\-$]+)?\s*\(/i,c=[],b,k;h&&10>c.length;)b=e.test(h.toString())?RegExp.$1||"{anonymous}":"{anonymous}",||[]),c[c.length]=b+"("+i(k)+")",h=h.caller;a=c.join("\n");d._stack=a}}catch(g){}}function t(){var d=[],a,b,e,c,f=0,k,g=function(a,c){d.push(s(a+f,c))};try{for(;a=q.shift();){b=k=a.m||a[0]||a;e=a.u||a[1];c=a.l||a[2];if(!(k&&k instanceof Error)&&b&&"string"==typeof b&&e&&c&&("Error loading script"===b&&/Firefox/.test(navigator.userAgent)||/originalCreateNotification/.test(b)?f--:(g("type","onerr"),g("mes
rakeshpai / _errsAsAnApi.html
Created Jan 16, 2012
Errorception populating the queue before it's ready to flush
View _errsAsAnApi.html
var _errs = [];
window.onerror = function() { _errs.push(arguments); }
// <snip> Load our JS asynchronously, after page load, to process the _errs "queue"