Skip to content

Instantly share code, notes, and snippets.

@meeech
meeech / gist:7744433
Created December 2, 2013 03:15
regex to follow up on.
/(?:\n|\r\n|\r)/g
@meeech
meeech / ex23.go
Last active December 27, 2015 20:29
gotour ex 24
//Exercise 24 (23 in gotour local)
package main
import (
"fmt"
"math"
)
func Approx(x float64, z float64) float64 {
@meeech
meeech / ui.lua
Last active December 21, 2015 04:09
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
/**
* 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)
*/
@meeech
meeech / gist:5407137
Created April 17, 2013 19:42
Test using Ti.App events vs using JS only event system.
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});
//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');
@meeech
meeech / gist:4724807
Created February 6, 2013 18:49
work around the fact you can't show/hide buttons in a toolbar on ios w/ titanium. So this manages the toolbar for portrait/landscape mode of the detail window in a split view.
//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;
@meeech
meeech / gist:8188f9f7722a413ed65e
Created October 12, 2015 19:31
jsbeautify everything in a folder
ls -LR Scripts/**/**/*.js | xargs -L1 js-beautify -r
@meeech
meeech / app.js
Created October 16, 2012 01:50 — forked from nauman/app.js
Titanium header - > title, content -> table, footer -> banner
Ti.UI.setBackgroundColor('#000');
var win = Ti.UI.createWindow({
backgroundColor: 'red',
exitOnClose: true,
navBarHidden: true
});
var titleView = Ti.UI.createView({
backgroundColor: '#f00',
top: 0,
@meeech
meeech / gist:3894108
Created October 15, 2012 18:15
sidemenu distilled
//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
});