Skip to content

Instantly share code, notes, and snippets.

View joshualambert's full-sized avatar
🎧

Josh Lambert joshualambert

🎧
View GitHub Profile
@joshualambert
joshualambert / gist:ba5d6bbe98bc9b8124e8a04648df9d20
Created October 20, 2017 13:33
Titanium Navigation Function
// Used to prompt a user for how to open an address, or open automatically, based on the platform.
function openAddress(destAddr, startAddr) {
var destParam = '';
var startParam = '';
if (typeof destAddr !== 'undefined') {
destParam = '&daddr=' + encodeURIComponent(destAddr);
}
if (typeof startAddr !== 'undefined') {
startParam = '&saddr=' + encodeURIComponent(startAddr);
}
@joshualambert
joshualambert / bitly.js
Last active September 29, 2017 21:51
Titanium BitLy CommonJS Library
/*
* Used to interact with the Bit.LY API.
* Written by: Josh Lambert
* Twitter: @zettageek
* Email: hi@centrevilletech.com
* Version: 1.0
*/
var apiKey,
apiVersion = 'v3',
@joshualambert
joshualambert / hintTextShim
Created January 2, 2014 16:44
hintText shim for Appcelerator's Titanium allowing hintText to be colored. Simply call this function after creating each textfield, and pass the option isPswd boolean if you're dealing with a password field.
// Used to fake hintText coloring to the font color.
// Requires hintText to be defined on the object being passed.
function hintTextShim(uiObject, isPswd) {
uiObject.objectFocus = function () {
if (uiObject.value === uiObject.hintText) {
if (typeof isPswd !== 'undefined' && isPswd === true) {
uiObject.passwordMask = true;
}
uiObject.value = '';
}
$query = mysqli_query($connection,"INSERT INTO `child_menu_details` (`id`, `parent_id`, `child_id`, `date`, `lunch`, `side1`, `side2`, `side3`, `side4`, `size`, `smoothie`, `orderDate`)
VALUES (NULL, '".$parentid."', '".$childid."', '".$date."' ,'".$lunch."', '".$side1."', '".$side2."', '".$side3."', '".$side4."', '".$size."', '".$smoothie."', '".$orderDate."')");
function dump(arr,level) {
var dumped_text = "";
if(!level) level = 0;
//The padding given at the beginning of the line.
var level_padding = "";
for(var j=0;j<level+1;j++) level_padding += " ";
if(typeof(arr) == 'object') { //Array/Hashes/Objects
for(var item in arr) {
var mainWindow = Ti.UI.createWindow();
var myView = Ti.UI.createView({
width:500,
height:500,
left:-500,
backgroundColor:blue
});
mainWindow.add(myView);
@joshualambert
joshualambert / gist:4347159
Created December 20, 2012 17:47
time_since() - Time comparison function for PHP.
/*
* Originally written by: billythekid.
* https://twitter.com/billythekid
*
* Modified by: Joshua Lambert.
* https://twitter.com/zettageek
*
* Changelog:
* - Added array output.
* - Added ability to pass in custom end timestamp.
@joshualambert
joshualambert / gist:4273022
Created December 13, 2012 00:32
Storekit Purchase Issue
--------------------------------------------------
Code
--------------------------------------------------
AppContext.Storekit.requestProducts(['com.testproduct.lite.pm1'], function (evt) {
displayLog(JSON.stringify(evt));
if (!evt.success) {
alert('ERROR: We failed to talk to Apple!');
}
else if (evt.invalid) {
@joshualambert
joshualambert / gist:4270844
Created December 12, 2012 19:35
Ti.storekit Verification Issue
[INFO] One moment, building ...
[INFO] Detected third-party module: ti.storekit/1.6.1
[INFO] Detected third-party module: ti.storekit/1.6.1
[INFO] Titanium SDK version: 2.1.3 (10/02/12 16:16 15997d0)
[INFO] iPhone Device family: iphone
[INFO] iPhone SDK version: 5.0
[INFO] iPhone simulated device: iphone
[INFO] Performing full rebuild. This will take a little bit. Hold tight...
[INFO] Minimum iOS version: 4.0 Linked iOS Version 5.0
[INFO] Performing clean build
@joshualambert
joshualambert / gist:4128161
Created November 21, 2012 22:03
Switch loop
followMeSwtichCheckbox.eventOverride = false;
followMeSwtichCheckbox.addEventListener('change', function(e) {
if (followMeSwtichCheckbox.eventOverride == false) {
if (checkSOSactive() == false) {
alert('SOS inactive.');
} else {
followMeSwtichCheckbox.eventOverride = true;
if (followMeSwtichCheckbox.value == true) {
followMeSwtichCheckbox.value = false;