Skip to content

Instantly share code, notes, and snippets.

Anant Narayanan anantn

Block or report user

Report or block anantn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
anantn / owa_receipt.js
Created Feb 18, 2012
How to verify a Mozilla Apps receipt
View owa_receipt.js
function doVerifyReceipt(cb, options) {
navigator.mozApps.getSelf(function(app) {
var record = app.receipt;
if (!record) {
cb({"error": "Application not installed"});
if (typeof cb !== "function") {
throw "Callback not provided in doVerifyReceipt";
anantn / gist:2871209
Created Jun 4, 2012
Add popup blocking to android getUserMedia({picture})
View gist:2871209
diff --git a/content/media/MediaEngineDefault.cpp b/content/media/MediaEngineDefault.cpp
--- a/content/media/MediaEngineDefault.cpp
+++ b/content/media/MediaEngineDefault.cpp
@@ -1,13 +1,19 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at */
#include "MediaEngineDefault.h"
+#include "nsDOMFile.h"
anantn / gUM_hack.html
Created Jul 12, 2012
Example getUserMedia Usage
View gUM_hack.html
<!DOCTYPE html public "✰">
<meta charset="utf-8">
<title>getUserMedia Video Example</title>
<button type="button" onclick="toggle()">
Toggle Video
anantn / pc_xpcshell_test.js
Created Jul 27, 2012
PeerConnection in XPCShell
View pc_xpcshell_test.js
const Cc = Components.classes;
const Ci = Components.interfaces;
let gScriptDone = false;
View xpcom_file_io.js
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
// Let's enumerate all available files in ~
function getHomeDir() {
let home = Cc[";1"].createInstance(Ci.nsILocalFile);
if (!home.isDirectory()) {
alert("that seems wrong...");
anantn / getUserMediaDevices.html
Created Sep 18, 2012
navigator.mozGetUserMediaDevices Example
View getUserMediaDevices.html
<h1>Device Test</h1>
<ul id="contents">
<video id="tehvideo"/>
<audio id="tehaudio"/>
var devices;
var nav = navigator.QueryInterface(Components.interfaces.nsINavigatorUserMedia);
anantn / tamejs_gum.js
Created Oct 18, 2012
TameJS wrapper for getUserMedia
View tamejs_gum.js
function myGetUserMedia(constraints, cb)
function errCb(code)
cb(code, null);
function successCb(stream)
anantn / firebase_queue_pop.js
Last active Dec 10, 2015
Firebase: Using .push() to maintain a queue and ensuring only one client is able to obtain the head of the queue at a time.
View firebase_queue_pop.js
var Firebase = require("./firebase-node.js");
function Queue(ref) {
this._ref = ref;
Queue.prototype.pop = function(cb) {
this._ref.startAt().limit(1).once("child_added", this._pop.bind(this, cb));
anantn / firefox_ext_iframe.js
Created Jan 1, 2013
Creating an iframe in Firefox extension code
View firefox_ext_iframe.js
if (Components && Components.classes) {
// This means we are in a Firefox extension.
var appShell = Components.classes[";1"]
// hiddenDoc will now point to a regular DOM document.
var hiddenDoc = appShell.hiddenDOMWindow.document;
// Create an iframe.
let iframe = hiddenDoc.createElementNS("", "iframe");
anantn / backfire.diff
Created Jan 11, 2013
Changes to needed to make TODOmvc real-time with Firebase <-> Backbone
View backfire.diff
--- ../backbone/examples/todos/todos.js 2013-01-08 17:02:02.000000000 -0800
+++ todos.js 2013-01-10 17:33:56.000000000 -0800
@@ -1,7 +1,6 @@
// An example Backbone application contributed by
// [Jérôme Gravel-Niquet]( This demo uses a simple
-// [LocalStorage adapter](backbone-localstorage.html)
-// to persist Backbone models within your browser.
+// Firebase adapter to persist Backbone models.
// Load the application once the DOM is ready, using `jQuery.ready`:
You can’t perform that action at this time.