Skip to content

Instantly share code, notes, and snippets.

View adampax's full-sized avatar
🏠
Working from home

Adam Paxton adampax

🏠
Working from home
View GitHub Profile
@adampax
adampax / app.js
Created August 30, 2011 20:00 — forked from kwhinnery/app.js
var os = require('os').os;
//branch logic based on platform - saves you an if statement
os(function() {
alert('do this on android');
}, function() {
alert('do this on iOS');
});
var platformSpecificValue = os('android string','ios string');
@adampax
adampax / app.js
Created September 1, 2011 22:15 — forked from skypanther/app.js
Draw gridlines in a Titanium window
// implement like this:
var window = Ti.UI.createWindow({
backgroundColor:'#fff'
});
// draw the gridlines first so your other elements stack on top of them
// without requiring you to set the z-index property of each
var grid = require('gridlines');
grid.drawgrid(10,window);
@adampax
adampax / app.js
Created September 7, 2011 14:52 — forked from dawsontoth/app.js
Generate QR Codes in Titanium Mobile
/**
* Creates an image view using Google's QR Code generator.
* @param text The text to be encoded in the QR code
* @param size The size of the QR code; Possible Sizes: 100x100, 150x150, 200x200, 250x250, 300x300, 350x350, 400x400, 500x500
*/
function createQRCodeImageView(text, size) {
var url = 'http://chart.apis.google.com/chart?cht=qr&chs=' + size + '&chl=' + encodeURI(text) + '&chld=H|0';
var width = size.split('x')[0], height = size.split('x')[1];
if (Ti.Android) {
width += 'dp';
@adampax
adampax / uri.js
Created April 21, 2012 14:22 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.host; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"