Skip to content

Instantly share code, notes, and snippets.

@jsantell
jsantell / worker-script.js
Created November 6, 2013 21:56
Testing string evals in worker threads
/* Worker Thread */
var x = 5;
var exec = 'self.port.emit("message", x);'
setTimeout(exec, 1)
/* Main Thread Test */
Worker({
contentScript: script,
onAttach: (worker) => {
worker.port.on('message', (val) => {
@jsantell
jsantell / mapping.json
Last active December 28, 2015 08:58
sample output of module dependency map generator
{
"./index.js": {
"./utils": "./utils/index.js",
"./dir/a": "./dir/a.js",
"./newmodule": "./newmodule/lib/file.js",
"./dir/b": "./dir/b.js",
"test-math": "./node_modules/test-math/index.js",
"test-custom-main": "./node_modules/test-custom-main/lib/custom-entry.js"
},
"./dir/b.js": {
@jsantell
jsantell / sdk-promise-consumers
Last active December 29, 2015 05:19
sdk/core/promise consumers
./b2g/chrome/content/dbg-browser-actors.js:sdk/core/promise
./browser/base/content/newtab/newTab.js:sdk/core/promise
./browser/base/content/sanitize.js:sdk/core/promise
./browser/base/content/test/general/browser_aboutHealthReport.js:sdk/core/promise
./browser/base/content/test/general/browser_aboutHome.js:sdk/core/promise
./browser/base/content/test/general/head.js:sdk/core/promise
./browser/base/content/test/social/head.js:sdk/core/promise
./browser/components/places/tests/browser/head.js:sdk/core/promise
./browser/devtools/app-manager/app-projects.js:sdk/core/promise
./browser/devtools/app-manager/app-validator.js:sdk/core/promise
# Fish 2.0 config
# Utility functions
function sser --description "Starts a SimpleHTTPServer in the current directory"
if [ (count $argv) = 0 ]
sser 8080
return
end
@jsantell
jsantell / declaritive-build.js
Created December 6, 2013 23:57
dreambuilder
var declare = {
// Transpile src stylus/sass and concatenate with vendor CSS into `dist/build.css`
'dist/build.css': ['vendor/**/*.css', 'style/*.styl', 'style/*.sass'],
// Transpile src coffeescript and concatenate with vendor JS into temporary pseudofile `$tmpjs.js`
'$tmpjs.js': ['vendor/**/*.js', 'src/*.coffee'],
// Compile handlebar templates into temporary pseudofile `$tmphbs.js`
'$tmphbs.js': 'templates/*.hbs',
// Concatenate our built JS and templates into `dist/build.js`
'dist/build.js': ['$tmpjs.js', '$tmphbs.js'],
// Also create a minified version
@jsantell
jsantell / workertab.js
Created December 11, 2013 21:22
worker.tab test
const pageMod = require("sdk/page-mod");
const tabs = require("sdk/tabs");
var mod = pageMod.PageMod({
include: "*",
contentScript: '(function () { console.log("attached") })();',
onAttach: function(worker) {
if (worker.tab)
console.log('HURRAY');
console.log(worker.tab);
function Type (props) {
for (prop in props)
if (props.hasOwnProperty(prop))
this[prop] = props[prop]
}
Type.prototype.getName = function () { return this.name; }
var data = {
name: "Ted",
// Doesn't work
subprocess({
file: 'C:\\Windows\\System32\\cmd.exe',
args: ['/s', '/c', '\"DIR /L\"']
})
// Works
subprocess({
file: 'C:\\Windows\\System32\\cmd.exe',
args: ['/s', '/c', '\"c:\\path\\to\\file.bat\"']
@jsantell
jsantell / jpm-command.sh
Created January 13, 2014 21:01
Using `jpm init` to automatically enable node packages, adding to the dependencies and overload routes set up for what `jetpack-node` supports, which is a suite of `jetpack-*` dependencies (`package.json`). User can also add their own custom dependencies and overloads (`package2.json`)
$ jpm init
JPM info Running init on undefined
title: (My Jetpack Addon)
name: (my-jetpack)
version: (0.0.0)
Enable node packages? (yes)
description:
entry point: (index.js)
author:
engines (comma separated): (firefox,fennec)
@jsantell
jsantell / message-bus.js
Last active June 8, 2016 04:22
message-bus.js
/*
* CONTENT THREAD
*/
let responses = new Map();
let listener = ({ id, response }) => {
let callback = responses.get(id);
if (callback) {
responses.delete(id);
callback(response);
}