Skip to content

Instantly share code, notes, and snippets.

View evanxd's full-sized avatar

Evan Tseng evanxd

View GitHub Profile
@evanxd
evanxd / output-expected-result.js
Created October 14, 2016 06:14
Output expected resut for readability.js
// Output expected resut for readability.js
require("fs").writeFileSync(__dirname + "/expected.html", result.content);
@evanxd
evanxd / proposal-of-iotjs.md
Last active May 2, 2019 01:38
Proposal of IoT.js

Proposal of IoT.js

[IoT.js][iotjs] is an open framework for building IoT applications quickly and easily. The goal is to fascilitate an open IoT ecosystem in which contributors will build components which will in turn be used in other components and applications. IoT.js and these components will be built using Open Web technologies and philosophies. The purpose of this document is to explain why I feel it is of great importance for Mozilla to invest their time and resources into this project.

IoT Is The Next Big Thing

It is common knowledge at this point that within the next 5-10 years, a very large percentage of consumer, comercial and industrial products will be IoT enabled. According to conservative estimates ([chart][iot-device-number-chart]) there will be [50.1 billions connected devices][iot-device-number] in the world by 2020.

Because of this, I strongly feel that the next frontier for Mozilla as a company will be to get involved with IoT so that it can become the standard bearer. At the moment

@evanxd
evanxd / citibank-creditcard-checker.js
Created July 3, 2016 08:17
Check Your Citi Bank Credit Card Bill
var sum = 0;
var i = 4;
var ele;
while(1) {
ele = document.querySelectorAll('#appLsTbl tbody tr')[i];
if (!ele) {
break;
}
sum += parseInt(ele.querySelectorAll('td')[3].innerHTML.replace(',', '').replace('.00', ''));
i += 2;
@evanxd
evanxd / chrome-api-proxy-sample.js
Last active August 29, 2015 14:25
Sample Code with Chrome API Proxy
var extensionId = 'abcdefghijklmnoabcdefhijklmnoabc';
var proxy = new ChromeApiProxy(extensionId);
proxy.call('chrome.serial.getDevices');
.then(function(devices) {
var device = devices.find(function(device) {
return device.displayName === 'Arduino Uno';
});
return proxy.call('chrome.serial.connect', device.path);
})
@evanxd
evanxd / design-blue-yeast.js
Last active August 29, 2015 14:23
Design BlueYeast
var Util = Bluetooth.Util;
var profile = [
{ alias: 'char1', service: 'uuid-s1', characteristic: 'uuid-c1' },
{ alias: 'char2', service: 'uuid-s2', characteristic: 'uuid-c1' },
{ alias: 'de1', service: 'uuid-s1', characteristic: 'uuid-c2', descriptor: 'uuid-d1' },
{ alias: 'de2', service: 'uuid-s1', characteristic: 'uuid-c2', descriptor: 'uuid-d2' }
];
var devices = Bluetooth.GATT.connect([
{ name: 'BT_DEVICE1', address: 'a0:21:3e:3d:e1:33', profile: profile },
{ name: 'BT_DEVICE2', address: 'a0:21:3e:3d:e1:34', profile: profile }
@evanxd
evanxd / audio_channel_controller.js
Created March 16, 2015 08:05
Audio Channel Controller
/* global BaseUI */
'use strict';
(function(exports) {
var AudioChannelController = function(app) {
this.app = app;
this.appId = app.instanceID;
this._audioChannels = new Map();
app.browser.element.allowedAudioChannels.forEach((channel) => {
channel.addEventListener('activestatechanged', this);
#!/bin/bash
# setup your mozilla-central REPO and github REMOTE.
# path to mozilla-central
REPO="mozilla-central"
# regualr expression for gaia github repo url
REMOTE="https:\/\/github\.com\/RickyChien\/gaia"
@evanxd
evanxd / audio-channel-competing.json
Last active August 29, 2015 14:12
Audio Channel Competing
# Audio Channel Name
# 1. Normal
# 2. Foreground Content
# 3. Background Content
# 4. Alarm
# 5. System
# 6. Ringer
# 7. Telphony
# 8. Notification
# 9. Public Notification
@evanxd
evanxd / audio-channel-manager.js
Last active August 29, 2015 14:09
Audio Channel Manager
/**
* Use audio channel manager in System app[1].
*
* AppWindowManager.prototype.handleEvent = function(evt) {
* switch (evt.type) {
* case 'appcreated':
* var app = evt.detail;
* this._apps[evt.detail.instanceID] = app;
* audioChannelManager.register(app.browser.element);
* break;
@evanxd
evanxd / proposal-of-audio-channel-managerment-api.md
Last active August 29, 2015 14:09
Proposal of Audio Channel Management API

Proposal of Audio Channel Management API v0.0.6

mozBrowser[1] API

Properties

  • mozBrowser.allowedAudioChannels: List of audio channels allowed to play. Implement this like DOMTokenList { 0: "class1", 1: "class2", 2: "class3", length: 3, add: function, remove: function, toggle: function, contains: function }[2].
  • mozBrowser.audioChannels['channelName'].volume: 0 to 1, set/get volumes of all allowed audio channels.
  • mozBrowser.audioChannels['channelName'].paused: boolean, true means pause the playing, false means allow the playing.
  • mozBrowser.activeAudioChannels: List of active audio channels.