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
@iantearle
iantearle / alloy.js
Created September 9, 2013 15:02
BasicGeo where its not starting location services on iOS7 with v0.86
var geo = require('bencoding.basicgeo');
Alloy.Globals.geoCurrent = geo.createCurrentGeolocation();
Alloy.Globals.geoCoder = geo.createGeocoder();
Alloy.Globals.helpers = geo.createHelpers();
@iantearle
iantearle / app.js
Created June 11, 2013 09:33
Testing out my Appcelerator Titanium app on iOS7 and I appear to have an issue with the remote back up flag.
var doNotBackUp = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory);
doNotBackUp.remoteBackup = false;
@iantearle
iantearle / forecast.io.js
Created April 18, 2013 10:41
Forecast.io javascript library. Not currently working. Functions are not waiting for xhr data to complete. I have added a proxy script to help with cross domain policies. You should be able to run everything with these files. Please help me solve this. Many thanks. You can get your own API key from https://developer.forecast.io/register.
/**
* Helper Class for forecast.io webservice
*/
function ForecastIO(api_key) {
API_ENDPOINT = 'https://api.forecast.io/forecast/';
/**
* Create a new instance
*
* @param String $api_key
function hex_sha1(s) {
return binb2hex(core_sha1(str2binb(s), s.length * chrsz));
}
function b64_sha1(s) {
return binb2b64(core_sha1(str2binb(s), s.length * chrsz));
}
function str_sha1(s) {
return binb2str(core_sha1(str2binb(s), s.length * chrsz));
@iantearle
iantearle / Existing File in Lib folder.js
Last active December 14, 2015 20:29
Alloy breaks TiFont by rewriting the javascript. See https://github.com/k0sukey/TiIconicFont/ for library
function SSSocial(options) {
switch (Ti.Platform.osname) {
case 'iphone':
case 'ipad':
this.fontfamily = 'SSSocialRegular';
break;
case 'android':
this.fontfamily = 'SSSocialRegular';
}
@iantearle
iantearle / movie.js
Created December 11, 2012 12:12
movie player to play multiple videos. Needs ability to skip.
// Application Window Component Constructor
function Movie(_u, all) {
if(all) {
var mp4_array = ['12345.m4v', 'GrandOldDuke.m4v', 'TwinkleTwinkle.m4v', 'LittleBoPeep.m4v', 'LondonBridge.m4v', 'OldMotherHubbard.m4v', 'PataCake.m4v', 'PollyPutTheKettleOn.m4v', 'RockabyeBaby.m4v', 'TwinkleTwinkle.m4v'];
_u = mp4_array[0];
}
// Create our main window
@iantearle
iantearle / GeolocationModule.mm
Created November 26, 2012 12:11 — forked from stevenou/GeolocationModule.mm
Geofencing in Titanium
// this file located in /Library/Application Support/Titanium/mobilesdk/osx/{version_number}
// add the following methods to GeolocationModule.mm
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:NUMBOOL(YES),@"success",[NSDictionary dictionaryWithObjectsAndKeys:NUMDOUBLE(region.center.latitude),@"lat",NUMDOUBLE(region.center.longitude),@"lng",NUMDOUBLE(region.radius),@"radius",region.identifier,@"identifier",nil],@"region",nil];
if ([self _hasListeners:@"enteredRegion"])
{
[self fireEvent:@"enteredRegion" withObject:event];
@iantearle
iantearle / hack.sh
Created November 15, 2012 09:32 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/4077645/hack.sh | sh
#
@iantearle
iantearle / Login.js
Created November 5, 2012 12:46
Trying to retrieve the values from username and password in Login.
//FirstView Component Constructor
function Login() {
var Title = require('ui/common/Title'),
Logo = require('ui/common/Logo');
UserPassword = require('ui/common/UserPassword');
//create object instance, a parasitic subclass of Observable
var self = Ti.UI.createView({
width: Ti.Platform.displayCaps.platformWidth - 50,
left: 50
@iantearle
iantearle / RateMe.js
Created November 1, 2012 21:28 — forked from psyked/RateMe.js
"Rate my app in Appcelerator Titanium Mobile" as a commonJS module.
function RateMe(ios_url, goog_url, usecount) {
if(!Ti.App.Properties.hasProperty('RemindToRate')) {
Ti.App.Properties.setString('RemindToRate', 0);
}
var remindCountAsInt = parseInt(Ti.App.Properties.getString('RemindToRate'), 10);
var newRemindCount = remindCountAsInt += 1;
if(remindCountAsInt === -1) {
// the user has either rated the app already, or has opted to never be
// reminded again.