Skip to content

Instantly share code, notes, and snippets.

Avatar

Ben Bahrenburg benbahrenburg

View GitHub Profile
View gist:948579
// create tab group
demo.tabMainGroup = Ti.UI.createTabGroup({isOpen:false});
demo.tabLoginGroup = Ti.UI.createTabGroup({isOpen:false});
demo.wLogin = Ti.UI.createWindow({
id:'wLogin'
});
demo.tbLogin = Ti.UI.createTab({window:demo.wLogin});
View app.js
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
var tzt ={
testIt: function(){
alert('testIt');
},
isAndroid : function(){
return (Ti.Platform.osname == 'android');
},
View gist:1085149
bGet.addEventListener('click', function(){
var _url = "https://my.url.goes.here";
var username='demo';
var password='badpass';
var aToken = 'Basic ' + Ti.Utils.base64encode(username + ':' + password);
var c = Titanium.Network.createHTTPClient();
c.setTimeout(10000);
c.onload = function(e)
{
Ti.API.info("ONLOAD = "+e);
View app.js
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Ti.UI.setBackgroundColor('#000');
Ti.UI.iPhone.statusBarStyle = Ti.UI.iPhone.StatusBar.OPAQUE_BLACK;
//Create main app namespace
var demo={};
//Create a few helpers
demo.myHelpers = {
isAndroid : function(){
return (Ti.Platform.name == 'android');
},
@benbahrenburg
benbahrenburg / gist:1103324
Created Jul 25, 2011
Saving XHR Results to a file
View gist:1103324
var xhr = Titanium.Network.createHTTPClient();
xhr.onload = function()
{
var results = this.responseText;
Ti.API.info('Results from xhr Lookup = ' + results );
var supportDir = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,'my_support');
if(!supportDir.exists()){
supportDir.createDirectory();
}
@benbahrenburg
benbahrenburg / app.js
Created Jul 31, 2011 — forked from joemaffia/app.js
foursquare OAuth in Titanium
View app.js
/**
*
*
* Copyright 2011 Aaron K. Saunders, Clearly Innovative Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>
@benbahrenburg
benbahrenburg / gist:1129364
Created Aug 6, 2011
Tell git to globally ignore .DS_Store
View gist:1129364
git config --global core.excludesfile ~/.gitignore
echo .DS_Store >> ~/.gitignore
@benbahrenburg
benbahrenburg / .gitignore
Created Aug 6, 2011
Git ignore file for a Titanium Build Directory
View .gitignore
tmp
android/
iphone/
@benbahrenburg
benbahrenburg / gist:1130590
Created Aug 7, 2011
Query Stringify example based on the YUI plugin
View gist:1130590
//This snippet is based on the below:
//http://alloy.liferay.com/deploy/api/querystring-stringify-simple-debug.js.html
function queryStringify(obj, sep, eq) {
sep = sep || "&";
eq = eq || "=";
var qs = [], key, escape = encodeURIComponent;
for (key in obj){
if (obj.hasOwnProperty(key)) {
qs.push(escape(key) + eq + escape(String(obj[key])));
}
@benbahrenburg
benbahrenburg / gist:1202513
Created Sep 8, 2011
SphericalDistance Calculation
View gist:1202513
select abs(lat- 40.711389)+abs(lng- -74.064722)*0.643/case
when max(abs(lat- 40.711389),abs(lng- -74.064722)*0.643)/(min(abs(lat- 40.711389),abs(lng- -74.064722)*0.643)+0.000001) < 1.5 then 1.41
when max(abs(lat- 40.711389),abs(lng- -74.064722)*0.643)/(min(abs(lat- 40.711389),abs(lng- -74.064722)*0.643)+0.000001) < 2 then 1.34
when max(abs(lat- 40.711389),abs(lng- -74.064722)*0.643)/(min(abs(lat- 40.711389),abs(lng- -74.064722)*0.643)+0.000001) < 3 then 1.29
when max(abs(lat- 40.711389),abs(lng- -74.064722)*0.643)/(min(abs(lat- 40.711389),abs(lng- -74.064722)*0.643)+0.000001) < 5 then 1.18
when max(abs(lat- 40.711389),abs(lng- -74.064722)*0.643)/(min(abs(lat- 40.711389),abs(lng- -74.064722)*0.643)+0.000001) < 11 then 1.08
when max(abs(lat- 40.711389),abs(lng- -74.064722)*0.643)/(min(abs(lat- 40.711389),abs(lng- -74.064722)*0.643)+0.000001) < 25 then 1.04
else 1 end DISTANCE, AIRPORT_NAME,