Skip to content

Instantly share code, notes, and snippets.

@jsantell
jsantell / proxyServer
Created July 2, 2012 13:28 — forked from randylubin/proxyServer
Node.js Multi-App Proxy Server with Forwarding
var http = require('http'),
httpProxy = require('http-proxy');
//
// Setup proxy server with forwarding
//
var options = {
router: {
'proxytest.randylubin.com': '127.0.0.1:7200',
'randylubin.com': '127.0.0.1:7200',
@jsantell
jsantell / safariWebAudioBug.html
Created August 5, 2012 15:16
Web Audio API, proc audio / media element source Safari bug
<!DOCTYPE html>
<html>
<head>
<title>Web Audio API Test</title>
<style>#data{ color: #ff0077; font-weight: bold;}</style>
</head>
<body>
<h1>Processing audio from Media Element Source</h1>
<h2>Works in Chrome, fails in Safari</h2>
<audio controls="controls">
exports[key] = value for key, value of {
run : run
document : document
parse : parse
resolveSource : resolveSource
version : version
defaults : defaults
languages : languages
}
<!doctype html>
<script>
function pause() {
console.log('pause')
node.disconnect()
}
function play() {
console.log('play');
@jsantell
jsantell / methodspy.js
Created October 31, 2012 20:44
Method Spy
// Where native object is something like AudioContext, localStorage, XMLHttpRequest, etc..
var
nObject = window.someNativeObject,
originalMethod = nObject.method;
nObject.method = function () {
// Do other things here, like track arguments
originalMethod.apply( nObject, arguments );
}
@jsantell
jsantell / curry.js
Created November 21, 2012 21:08
currying
var curry = require( 'curry' );
var newFn = curry( [1,2,3], fn );
newFn( 4 );
function fn () {
Array.prototype.slice.call( arguments ).forEach(function (x) {
console.log( x );
});
// outputs 1, 2, 3, 4
}
@jsantell
jsantell / page-mod-bfcache.js
Created March 27, 2013 17:17
Jetpack page-mod/bfcache
/*
* testing page-mod's persistence with bfcache
*/
require('sdk/page-mod').PageMod({
include: '*',
contentScript: 'new ' + fn
});
// Content script
@jsantell
jsantell / bookmarks.js
Created April 3, 2013 21:18
Example usage of Places API
const { Bookmarks } = require('sdk/places/bookmarks');
const { all } = require('sdk/core/promise');
const { each } = require('sdk/util/array');
var data = [
{
url: 'http://www.mozilla.org',
title: 'Mozilla Org Homepage'},
{
url: 'http://bugzilla.mozilla.org',
const { Cc, Ci, Cu } = require('chrome');
const FaviconService = Cc["@mozilla.org/browser/favicon-service;1"].
getService(Ci.nsIFaviconService);
const IO = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
const asyncFavicons = FaviconService.QueryInterface(Ci.mozIAsyncFavicons);
let url = IO.newURI('http://www.mozilla.org', null, null);
// PRINT: URI: null len: 0 data: type:
asyncFavicons.getFaviconDataForPage(url, function (aURI, aDataLen, aData, aMimeType) {
let { events } = require('sdk/content/events');
let { on, emit, off, setListeners } = require('sdk/event/core');
let { filter, pipe, map } = require('sdk/event/utils');
let { create } = require('sdk/frame/utils');
let { window } = require('sdk/addon/window');
let view = create(window.document, {
nodeName: 'iframe',
type: 'content',
uri: 'http://mozilla.org',