Skip to content

Instantly share code, notes, and snippets.

var CustomSwitch = function(onText, offText, value) {
// the custom view
var view = Ti.UI.createView();
var label = Ti.UI.createLabel();
var sw = Ti.UI.createSwitch();
view.add(label);
view.add(sw);
@omorandi
omorandi / gist:1156232
Created August 19, 2011 07:01
Small javascript for decoding mashape's job posting @ http://www.mashape.com/jobs
var text = '576520776f756c64206c6f766520746f2073656520796f757220636f646520696e7374656164206f6620736f6d65207061706572732c20776520646f6e27742077616e74204954206d616e61676572732c2077652077616e74207265616c206861636b6572732e20576527726520666f6375736564206f6e206368616e67696e67207468652077617920736572766963657320616e6420646174612061726520646973747269627574656420616e6420636f6e73756d65642e20496620796f752077616e7420746f207075742074686520776f726c642075707369646520646f776e2c20616e6420796f7520647265616d732061726520636f64656420696e204a41564120616e64206261736564206f6e206d6f6e676f44422c2073686f757420697420686572653a206861636b657273406d6173686170652e636f6d20496620796f75277265206b69636b2d61737320646576656c6f706572207765276c6c2066696e6420796f752e204265206172726f67616e742e';
var decode = function(txt) {
var decoded = '';
for (var i = 0; i < txt.length; i += 2) {
var b = '' + txt.charAt(i) + txt.charAt(i+1);
var c = parseInt(b, 16);
decoded += String.fromCharCode(c);
}
@omorandi
omorandi / gist:1013226
Created June 7, 2011 21:31
Two methods for sending SMS messages with Titanium Mobile on Android throught native intents
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff',
layout: 'vertical'
});
var bt1 = Ti.UI.createButton({title: 'send message (method 1)', top: 200});
bt1.addEventListener('click', function(e)
@omorandi
omorandi / app.js
Created December 19, 2010 10:41
Appcelerator Titanium Mobile - Custom events
var win1 = Titanium.UI.createWindow({
title:'Window 1',
backgroundColor:'#fff'
});
var label1 = Titanium.UI.createLabel({
color:'#999',
text:'Window 1\nClick anywhere for opening Window 2',
textAlign:'center',