Skip to content

Instantly share code, notes, and snippets.

View iantearle's full-sized avatar
💭
I may be slow to respond.

Ian Tearle iantearle

💭
I may be slow to respond.
View GitHub Profile
@tsteur
tsteur / alloy.jmk
Last active November 8, 2017 02:12
Simple build configuration file for Titanium Mobile Alloy to remove unimportant log calls if build type is production
function isProduction(alloyConfig)
{
return 'production' == alloyConfig.deploytype;
}
function removeUnimportantLogCallsFromContent(content)
{
if (!content) {
return;
}
@josheinstein
josheinstein / gist:5586469
Last active October 15, 2022 02:13
Handle back button issues with Twitter Bootstrap's tab component.
// Handle back button issues with Twitter Bootstrap's tab component.
// Based on: http://stackoverflow.com/a/10120221/81769
// It has been changed to avoid the following side effects:
// - Switching tabs was being added to navigation history which is undesirable
// (Worked around this by using location.replace instead of setting the hash property)
// - Browser scroll position was lost due to fragment navigation
// (Worked around this by converting #id values to #!id values before navigating.)
$(document).ready(function () {
if (location.hash.substr(0,2) == "#!") {
@kwhinnery
kwhinnery / howto.md
Created May 13, 2013 00:42
Execute "tishadow run" in your Titanium app directory whenever a JavaScript file changes.

Automatic TiShadow Installs

Execute "tishadow run" in your Titanium app directory whenever a JavaScript file changes. Edit your JS files in a text editor, save, then switch to the test device or simulator. Profit.

Install supervisor

[sudo] npm install -g supervisor

Execute tishadow run anytime a JavaScript file changes

@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.
@FokkeZB
FokkeZB / VALIDATE.md
Last active December 16, 2015 22:39
Validation lib for Titanium
@FokkeZB
FokkeZB / ALERT.md
Created May 3, 2013 11:06
Replacement for Titanium's alert()

I guess just like me you like to do alert('My message'); instead of:

Ti.UI.createAlertDialog({
        message: 'My message'
}).show();

But I'd even more like to do alert('My message', 'My title', myCallback); instead of:

@FokkeZB
FokkeZB / CROP.md
Created May 2, 2013 09:43
Image (cropping) CommonJS lib for Titanium

Often I need to display a user-provided picture in an ImageView in such a way that the whole ImageView is filled with as much of the picture possible.

This is how I do it:

var image = require('image');

Ti.Media.showCamera({
        mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO],
 success: function (e) {
@FokkeZB
FokkeZB / UPDATE.md
Last active August 23, 2017 16:26
Update lib for Titanium

I like easy drop-in CommonJS libraries that need minimal configuration to perform common tasks.

This CommonJS library checks with Apple every X days to see if there's a new version available. If so, it asks the user if he/she would like to update and then opens the app in the App Store.

At minimum, the library requires no configuration at all and just a single line of code.

Look at advanced.js for all available options and methods.

Also check out my rating library:

@FokkeZB
FokkeZB / RATING.md
Last active December 16, 2015 16:49
Rate-my-app CommonJS module for Titanium
@FokkeZB
FokkeZB / SHARING.md
Last active December 16, 2015 15:49
Sharing lib for Titanium