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.tss
Created July 16, 2013 14:49
TSS reset for Alloy/Titanium
'Label[platform=android]': {
color: '#000' // all platforms except Android default to black
}
'Window': {
backgroundColor: '#fff' // white background instead of default transparent
}
'Window[platform=android]': {
modal: false // make android windows all heavyweight
@tonylukasavage
tonylukasavage / .bash_profile
Last active December 18, 2015 08:49
Shell script to create a new Titanium project, make it Alloy, and load it up in Sublime Text
# Here's how to add it to a shell profile
tialloy() {
ti create --id com.testing.$1 --name $1 --workspace-dir . --platforms \
android,blackberry,ios,ipad,iphone,mobileweb,tizen --no-prompt && \
cd $1 && alloy new . && subl .
}
var theView = $.someWidgetId.getView('idOfViewInWidget');
@tonylukasavage
tonylukasavage / script.sh
Created May 29, 2013 18:18
Move all uncommitted changes to a new branch and revert the existing branch to HEAD. "master" has uncommitted changes. You decided you'd rather make those changes in "dev_branch". Here's how to move those uncommitted changes to "dev_branch" and then revert "master" to its last commit.
# get into the master branch
git checkout master
# create a new branch for the changes and check it out
git checkout -b dev_branch
# stash the changes until we revert master
git stash
# go back to master
@tonylukasavage
tonylukasavage / compare.js
Created May 10, 2013 16:17
Deep (but slow) comparison of JSON-serializable JS objects
// I'm using this now in my Alloy runtime testing to assert that the
// proper styles are getting assigned to Titanium proxy objects. The
// deep comparison is necessary for objects like font in the style. So
// for my purposes the accuracy of the results far supercedes the lack
// of blazing performance with this code. I'm using underscore.js as
// it's part of Alloy, but isX() calls could easily be filled out in
// a couple lines of JS.
//
// Obviously due to the use of JSON.stringify() the objects to be
// compared need to be JSON serializable.
@tonylukasavage
tonylukasavage / with.js
Created May 7, 2013 18:58
jasmine "with" and without
module.exports = function($) {
with (require('jasmine')) {
describe('describe', function() {
it('it', function() {
expect(true).toBeTruthy();
});
});
}
};
var test = require('com.test');
...
var testTwo = test.init();
var realView = testTwo.createView();
@tonylukasavage
tonylukasavage / README.md
Created April 10, 2013 13:58
My new "license" for my OSS projects

license

Do whatever you want with this code. I offer it without expectation or warranty. No need to credit me in your project or source code. A digital high five would be nice, but is not required.

@tonylukasavage
tonylukasavage / index.js
Created March 26, 2013 18:22
Handling model validation errors in Alloy
$.index.open();
// create an instance of the model
var model = Alloy.createModel('myModel');
// listen for the "error" event
model.on('error', function(model, error) {
Ti.API.info('error handled: ' + error);
})
@tonylukasavage
tonylukasavage / index.js
Last active December 15, 2015 00:38
Alloy loose-usage of ListView
function myOnDisplayItem(e) {}
var myTemplate = {
properties: {
onDisplayItem: myOnDisplayItem,
selectedBackgroundColor: 'blue',
height: 120,
},
childTemplates: [
{