Skip to content

Instantly share code, notes, and snippets.

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

Gustavo Rodriguez Baldera gbaldera

🏠
Working from home
View GitHub Profile
@gbaldera
gbaldera / app.js
Created December 27, 2011 20:39 — forked from pec1985/app.js
Android quick dashboard view
var win = Ti.UI.createWindow({});
win.open();
var height = Ti.Platform.displayCaps.platformHeight-40;
var width = Ti.Platform.displayCaps.platformWidth;
var viewsArray = [];
@gbaldera
gbaldera / app.js
Created December 27, 2011 20:57 — forked from pec1985/app.js
Cache Remote Images
var Utils = {
RemoteImage: function(a){
a = a || {};
var md5;
var needsToSave = false;
var savedFile;
if(a.image){
md5 = Ti.Utils.md5HexDigest(a.image)+'.jpg';
savedFile = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,md5);
if(savedFile.exists()){
@gbaldera
gbaldera / app.js
Created April 14, 2012 12:25 — forked from pec1985/app.js
GetLocation
function GetLocation(callback){
if (!Ti.Network.online)
{
callback({success: false});
return;
}
var PROVIDER = Titanium.Geolocation.PROVIDER_GPS;
var timeout;
@gbaldera
gbaldera / gist:2415483
Created April 18, 2012 18:06 — forked from benedmunds/gist:2415063
Ion Auth - get users groups
$this->data['users'] = $this->ion_auth->users()->result();
foreach ($this->data['users'] as $k => $user)
{
$this->data['users'][$k]->groups = $this->ion_auth->get_users_groups($user->id)->result();
}
@gbaldera
gbaldera / customtable.js
Created April 19, 2012 19:25 — forked from pec1985/customtable.js
Custom Table
function CustomTable(){
var self = {};
var win = Ti.UI.createWindow({
backgroundColor:'#ccc'
});
var table = Ti.UI.createTableView({
top:20,
bottom:20,
left:20,
right:20,
@gbaldera
gbaldera / app.js
Created April 20, 2012 18:19 — forked from pec1985/app.js
Android Menu Example
var win = Ti.UI.createWindow({
exitOnClose: true,
backgroundColor: '#ccc',
fullscreen: false
});
win.open();
var activity = win.activity;
@gbaldera
gbaldera / app.js
Created April 21, 2012 13:23 — forked from skypanther/app.js
Cache Remote Images
var Utils = {
/* modified version of https://gist.github.com/1243697
* adds detection of file extension rather than hard-coding .jpg as in the original
*/
_getExtension: function(fn) {
// from http://stackoverflow.com/a/680982/292947
var re = /(?:\.([^.]+))?$/;
var tmpext = re.exec(fn)[1];
return (tmpext) ? tmpext : '';
},
// The result of the expression (true && false) is assigned to $g
// Acts like: ($g = (true && false))
$g = true && false;
// The constant true is assigned to $h and then false is ignored
// Acts like: (($h = true) and false)
$h = true and false;
@gbaldera
gbaldera / push_notifications.js
Created May 16, 2012 12:57 — forked from yagitoshiro/push_notifications.js
apple push notification sample (Titanium Mobile)
//////////////////////push_notifications.js///////////////////////
var apns = function(){
var pref = require('preferences').preferences;
Titanium.Network.registerForPushNotifications({
types: [
Titanium.Network.NOTIFICATION_TYPE_BADGE,
Titanium.Network.NOTIFICATION_TYPE_ALERT
],
success:function(e)
@gbaldera
gbaldera / app.js
Created May 21, 2012 19:40 — forked from pec1985/app.js
Easy SplitView controller - iPad, Titanium
var SplitView = require('splitview');
/**
* SplitView Public Methods:
*
* split.initWithMasterAndDetailWindows( Ti.UI.Window, Ti.UI.Window );
* split.openInMaster( Ti.UI.Window )
* split.openInDetail( Ti.UI.Window )