Skip to content

Instantly share code, notes, and snippets.

@pec1985
pec1985 / app.js
Created August 31, 2012 18:27
How to create a simple memory leak with Titanium
var memLeakArray = [];
function FirstWindow() {
var win = Ti.UI.createWindow({
backgroundColor: '#ccc'
});
var btn = Ti.UI.createButton({
title: 'open next',
width: Ti.UI.SIZE,
@pec1985
pec1985 / sample.cs
Created August 24, 2012 21:16
SubClassing in C#
public class Shape
{
virtual public int GetHeight()
{
return 101;
}
}
public class Square : Shape
{
@pec1985
pec1985 / app.js
Created July 24, 2012 21:27
movable header
var win = Ti.UI.createWindow();
// image found at
// http://f.cl.ly/items/3F2Z0j112l3r0x2Z0215/background.png
var bgImage = Ti.UI.createImageView({
width:320,
height:320,
image: 'background.png',
top:-100
@pec1985
pec1985 / lorem.txt
Created July 24, 2012 02:28
Lorem Ipsum
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis varius nulla a tortor luctus a suscipit lorem vehicula. Donec eleifend sollicitudin purus, ut condimentum lorem tincidunt eu. Aliquam vitae nunc et lacus faucibus sodales pretium ac nisl. In at metus nec lacus imperdiet semper. Phasellus ullamcorper viverra pharetra. Praesent urna felis, molestie id mattis a, bibendum facilisis mauris. Vestibulum ut sapien magna. Vivamus et justo lectus, ac placerat eros.
Aliquam quis elit quis urna egestas mollis quis nec odio. Aenean malesuada, odio vitae egestas dapibus, nunc augue blandit augue, a cursus lectus lorem rutrum augue. Curabitur tincidunt mollis laoreet. Curabitur non dolor neque. Proin accumsan convallis massa vitae feugiat. Aliquam luctus est nec mi vestibulum fermentum. Sed et felis id tortor iaculis gravida. Proin lectus lacus, ultrices posuere imperdiet vel, cursus et leo. Cras lacinia, ante sed accumsan vulputate, quam nisi hendrerit est, vel tempus ante nisl et risus. Cras nulla sapien, aliqu
@pec1985
pec1985 / TiUITextAreaProxy.m
Created June 28, 2012 02:30
contentWidth and contentHeight in Ti.UI.TextArea
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2012 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*
* WARNING: This is generated code. Modify at your own risk and without support.
*/
#ifdef USE_TI_UITEXTAREA
@pec1985
pec1985 / test1.js
Created June 25, 2012 15:37
Optimizing Appcelerator's Titanium
/**
* Test #1
* Adding 10,000 Ti.UI.TableViewRows to a Ti.UI.TableView
* The rows have the Ti.UI.iPhone.TableViewCellSelectionStyle.BLUE constant in them
*
* Total time in my Mac: 1228ms
*/
var win = Ti.UI.createWindow({
backgroundColor: '#ccc'
@pec1985
pec1985 / app.js
Created June 22, 2012 18:42
Titanium getElemetByTag()
/**
* Gets a Titanium Element
* @param {Ti.UI.View} Parent View - Where the view is
* @param {String} tag Property of the view
* @param {String} value Value of the custom property
* @return {Ti.UI.View} Return a view if found, otherwise null;
*/
function getElementByTag(parent, tag, value){
// Store the array in a variable for better performance
@pec1985
pec1985 / example1.js
Created May 21, 2012 17:46
Callback examples
//------------ ui.js -------------
/**
* AlertDialog component with callback function
* @param { Object } _params Ti.UI.AlertDialog properties
* and optional "callback"
*/
exports.Alert = function(_params){
_params = _params || {};
@pec1985
pec1985 / log.js
Created May 21, 2012 17:15
Android pause and resume events
var DEBUG = true;
/**
* Print log in cosole in "< INFO >" modude if DEBUG if true
* @param { String } _text console log text
*/
exports.Info = function(_text){
if(DEBUG){
Ti.API.info('< INFO > '+_text);
} else {
return;
@pec1985
pec1985 / app.js
Created May 20, 2012 06:55
DashboardView JS module
var Dashboard = require('dashboard');
var win = Ti.UI.createWindow({
backgroundColor:'lightgray'
});
var view = new Dashboard.View();
var data = [];
for(var i = 0; i < 20; i++){