Skip to content

Instantly share code, notes, and snippets.

View benbahrenburg's full-sized avatar

Ben Bahrenburg benbahrenburg

View GitHub Profile
@benbahrenburg
benbahrenburg / gist:948579
Created April 29, 2011 16:32
Login Example
// 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});
@benbahrenburg
benbahrenburg / app.js
Created May 23, 2011 20:29
Ti.App issues
// 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');
},
@benbahrenburg
benbahrenburg / gist:1085149
Created July 15, 2011 17:47
Android XHR issue
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);
@benbahrenburg
benbahrenburg / app.js
Created July 24, 2011 23:57
Camera Callback
// 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 July 25, 2011 00:54
Saving XHR Results to a file
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 July 31, 2011 03:46 — forked from joemaffia/app.js
foursquare OAuth in Titanium
/**
*
*
* 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 August 6, 2011 14:15
Tell git to globally ignore .DS_Store
git config --global core.excludesfile ~/.gitignore
echo .DS_Store >> ~/.gitignore
@benbahrenburg
benbahrenburg / .gitignore
Created August 6, 2011 14:20
Git ignore file for a Titanium Build Directory
tmp
android/
iphone/
@benbahrenburg
benbahrenburg / gist:1130590
Created August 7, 2011 17:54
Query Stringify example based on the YUI plugin
//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 September 8, 2011 03:06
SphericalDistance Calculation
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,