Skip to content

Instantly share code, notes, and snippets.

Avatar

Marshall Culpepper marshall

View GitHub Profile
View lsusb_mac.py
#!/usr/bin/env python
# poor man's "lsusb -d" for Mac OS X
import argparse
import plistlib
import subprocess
import sys
devices = []
def add_device(item):
if '_items' in item:
View csvfind.c
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "csv.h"
char *city = "test";
int row_index = 0;
void data_callback(void *string, size_t i, void *data) {
@marshall
marshall / README.md
Last active Jan 3, 2016
A dirt simple CSV to sqlite db generator.
View README.md
@marshall
marshall / compare.js
Created Jan 8, 2013
Services.vc.compare for different version strings
View compare.js
Components.utils.import("resource://gre/modules/Services.jsm");
let versions = [
"1.0", "1.0.0", "1.0.0beta", "1.0.0.1", "1.0.20", "1.0.2.0", "1.1.0.1",
"1.1.0", "1.1.0alpha"
];
versions.sort(Services.vc.compare);
versions.reverse();
for (let i = 0; i < versions.length; i++) {
@marshall
marshall / activity1.js
Created Feb 22, 2011
Native Titanium + Android example code
View activity1.js
var activity = Ti.Android.currentActivity;
var win = Ti.UI.currentWindow;
activity.addEventListener("create", function(e) {
var button = Ti.UI.createButton({title: "Hello world"});
button.addEventListener("click", function(e) {
activity.finish();
});
win.add(button);
});
@marshall
marshall / force-update-check.sh
Created Sep 17, 2012
Force AUS update check
View force-update-check.sh
#!/bin/bash
DEVICE_TIME=$(date -j -f "%a %b %d %T %Z %Y" "`adb -d shell date`" "+%s" 2>/dev/null)
PROFILE_PREFS=$(adb -d shell cat '/data/b2g/mozilla/*.default/prefs.js')
PROFILE_DIR=$(adb -d shell ls -l /data/b2g/mozilla | grep .default)
PROFILE_REGEX="([^ ]+\.default)"
if [[ "$PROFILE_DIR" =~ $PROFILE_REGEX ]]; then
PROFILE_DIR=/data/b2g/mozilla/${BASH_REMATCH[1]}
else
@marshall
marshall / shell output
Created Sep 6, 2012
shell expansion fun
View shell output
# in each case the script sees $1 as the full value (with spaces, or quotes)
$ export ABC="a b c"
$ ./test.sh "ABC=$ABC"
=ABC=a b c=
$ export ABC="\"abc\""
$ ./test.sh "ABC=$ABC"
=ABC="abc"=
@marshall
marshall / smsIndicator.js
Created Jun 22, 2012
WebSmsIndicator example
View smsIndicator.js
// This example shows the WIP API in https://bugzilla.mozilla.org/show_bug.cgi?id=736710
// Note: mozSms access requires the URL to be in the dom.sms.whitelist
// I tested with the statusbar by adding the "sms" permission category to Gaia's system app in gaia/apps/system/manifest.webapp
var sms = window.navigator.mozSms;
sms.addEventListener("indicator", function onindicator(event) {
var indicator = event.message.indicator;
if (indicator.active) {
// show indicator
}
@marshall
marshall / networkSelectionModes.patch
Created Jun 18, 2012
networkSelectionModes.patch - v4
View networkSelectionModes.patch
# HG changeset patch
# User Marshall Culpepper <marshall@mozilla.com>
Bug 759637: Initial implementation of MobileConnection network selection APIs. r=philikon sr=sicking
diff --git a/dom/network/interfaces/nsIDOMMobileConnection.idl b/dom/network/interfaces/nsIDOMMobileConnection.idl
index 1df7131..ef434cd 100644
--- a/dom/network/interfaces/nsIDOMMobileConnection.idl
+++ b/dom/network/interfaces/nsIDOMMobileConnection.idl
@@ -31,17 +31,52 @@ interface nsIDOMMozMobileConnection : nsIDOMEventTarget
@marshall
marshall / test_mobile_networks.js
Created Jun 13, 2012
test_mobile_networks.js
View test_mobile_networks.js
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
// getNetworks() can take some time..
MARIONETTE_TIMEOUT = 60000;
const WHITELIST_PREF = "dom.mobileconnection.whitelist";
let uriPrePath = window.location.protocol + "//" + window.location.host;
SpecialPowers.setCharPref(WHITELIST_PREF, uriPrePath);