Skip to content

Instantly share code, notes, and snippets.

View autonome's full-sized avatar

Dietrich Ayala autonome

View GitHub Profile
<div id="myElement">asdfa</div>
<script>
var element = document.querySelector('#myElement')
element.addEventListener('dblclick', makeEditable, false)
function makeEditable(e) {
var editable = e.target,
input = document.createElement('input')
input.value = editable.textContent
Firefox OS News Reader
Software Requirements Document
(Draft 1, May 2014)
Christopher Behrens, Randal Holmes, Nhan Huynh,
Michael Kuvelas, Mike Messuri-Zhang, Jeremy Sample, Josh Willhite
if (navigator.mozSetMessageHandler) {
function NFCActivityHandler(activity) {
var text = activity.source.data.text;
if (!text) {
updateText('No text record')
}
else if (text.indexOf('bcm:') === 0) {
var email = text.substr(4)
registerRider(email)
updateText('Registered ' + email)
@autonome
autonome / gist:179afc6f9515a5008cb1
Created October 19, 2014 19:09
Query Selector Helpers
/*
Quick and easy conversion of nodelist to array.
You're on your own for error handling - invalid selectors throw an exception!
Example:
qsa['.fooble'].forEach(function(node) {
// do stuff
/chrome.manifest:
component {a5d89cee-85f4-44ad-b8eb-39ad39170823} components/helloworldapi.js
contract @mozilla.org/helloworld;1 {a5d89cee-85f4-44ad-b8eb-39ad39170823}
category JavaScript-navigator-property helloworld @mozilla.org/helloworld;1
/components/helloworldapi.js:
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
@autonome
autonome / webspeechwrapper.js
Last active August 29, 2015 14:14
Web Speech API utility
function say(phrase) {
speechSynthesis.speak(new SpeechSynthesisUtterance(phrase));
}
// words: array of strings
function addSpeech(words) {
var speechrecognitionlist = new SpeechGrammarList();
speechrecognitionlist.addFromString(
"#JSGF V1.0; grammar test; public <simple> = " +
words.join(' | ') + ' ;', 1);
@autonome
autonome / content-kit-template.md
Created March 17, 2015 22:15
Content Kit Template

Thing Content Kit

Current as of Thing 0.2.4

Introduction

  • One sentence description of thing and its purpose
  • Who/where/what/when/why
Verifying I am +dietrich on my passcard. https://onename.com/dietrich
/* Manifest snippets */
"type": "privileged",
"permissions": {
"alarms": {
"description": "Required to schedule alarms"
}
},
"messages": [
{ "alarm": "/index.html" }
twerkworker:gaia dietrich$ APP=keyboard make test-integration
rm -rf profile profile-debug profile-test profile-gaia-test-b2g profile-gaia-test-firefox profile-raptor profile-test /Users/dietrich/Dropbox/moz/gaia/build_stage docs minidumps
Test SDK directory: /Users/dietrich/Dropbox/moz/gaia/b2g_sdk/39.0a1-2015-03-05-16-02-02
test -f /Users/dietrich/Dropbox/moz/gaia/b2g_sdk/39.0a1-2015-03-05-16-02-02/B2G.app/Contents/MacOS/xpcshell
[rebuild] rebuildAppDirs: ["/Users/dietrich/Dropbox/moz/gaia/apps/bluetooth","/Users/dietrich/Dropbox/moz/gaia/apps/bookmark","/Users/dietrich/Dropbox/moz/gaia/apps/calendar","/Users/dietrich/Dropbox/moz/gaia/apps/callscreen","/Users/dietrich/Dropbox/moz/gaia/apps/camera","/Users/dietrich/Dropbox/moz/gaia/apps/clock","/Users/dietrich/Dropbox/moz/gaia/apps/collection","/Users/dietrich/Dropbox/moz/gaia/apps/communications","/Users/dietrich/Dropbox/moz/gaia/apps/costcontrol","/Users/dietrich/Dropbox/moz/gaia/apps/default_theme","/Users/dietrich/Dropbox/moz/gaia/apps/download","/Users/