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
@ryanflorence
ryanflorence / static_server.js
Last active April 26, 2024 16:18
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@dawsontoth
dawsontoth / app.js
Created February 23, 2011 20:08
Swipe for Android plus Vertical Swipes in @appcelerator #titanium
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
/**
* Adds "swipe" event support to Android, and adds swipe up and down to iOS.
* @param view The view that should be made swipeable.
* @param allowVertical Whether or not vertical swipes (up and down) are allowed; default is false.
* @param tolerance How much further you need to go in a particular direction before swipe is fired; default is 2.
*/
function makeSwipeable(view, allowVertical, tolerance) {
tolerance = tolerance || 2;
@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
//Wrapper class to create extensible Titanium components
function Component(/*Object*/ tiView) {
var self = {
__viewProxy:tiView
};
//passthrough for add
self.add = function(/*Object*/ tiChildView) {
var v = tiChildView.__viewProxy||tiChildView;
self.__viewProxy.add(v);
/*
* Mixin properties of n objects into the given object - pass in as many objects to mix in as you like.
* Can perform a shallow or deep copy (shallow is default for performance reasons).
*
* Usage:
* mixin([Boolean deepCopy,] objectToExtend, objectToMixIn [, as many other objects as needed])
*
* Examples:
*
* var o1 = {
@billdawson
billdawson / android_scons_speedups.md
Created January 11, 2012 21:41
Speeding up Titanium Build

Speeding up Titanium Mobile Build

(The command examples assume OS X).

Just about everything that happens when you enter scons is for Android. So anything you can do to speed up the Android part of our build will be useful.

  • Android NDK r7 can use ccache. We get huge improvements in build time with it. So install it (if you have HomeBrew, brew install ccache) then set a shell variable NDK_CCACHE to point to it. I.e., for me, having installed it with brew, it would be export NDK_CCACHE=/usr/local/bin/ccache.

  • NDK can also parallelize while compiling. Set a shell variable NUM_CPUS to (according to Opie) 2x the number of cores in your machine. A quick way to get the # cores on your machine in OS X is system_profiler | grep "Number Of Cores" in terminal. I have 2 cores, so my shell var setting is export NUM_CPUS=4.

//Component Base
var Base = {
log: function(str) {
Ti.API.info(str);
}
};
//construct a new component object
Base.create = function(funcs) {
var context = {
@rodw
rodw / backup-github.sh
Last active March 30, 2024 15:04
A simple script to backup an organization's GitHub repositories, wikis and issues.
#!/bin/bash
# A simple script to backup an organization's GitHub repositories.
#-------------------------------------------------------------------------------
# NOTES:
#-------------------------------------------------------------------------------
# * Under the heading "CONFIG" below you'll find a number of configuration
# parameters that must be personalized for your GitHub account and org.
# Replace the `<CHANGE-ME>` strings with the value described in the comments
# (or overwrite those values at run-time by providing environment variables).
module.exports = Alloy.getController('BaseController').extend({
customFunction: function(){ alert('inherited function call!'); }
});

Underscore prefix indicates that the function is created and performed by Alloy. All non-Alloy functions below will be optional;

  • __init - Establish $ as this
  • prelayout - Before any UI is created. Good time to update Alloy.CFG with runtime values for use in styles.
  • __layout - All UI elements are created and added to the view hierarchy
  • postLayout - Everything is prepared, this is where the bulk of the code will go and where beginners will spend all their time.