This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/(?:\n|\r\n|\r)/g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Exercise 24 (23 in gotour local) | |
package main | |
import ( | |
"fmt" | |
"math" | |
) | |
func Approx(x float64, z float64) float64 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UI = {} | |
local FONT = 'OCRAStd' | |
function UI.counter(label, counter) | |
local group = display.newGroup() | |
local lText, lSize = label.text, label.size or 25 | |
local cText, cSize = counter.text, counter.size or lSize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* RULES: | |
* PAUSE event always seems to remember the last URL value | |
* So, if you launch app with URL, then PAUSE, getArgs will still have URL in it | |
* Same for if you pause app, | |
* resume it with a URL, then pause, same thing - it remains the first time. | |
* Incoming query string values should be encoded according to http://www.faqs.org/rfcs/rfc3986.html | |
* (basically, php rawurlencode) | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var win = Ti.UI.createWindow({backgroundColor: '#fff'}) | |
, Emitter = require('emitter') //https://github.com/component/emitter | |
, event = new Emitter() | |
, limit = 10000 | |
, i = 0 | |
, startTime | |
; | |
var buttonTi = Ti.UI.createButton({title: 'start-Ti', left: 10}); | |
var buttonJs = Ti.UI.createButton({title: 'start-js', right: 10}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//So, grab the toolbar items. | |
//Its set up for portrait by default | |
var tbButtons = $.toolbar.items | |
, showMasterViewButton = tbButtons[0] //cache a copy | |
; | |
//For first run if launched in landscape mode | |
if(Ti.Gesture.isLandscape()) { | |
tbButtons.shift(); | |
$.toolbar.items = tbButtons; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ls -LR Scripts/**/**/*.js | xargs -L1 js-beautify -r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ti.UI.setBackgroundColor('#000'); | |
var win = Ti.UI.createWindow({ | |
backgroundColor: 'red', | |
exitOnClose: true, | |
navBarHidden: true | |
}); | |
var titleView = Ti.UI.createView({ | |
backgroundColor: '#f00', | |
top: 0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Barebones example of how we do sidemenu in iOS app. | |
//You use this window as the container for your navGroup. | |
var rootWin = Titanium.UI.createWindow({ | |
zIndex: 2, | |
width: '100%', | |
backgroundColor: '#f00', | |
listPanelVisible: false //Custom prop | |
}); |