Skip to content

Instantly share code, notes, and snippets.

View tonylukasavage's full-sized avatar
💭
Learning to make games

Tony Lukasavage tonylukasavage

💭
Learning to make games
View GitHub Profile
@tonylukasavage
tonylukasavage / app.js
Created June 2, 2014 14:51
Inject environment variables into Titanium. Makes shared code easier to manage (no more sanitizing keys in repos). Uses Titanium to encrypt the values.
// now you can use it in a titanium app
useSomeApi(Ti.App.Properties.getString('SOME_API_KEY'));
@tonylukasavage
tonylukasavage / should.js
Created May 24, 2014 02:00
custom should.js assertion
// getter assertion
should.Assertion.add('CRAZY', function() {
this.params = {
operator: 'to be the string "CRAZY"',
expected: 'CRAZY',
showDiff: true
};
this.obj.should.equal('CRAZY');
}, true);
@tonylukasavage
tonylukasavage / app.js
Last active August 29, 2015 14:01
perf test
var win = Ti.UI.createWindow();
var key = '#foo';
var start = new Date().getTime();
for (var i = 0; i < 10000; i++) {
if (key.indexOf('#') === 0 && key !== '#' && !win.__iamalloy) {
var bar = 1;
}
}
console.log('time (__iamalloy): ' + ((new Date().getTime()) - start) + 'ms');
find-up() {
local path=$(pwd)
while [[ "$path" != "" && ! -e "$path/$1" ]]; do
path=${path%/*}
done
if [ "$path" != "" ]
then
echo "$path"
fi
}
@tonylukasavage
tonylukasavage / search.txt
Created May 16, 2014 13:48
Alloy twitter search
((alloy AND appcelerator) OR #tialloy) -Q&A
exports.createController = function(name, args) {
var newController = new (require('alloy/controllers/' + name))(args);
_.each(_.keys(args), function(key) {
if (key.indexOf('#') === 0 && key !== '#') {
newController[key.substring(1)].applyProperties(args[key]);
}
});
});
@tonylukasavage
tonylukasavage / index.js
Created April 18, 2014 22:18
can't get translucent navbars working
$.nav.open();
@tonylukasavage
tonylukasavage / Profile.js
Last active January 4, 2016 00:28 — forked from timanrebel/Profile.js
This is essentially what Alloy is doing under the hood for you with backbone
var EVENTS = 'fetch change destroy';
var args = arguments || {};
// remove existing bindings to prevent unexpected behavior and memory leaks
$.user.off(EVENTS);
// add bindings to new model
args.user.on(EVENTS, function() {
$.name.text = args.user.get('name');
@tonylukasavage
tonylukasavage / .bash_profile
Last active August 13, 2016 17:28
custom bash prompt for Titanium/Alloy development (and git) Shows the git branch in the current working directory, as well as the Titanium SDK and Alloy version if you are in a Titanium project. The git branch will also show a star (*) next to it if the branch has uncommitted changes. I'm using this with Mac OSX 10.9.1 Terminal and the Droid San…
find-up() {
local path=$(pwd)
while [[ "$path" != "" && ! -e "$path/$1" ]]; do
path=${path%/*}
done
if [ "$path" != "" ]
then
echo "$path"
fi
}
@tonylukasavage
tonylukasavage / .jshintrc
Created January 1, 2014 14:49
.jshintrc file for Titanium + mocha + should
{
"globals": [
"Ti": false,
"Titanium": false,
"Alloy": false,
"describe": false,
"it": false,
"before": false,
"beforeEach": false,
"after": false,