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
cachedImageView = function(basedir, uri, obj, attr, cacheage) {
/**
Appcelerator Titanium ImageView /w cache
This function attempts to cache a remote image and then returns it again
when it's requested.
The file is stored in a directory "basedir," this is to try and help
you keep files unique. It's not special or magical, but not dirty either.
function myOnDisplayItem(e) {}
var myTemplate = {
properties: {
onDisplayItem: myOnDisplayItem,
selectedBackgroundColor: 'blue',
height: 120,
},
childTemplates: [
{
var username = Ti.UI.createTextField({
width:Ti.UI.FILL,
hintText:'Email',
height:'40dp',
backgroundColor:'#fff'
});
var line = Ti.UI.createView({
width:Ti.UI.FILL,
height:'1dp',
/**
* Modal Info View module - Titanium JS
* @author César Cavazos - @cesarcvz
* Based on: https://github.com/appcelerator/KitchenSink
*/
/**
* Open an infomation modal anywhere in hour app
* @param {String} text
* @param {Object} params
@gbaldera
gbaldera / app.js
Created February 2, 2013 19:59 — forked from dawsontoth/app.js
/**
* 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';
@gbaldera
gbaldera / app.js
Created February 2, 2013 19:59 — forked from dawsontoth/app.js
/**
* The following snippet will ask the user to rate your app the second time they launch it.
* It lets the user rate it now, "Remind Me Later" or never rate the app.
*/
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
win.addEventListener('open', checkReminderToRate);
win.add(Ti.UI.createLabel({ text: 'This is a simple app that will remind you to rate it.' }));
win.open();
function checkReminderToRate() {
/**
* We're going to create an infinite loading table view. Whenever you get close to the bottom, we'll load more rows.
*/
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
var isAndroid = Ti.Platform.osname === 'android';
/**
* Create our UI elements.
*/
var table = Ti.UI.createTableView({ top: 0, right: 0, bottom: 0, left: 0 });
@gbaldera
gbaldera / pull-to-refresh(android).js
Created December 5, 2012 18:26 — forked from jpurcell/pull-to-refresh(android).js
Tweetie-like pull to refresh and pull to load more. Note that it requries set heights for everything.
// This is the Android version of the Tweetie-like pull to refresh table:
// http://developer.appcelerator.com/blog/2010/05/how-to-create-a-tweetie-like-pull-to-refresh-table.html
var win = Ti.UI.currentWindow;
var alertDialog = Titanium.UI.createAlertDialog({
title: 'System Message',
buttonNames: ['OK']
});
var scrollView = Ti.UI.createScrollView({
@gbaldera
gbaldera / cuter.py
Created September 21, 2012 18:50 — forked from sigilioso/cuter.py
Python PIL Example: get a thumbnail resizing and cropping an image.
# -*- coding: utf-8 -*-
import Image
def resize_and_crop(img_path, modified_path, size, crop_type='top'):
"""
Resize and crop an image to fit the specified size.
args:
img_path: path for the image to resize.
@gbaldera
gbaldera / app.js
Created September 21, 2012 00:18 — forked from pec1985/app.js
Best UI CommonJS module ever
var UI = require('ui');
UI.Window({
subviews:[
UI.Label({
width: Ti.UI.SIZE,
height: Ti.UI.SIZE,
color: "#000",
text: 'here',
onClick: function() {