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 / .jshintrc
Created January 1, 2014 14:06
Titanium-specific .jshintrc file for those using realtime linting in their editors
{
"globals": [
"Ti": false,
"Titanium": false,
"Alloy": false
],
"node": true
}
$.theRequire.doSomething();
$.index.open();
@tonylukasavage
tonylukasavage / beastieboys.js
Last active December 26, 2015 14:19
Javascript for properly emphasizing Beastie Boys lyrics (tested in node.js 0.10.21)
var always = new RegExp('(?:' + ['style', 'johnny ryall', 'sabotage', 'brooklyn', 'root down'].join('|') + ')', 'gim');
function droppinScienceLikeGalileoDroppedTheOrange(lyrics) {
return lyrics
.replace(always, function(m, p1) {
return m.toUpperCase();
})
.replace(/\b([^\s]+?)(\r\n|\n|\r|$)/g, function(m, p1, p2) {
return p1.toUpperCase() + p2;
});
}
@tonylukasavage
tonylukasavage / pf.txt
Created October 1, 2013 00:27
Pulp Fiction
PULP [pulp] n.
1. A soft, moist, shapeless mass or matter.
2. A magazine or book containing lurid subject matter and
being characteristically printed on rough, unfinished paper.
American Heritage Dictionary: New College Edition
if (someRuntimeCondition) {
@import('class2');
} else {
@import('class1');
}
// or
function foo() {
@import('bar');
{
"jshint_options": {
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": "nofunc",
"loopfunc": true,
"maxlen": 100,
"newcap": true,
"noarg": true,
var _ = require('underscore');
NormalNoXMLActivity.prototype.onCreate = function() {
// "this" refers to the NormalNoXMLActivity instance invoking this function
// save a reference to "this"
var self = this
_.each([1,2,3], function(i) {
// "this" no longer refers to the NormalNoXMLActivity, but "self" does
@tonylukasavage
tonylukasavage / index.xml
Created August 7, 2013 21:25
potential usage for nested widgets/requires
<Alloy>
<Window>
<Widget src="genericContainer">
<Label>hi there</Label>
<Label>another label</Label>
<Button>and a button</Button>
</Widget>
</Window>
</Alloy>
@tonylukasavage
tonylukasavage / base.js
Created August 5, 2013 19:31
inheriting event handlers in Alloy
// The base controller event handler, which will get overridden by the derived one
exports.doClick = function(e) {
alert('base click handler');
};
// We have to wait until the object is initialized before applying the event listener. This is so
// the derived listener is used, not the base one. Also, "$" must be used instead of "exports", to
// ensure that the overridden instance of the controller's "doClick" is used, not the exported
// version of the function from the base controller.
exports.init = function(e) {
@tonylukasavage
tonylukasavage / lib.js
Last active December 20, 2015 13:09
requires
var Alloy = require('alloy'),
Backbone = require('alloy/backbone'),
_ = require('alloy/underscore')._;