Skip to content

Instantly share code, notes, and snippets.

//app.js
Titanium.UI.setBackgroundColor('#000');
//create window
var win = Titanium.UI.createWindow({
title:'Countdown Main',
modal: true,
exitOnClose: true
});
//Simple k/v
//Open the db.
//DB is simple k/v
var db = Ti.Database.open('db');
// db.execute('DELETE FROM DATA');
// db.execute('DROP TABLE DATA');
// db.execute('VACUUM');
db.execute('CREATE TABLE IF NOT EXISTS DATA (KEY TEXT UNIQUE, VALUE TEXT)');
// var xo = db.execute('SELECT * FROM DATA');
#!/usr/bin/ruby
require 'socket'
require 'rubygems'
require 'json'
require 'listen'
path = '/Users/mitch/Sites/klocko'
Listen.to(path, :force_polling => true) do |modified, added, removed|
<html>
<head>
<script type="text/javascript">
var Ti = Titanium;
Titanium.UI.getCurrentWindow().showInspector(true);
</script>
</head>
<body style="background-color:#ccc;margin:0">
</body>
//Some example code on how to make a menu item type app.
var tray = Ti.UI.addTray('tray.png'),
menu = Ti.UI.createMenu(),
//Add some menu items
menuItems = [
Titanium.UI.createMenuItem('Change Icon', function() {
//Something's going on... let's change the icon.
tray.setIcon('tray-active.png');
@meeech
meeech / gist:3628881
Created September 5, 2012 01:26
Snippet for listen gem bug report
#!/usr/bin/ruby
require 'socket'
require 'rubygems'
require 'json'
require 'listen'
path = '/Users/mitch/Sites/klocko'
Listen.to(path) do |modified, added, removed|
@meeech
meeech / gist:3433382
Created August 23, 2012 06:28
example for bug report
//bug: Cannot remove child view from inside TableViewRow
//2 cases
//A: .remove() View inside TableViewRow - Crash
//B: .remove() View nested in View inside TableViewRow - No Crash, but no effect
//Tested
//Android: 4.1, 2.3.3
//TiSDK: 2.1.2.v20120821160113, 2.1.1GA
var table = Ti.UI.createTableView({
module.exports = function() {
// CREDIT: broofa http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,
function(c) {
var r = Math.random() * 16 | 0,
v = c == 'x' ? r: (r & 0x3 | 0x8);
return v.toString(16);
}).toUpperCase();
};
@meeech
meeech / gist:3342781
Created August 13, 2012 18:02
nav stack
//navGroup Wrapper to be able to implement home.
//Track stack of open windows
var _navGroup, //Original
currentStack = [],
uuid = require('lib/util/uuid');
var create = function(args) {
if (Ti.Platform.osname != 'android') {
_navGroup = Ti.UI.iPhone.createNavigationGroup(args);
@meeech
meeech / gist:3125227
Created July 16, 2012 21:35
ellipsize
var win1 = Titanium.UI.createWindow({
backgroundColor:'#ccc',
exitOnClose:true,
title:'win1: Main Window'
});
var label1 = Ti.UI.createLabel({
top: 10,
backgroundColor:'black',
color:'white',
ellipsize:true,