Skip to content

Instantly share code, notes, and snippets.

View stephenfeather's full-sized avatar

Stephen Feather stephenfeather

View GitHub Profile
@stephenfeather
stephenfeather / app.js
Created February 20, 2012 16:48 — forked from dawsontoth/app.js
Rate my app in Appcelerator Titanium Mobile
/**
* The following snippet will ask the user to rate your app the second time they launch it.
* It lets the user rate it now, "Remind Me Later" or never rate the app.
*/
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
win.addEventListener('open', checkReminderToRate);
win.add(Ti.UI.createLabel({ text: 'This is a simple app that will remind you to rate it.' }));
win.open();
function checkReminderToRate() {
@stephenfeather
stephenfeather / tracer.js
Created June 1, 2012 23:41 — forked from jeffbonnes/tracer.js
A tracer object to Titanium Mobile to show elapsed time and memory usage
/**
* Courtesy of Jeff Bonnes
* http://www.titaniumdevelopment.com.au/blog/2011/09/12/debugging-ipad-performance-and-memory-usage/
*/
/**
* Modified to a commonJS format by Stephen Feather
* Usage:
* var Tracer = require('/lib/tracer');
@stephenfeather
stephenfeather / analytics.js
Created June 2, 2012 18:09
commonJS version of Roger Chapman's Google Analytics Library for Appcelerator's Titanium Mobile SDK
/*
The MIT License
Copyright (c) 2010 Roger Chapman
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@stephenfeather
stephenfeather / parse.js
Last active May 28, 2024 15:03
Quick library for using the Parse REST API within Appcelerator's Titanium. Building it out as I need different pieces of the API.
// Copyright Stephen Feather and other contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
@stephenfeather
stephenfeather / ImageProcessor.js
Created January 4, 2013 12:19
Module that uses the ti.imagefactory module to resize images.
/*jslint vars: true, sloppy: true, nomen: true, maxerr: 1000 */
function ImageProcessor(imagePath){
//if (Ti.App.Properties.getInt('CompressImages') === 1){
var ImageFactory = require('ti.imagefactory');
Ti.API.info('Compressing and Resizing Image');
var tempFile = Ti.Filesystem.getFile(imagePath);
var imageBlob = tempFile.read();
@stephenfeather
stephenfeather / waze.js
Last active August 24, 2017 19:15
Appcelerator Titanium module for Waze
// Copyright Stephen Feather and other contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
@stephenfeather
stephenfeather / LatLon.js
Last active November 14, 2018 18:00
GeoTools we use in Appcelerator Titanium (sourced from Chris Veness) http://www.movable-type.co.uk/scripts/latlong.html
/*jslint vars: true, sloppy: true, nomen: true, maxerr: 1000 */
function LatLon(lat, lon, rad) {
if (typeof(rad) == 'undefined') rad = 6371; // earth's mean radius in km
// only accept numbers or valid numeric strings
this._lat = typeof(lat)=='number' ? lat : typeof(lat)=='string' && lat.trim()!='' ? +lat : NaN;
this._lon = typeof(lon)=='number' ? lon : typeof(lon)=='string' && lon.trim()!='' ? +lon : NaN;
this._radius = typeof(rad)=='number' ? rad : typeof(rad)=='string' && trim(lon)!='' ? +rad : NaN;
}
// ==UserScript==
// @name Ingress Player Locations
// @description Shows player locations on the Ingress Intel Map
// @version 1.2
// @match http://www.ingress.com/intel
// @run-at document-start
// ==/UserScript==
function override() {
@stephenfeather
stephenfeather / validation.js
Created May 12, 2013 15:21
Simple validation and typing functions
exports.trim = function(s) {
//alert('hi');
var l = 0;
var r = s.length - 1;
while (l < s.length && s[l] == ' ') {
l++;
}
while (r > l && s[r] == ' ') {
r -= 1;
}
@stephenfeather
stephenfeather / app.js
Last active December 29, 2015 11:59
Sample code for Richard Olenick in answer to http://developer.appcelerator.com/question/159878/trying-to-switch-windows-with-use-of-a-button-click#comment-195523 assumes all these files are in Resources/
var Login = require('loginScreen');
var loginPage = new Login();
loginPage.open();