Skip to content

Instantly share code, notes, and snippets.

View nickdesaulniers's full-sized avatar

Nick Desaulniers nickdesaulniers

View GitHub Profile
@arcturus
arcturus / crossdomainrequest.js
Created December 28, 2012 20:34
How to do a cross domain request in Firefox OS
/*
YOU'LL BE ABLE TO PERFORM A CROSS DOMAIN REQUEST IF YOUR APP IS CERTIFIED OR PRIVILEDGED.
FOR MORE INFO CHECK THE PERMISSIONS MATRIX: https://docs.google.com/spreadsheet/ccc?key=0Akyz_Bqjgf5pdENVekxYRjBTX0dCXzItMnRyUU1RQ0E#gid=0
First you'll need to setup the permission for doing the cross domain request on your application manifest.
Go to your app manifest, to the permissions section and add the following:
"systemXHR": {}
@potch
potch / urlparse.js
Created February 1, 2013 22:57
Hey everyone we solved URL parsing in JavaScript!
var urlparse = (function() {
var a = document.createElement('a');
// urlparse('https://example.com:8080/bar.html?baz#yay')
return function(url) {
a.href = url;
return {
hash: a.hash, // '#yay'
host: a.host, // 'example.com:8080'
hostname: a.hostname, // 'example.com'
if ('MozActivity' in window) { // feature detection
// When getting elements, like document.getElementsByClassName('video-links')
// rather use event delegation, like
// `jQuery(document).on('click', 'video', fn)
document.getElementById('video-1').onclick = function(evt) {
evt.preventDefault(); // Prevent click behaviour
console.log("Launching Video!");
var activity = new MozActivity({
@janjongboom
janjongboom / gist:5500846
Created May 2, 2013 08:08
Flashing a GeeksPhone with a newer version of Firefox OS

Here are instructions on how to flash your Geeksphone.

Prerequisites

  1. First of all you'll need to have adb and fastboot, these are included in the Android SDK
  2. If your phone can be turned on, enable 'Remote debugging' (in Settings -> Device Information -> More information -> Debugging)
    • Now see if your device is listed when you type adb devices in the terminal
    • If so: run adb reboot bootloader
  3. If your phone is bricked, load into bootloader by pressing power and volume up
  • Verify that the phone is listed when running fastboot devices
@ryanseys
ryanseys / .git_config
Last active December 17, 2015 04:18
Sync master & gh-pages by adding these 2 lines in your .git/config file
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git@github.com:user/repo.git
# add the following 2 lines so $ git push pushes to both master & gh-pages
push = +refs/heads/master:refs/heads/gh-pages
push = +refs/heads/master:refs/heads/master
@digitarald
digitarald / language-detect.js
Last active December 17, 2015 04:19
Detect language changes when switching to app. I personally recommend setting current language only on app launch. Reacting to changes later benefits only a small set of users, focus on the 99%!
// Example code, use with caution!
// Events and .hidden property requires no prefix since 18
// Set current language on launch
document.documentElement.lang = navigator.language;
function visibilityChange() {
// user went off page, ignore
if (document.hidden) return;
@digitarald
digitarald / 1-moz-mobile-connection-snippet.js
Last active December 18, 2015 03:19
Detect carrier and region from `mozMobileConnection`'s `MNC` and `MCC`
// Original https://github.com/mozilla/fireplace/blob/c50b5ca51643f13ae2e8b3a003d3aa0432358bf7/hearth/media/js/user.js#L41
// Retrieve MCC and MNC from mozMobileConnection (requires "privileged" app type and "mobileconnection" permission)
// and translates them to carrier and region via mobilenetwork.js
try {
// When Fireplace is served as a privileged packaged app (and not
// served via Yulelog) our JS will have direct access to this API.
var conn = navigator.mozMobileConnection;
if (conn) {
@louisstow
louisstow / external.js
Last active December 19, 2015 04:29
Force external links to open in a new browser window on Firefox OS
if (navigator.mozApps && window.locationbar.visible === false) {
var externalLinks = document.querySelectorAll("a[href^='http']:not([href*='"+location.host+"'])");
for (var i = 0; i < externalLinks.length; ++i) {
externalLinks[i].setAttribute("target", "_blank");
}
}
@vuldin
vuldin / default.prop
Last active December 22, 2015 18:29
Install latest dev build of FxOS on ZTE Open
ro.secure=0
ro.allow.mock.location=1
ro.debuggable=1
persist.usb.serialno=full_inari
persist.sys.usb.config=adb
@digitarald
digitarald / detectByConnection.js
Created December 6, 2013 18:21
Using mozMobileConnections with MNC and MCC to enable app features for specific country/carrier combinations
var mccs = [];
try {
// navigator.mozMobileConnections is the new API.
// navigator.mozMobileConnection is the legacy API.
var conn;
if ((conn = navigator.mozMobileConnection)) {
console.log('navigator.mozMobileConnection available');
// `MCC`: Mobile Country Code