Skip to content

Instantly share code, notes, and snippets.

@RudyLu
RudyLu / before_run_marionetteJs.sh
Last active August 29, 2015 14:01
script before running marionette js on travis
#extracted from .travis.yml
mkdir -p "$HOME"/.local/lib/python2.7/site-packages
export PATH="$HOME/.local/bin:$PATH"
export PYTHONPATH="$HOME"/.local/lib/python2.7/site-packages:"$PYTHONPATH"
# travis_retry make node_modules
export DISPLAY=:99.0
sh -e /etc/init.d/xvfb start
@RudyLu
RudyLu / js_inheritance
Created May 12, 2014 09:37
JS inheritance
var Class = function(parent){
var klass = function(){
this.init.apply(this, arguments);
};
// Change klass' prototype
if (parent) {
var subclass = function() { };
subclass.prototype = parent.prototype;
klass.prototype = new subclass;
@RudyLu
RudyLu / gist:33080411a9963722ea69
Last active August 29, 2015 14:00
Bring back the source view for app manager
// follow the same step in the following link to add pref,
// https://developer.mozilla.org/en-US/Firefox_OS/Using_the_App_Manager#Debugging_Certified_Apps_2
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1001348 for details.
echo 'user_pref("javascript.options.discardSystemSource", false);' >> prefs.js
// and this, if you want to debug certified app
echo 'user_pref("devtools.debugger.forbid-certified-apps", false);' >> prefs.js
Download file: https://pvtbuilds.mozilla.org/pvt/mozilla.org/b2gotoro/nightly/mozilla-central-hamachi-eng/latest/gaia.zip
WGET: -P /var/folders/g8/_gfsy_r14870m89nlsv677zh0000gn/T/autoflashfromPVT.XXXXXXXXXXXX.R3fETS5h https://pvtbuilds.mozilla.org/pvt/mozilla.org/b2gotoro/nightly/mozilla-central-hamachi-eng/latest/gaia.zip
--2013-11-28 10:53:48-- https://pvtbuilds.mozilla.org/pvt/mozilla.org/b2gotoro/nightly/mozilla-central-hamachi-eng/latest/gaia.zip
Resolving pvtbuilds.mozilla.org... 63.245.215.32
Connecting to pvtbuilds.mozilla.org|63.245.215.32|:443... connected.
HTTP request sent, awaiting response... 401 Authorization Required
Reusing existing connection to pvtbuilds.mozilla.org:443.
HTTP request sent, awaiting response... 200 OK
Length: 57629810 (55M) [application/zip]
Saving to: ‘/var/folders/g8/_gfsy_r14870m89nlsv677zh0000gn/T/autoflashfromPVT.XXXXXXXXXXXX.R3fETS5h/gaia.zip’
<html>
<audio src='sound/test.ogg' controls />
</html>
@RudyLu
RudyLu / facebook_strophe.html
Created May 24, 2013 04:58
The sample code of using Strophe.js to connect to facebook chat
<html>
<head>
<script src="http://connect.facebook.net/en_US/all.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="strophe-102.js" type="text/javascript"></script>
<script src="facebook.js" type="text/javascript"></script>
<script>
var BOSH_SERVICE = 'http://island.csie.org:8273/xmpp-httpbind'
var connection = null;
@RudyLu
RudyLu / value_selector.js.diff
Created October 9, 2012 08:49
Patch for 796740
diff --git a/apps/system/js/value_selector/value_selector.js b/apps/system/js/value_selector/value_selector.js
index 3d9012e..98d86d6 100644
--- a/apps/system/js/value_selector/value_selector.js
+++ b/apps/system/js/value_selector/value_selector.js
@@ -1,4 +1,4 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
+/* -*- Mode: js; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
'use strict';
@RudyLu
RudyLu / form.js.patch
Created July 27, 2012 22:05
form.js patch for <select> on Gaia
diff -r b5c4b792f3f2 b2g/chrome/content/forms.js
--- a/b2g/chrome/content/forms.js Mon Jul 30 17:20:58 2012 +0300
+++ b/b2g/chrome/content/forms.js Mon Jul 30 16:08:55 2012 -0700
@@ -61,6 +61,7 @@
content.setTimeout(function showIMEForSelect() {
sendAsyncMessage("Forms:Input", getJSON(evt.target));
});
+ this.previousTarget = evt.target;
} else if (evt.target instanceof HTMLOptionElement &&
evt.target.parentNode instanceof HTMLSelectElement) {
@RudyLu
RudyLu / keyboard.js
Created July 12, 2012 07:14
keyboard.js code for Gaia keyboard to work in firefox
/* -*- Mode: js; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
'use strict';
// Duplicated code in several places
// TODO Better settings observe interface?
if (!window.navigator.mozKeyboard) {