Skip to content

Instantly share code, notes, and snippets.

View wackyapps's full-sized avatar
🎯
Focusing

Waqas Mahmood Khan wackyapps

🎯
Focusing
  • Itelc
  • Pakistan
View GitHub Profile
Ti.Geolocation.getCurrentPosition(function(evt) {
var origin = String(evt.coords.latitude + ',' + evt.coords.longitude),
travelMode = 'walking',
destination = String(yourLatitude + ',' + yourLongitude),
url = "http://maps.google.com/maps/api/directions/xml?mode="
+ travelMode + "&origin="
+ origin + "&destination="
+ destination +"&sensor=false";
xhr = Titanium.Network.createHTTPClient();
xhr.open('GET',url);
function decodeLine(encoded) {
var len = encoded.length;
var index = 0;
var array = [];
var lat = 0;
var lng = 0;
while (index < len) {
var b;
var shift = 0;
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.
@wackyapps
wackyapps / app.js
Created June 17, 2016 00:46 — 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() {
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
var rotate = Ti.UI.create2DMatrix().rotate(90);
var counterRotate = rotate.rotate(-180);
var scrollView = Titanium.UI.createScrollableView({
views:[
Titanium.UI.createImageView({ image:'default_app_logo.png', transform: counterRotate }),
Titanium.UI.createImageView({ image:'KS_nav_ui.png', transform: counterRotate }),
Titanium.UI.createImageView({ image:'KS_nav_views.png', transform: counterRotate })
@wackyapps
wackyapps / Ti-touches.js
Created June 17, 2016 00:47 — forked from tripitakit/Ti-touches.js
Appcelerator Titanium touch events usage example: connecting a blue box to a red box with a touch and finger slide.
/***
* Connects the blue box to the red box with touch and finger slide.
* The window's backgroundColor and the label's text give feedback to the user.
* ... the blue box is not going to move anywhere
*
* @Copyleft 2013 Patrick De Marta
* @License GNU GPL
*/
/**
@wackyapps
wackyapps / Ti-touches.js
Created June 17, 2016 00:47 — forked from tripitakit/Ti-touches.js
Appcelerator Titanium touch events usage example: connecting a blue box to a red box with a touch and finger slide.
/***
* Connects the blue box to the red box with touch and finger slide.
* The window's backgroundColor and the label's text give feedback to the user.
* ... the blue box is not going to move anywhere
*
* @Copyleft 2013 Patrick De Marta
* @License GNU GPL
*/
/**
@wackyapps
wackyapps / google_autocomplete_table.js
Created June 30, 2016 14:50 — forked from undernewmanagement/google_autocomplete_table.js
Appcelerator titanium google places autocomplete
//AUTOCOMPLETE TABLE
var table_data = [];
var last_search = null;
var timers = [];
// NOTE: iOS and Android keys will be different!
var IOS_API_KEY = 'xxx__APIKEY___xxx';
var ANDROID_API_KEY = '';
@wackyapps
wackyapps / physical_size.js
Created July 12, 2016 14:13 — forked from manumaticx/physical_size.js
Function to calculate display size as inches on android for Appcelerator Titanium with the help of https://github.com/dbankier/HasMenu
/**
* Calculates the physical display size for android devices
* e.g 4,95 for Nexus 5 or 7,02 for Nexus 7
*
* IMPORTANT: this requires https://github.com/dbankier/HasMenu
*
* @return {Number} size as inches
*/
function getPhysicalSize(){
// some infos we need
@wackyapps
wackyapps / gist:bc35919a7835e10ecfa3dcbc0e7d63cf
Created July 25, 2016 19:50 — forked from prime31/gist:5675017
Simple PHP script showing how to send an Android push notification. Be sure to replace the API_ACCESS_KEY with a proper one from the Google API's Console page. To use the script, just call scriptName.php?id=THE_DEVICE_REGISTRATION_ID
<?php
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'YOUR-API-ACCESS-KEY-GOES-HERE' );
$registrationIds = array( $_GET['id'] );
// prep the bundle
$msg = array