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 / unzip.py
Created April 12, 2012 15:09
Trying to unzip large files
# Make sure you add the -Xmx512M options or jython will throw a heap exception
# METHOD 1
import zipfile, os, sys
z = zipfile.ZipFile(sys.argv[1])
for name in z.namelist():
destdir = os.path.dirname(name)
if not os.path.isdir(destdir) :
os.makedirs(destdir)
<!-- HTML and CSS -->
<html>
<head>
<title>Declarative UI Master Detail Test</title>
<script src="/controller/index.js"></script>
</head>
<body>
<div id="mainWindow" data-ti-api="Window" style="-ti-navBarHidden:false;">
<div id="header" data-ti-api="View">
<div id="title" data-ti-api="Label" style="-ti-text:'My Title';"></div>
@tonylukasavage
tonylukasavage / app.js
Created May 10, 2012 18:24
Example gist
var win = Ti.UI.createWindow({
backgroundColor: '#fff',
exitOnClose: true,
navBarHidden: false
});
win.open();
@tonylukasavage
tonylukasavage / idea.xml
Created May 14, 2012 18:07
rendering idea
<div id="tableview" data-ti-api="TableView" data-ti-datasource="/model/mydata">
<div data-ti-api="RowRenderer">
<div data-ti-api="Label" style="{objectname}"></div>
</div>
</div>
@tonylukasavage
tonylukasavage / app.js
Created June 7, 2012 20:39
Embed test
var win = Ti.UI.createWindow({
backgroundColor: '#fff',
exitOnClose: true,
navBarHidden: false
});
win.open();
@tonylukasavage
tonylukasavage / app.js
Created June 18, 2012 14:36
before and after: alloy
var Alloy = require("alloy"), _ = Alloy._, A$ = Alloy.A, M$ = Alloy.M, BC$ = Alloy.Backbone.Collection, TFL$ = Ti.UI.FILL, TSZ$ = Ti.UI.SIZE, $ = {};
$.master = A$(Ti.UI.createWindow({
backgroundColor: "white",
layout: "vertical",
id: "master"
}), "Window"), $.table = A$(Ti.UI.createTableView({
id: "table"
}), "TableView", $.master), $.master.add($.table), function(exports) {
$.table.setData([ Ti.UI.createTableViewRow({
@tonylukasavage
tonylukasavage / DisplayCapsProxy.java
Created July 19, 2012 20:20
getSize() for Android in Titanium
@Kroll.getProperty @Kroll.method
public String getSize() {
switch(TiApplication.getInstance().getApplicationContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) {
case Configuration.SCREENLAYOUT_SIZE_SMALL :
return "small";
case Configuration.SCREENLAYOUT_SIZE_NORMAL :
return "normal";
case Configuration.SCREENLAYOUT_SIZE_LARGE :
return "large";
case 4 : // Configuration.SCREENLAYOUT_SIZE_XLARGE (API 9)
@tonylukasavage
tonylukasavage / app.js
Created July 31, 2012 00:41
zIndex doesn't animate
var win = Ti.UI.createWindow({
backgroundColor: '#fff',
fullscreen: false,
exitOnClose: true
});
var view1 = Ti.UI.createView({
height: 200,
width: 200,
left: 30,
export.module = Alloy.getController('BaseController').extend({
// preLayout() is optional. It's safe to delete.
preLayout: function(args) {}
// postLayout() is also optional, but most often all your app
// logic will be contained in this function.
postLayout: function(args) {}
});
@tonylukasavage
tonylukasavage / no_magic_explicit.js
Created August 3, 2012 13:24
no magic controllers
module.exports = Alloy.getController('BaseController').extend({
// rarely used
preLayout: function(args){},
// where 98% of the code will go
postLayout: function(args) {
$.label.text = 'here i am';
// other controller code
},