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
{
"browser": true,
"camelcase": false,
"curly": true,
"eqeqeq": true,
"eqnull": true,
"expr": true,
"immed": true,
"indent": 4,
"latedef": false,
@tonylukasavage
tonylukasavage / Vagrantfile
Created May 27, 2015 12:08
Use quick Vagrantfile to emulate a Travis CI environment (AKA, Ubuntu 12.04.5 LTS). Make sure you install vagrant (www.vagrantup.com) and VirtualBox (www.virtualbox.org/wiki/Downloads) first. Create the below Vagrantfile then simply run `vagrant up` in the folder in which it is located. After it boots you can run `vagrant ssh` to SSH into the he…
Vagrant.configure("2") do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
end
@tonylukasavage
tonylukasavage / GonzoPreferenceWindow.as
Created July 26, 2011 20:08
Unsexy scroll position hackery
// fontList == s:List
// arrList == s:ArrayList for enumerated fonts
fontList.selectedIndex = -1;
for (var i:uint = 0; i < arrList.length; i++) {
if (arrList.getItemAt(i).fontName == FONT_NAME_TO_MATCH) {
fontList.selectedIndex = i;
fontList.layout.verticalScrollPosition = fontList.dataGroup.contentHeight * (i/(arrList.length-1)) - (fontList.height/2) + 8;
break;
}
@tonylukasavage
tonylukasavage / snip.js
Created September 1, 2011 19:39
cross-platform labels with padding in tableviewrow
var isAndroidValue = undefined;
function isAndroid() {
if (isAndroidValue === undefined) {
isAndroidValue = Ti.Platform.osname;
}
return isAndroidValue;
}
// The trick here is that `left` and `right` would constantly give me the wrong height and truncate the Label text
// when using padded Labels in a TableViewRow on Android. They work fine on iOS though. To get around this I just use
win.addEventListener('close', function(e) {
tmpFile.deleteFile();
});
win.add(button);
win.open();
@tonylukasavage
tonylukasavage / app.js
Created September 30, 2011 15:06
Appcelerator: PDF Intent
Ti.UI.setBackgroundColor('#222');
var win = Ti.UI.createWindow({
navBarHidden: true,
exitOnClose: true
});
var button = Ti.UI.createButton({
title: 'open pdf',
height: '60dp',
width: '120dp',
Ti.UI.setBackgroundColor('#222');
var win = Ti.UI.createWindow({
navBarHidden: true,
exitOnClose: true
});
var button = Ti.UI.createButton({
title: 'open pdf',
height: '60dp',
width: '120dp',
var appFilePath = Ti.Filesystem.resourcesDirectory + 'w4.pdf';
var appFile = Ti.Filesystem.getFile(appFilePath);
var tmpFile = undefined,
newPath = undefined;
if (Ti.Filesystem.isExternalStoragePresent()) {
tmpFile = Ti.Filesystem.createTempFile();
newPath = tmpFile.nativePath + '.pdf';
tmpFile.move(newPath);
tmpFile = Ti.Filesystem.getFile(newPath);
button.addEventListener('click', function(e) {
if (tmpFile) {
var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_VIEW,
type: "application/pdf",
data: tmpFile.nativePath
});
try {
Ti.Android.currentActivity.startActivity(intent);
@tonylukasavage
tonylukasavage / .gitignore
Created November 29, 2011 14:03
.gitignore for Titanium Mobile projects
tmp
.DS_Store
build/iphone/*
!build/iphone/.gitignore
build/android/*
!build/android/.gitignore
.settings
build.log
.fastdev.lock