Skip to content

Instantly share code, notes, and snippets.

@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:
//
@jdarling
jdarling / Object.observe.poly.js
Created November 30, 2012 02:00
Initial Object.observe polyfill/shim trying to be compliant
/*
Migrated to: https://github.com/jdarling/Object.observe
Tested against Chromium build with Object.observe and acts EXACTLY the same,
though Chromium build is MUCH faster
Trying to stay as close to the spec as possible,
this is a work in progress, feel free to comment/update
http://wiki.ecmascript.org/doku.php?id=harmony:observe
@pec1985
pec1985 / app.js
Last active October 13, 2015 06:48
Zoomable image
var win = Ti.UI.createWindow();
var images = [];
for(var i = 1; i < 100; i++){
// Assuming all the images are called image1.jpg, image2.jpeg, etc...
images.push('/images/image'+i+'.jpg');
}
var gallery = Gallery(images,0);
@rborn
rborn / AndroidManifest.xml
Created October 12, 2012 21:22 — forked from skypanther/AndroidManifest.xml
Android 4 theme and menu
<?xml version="1.0" ?><manifest android:versionCode="1" android:versionName="1" package="com.appcelerator.foo" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="8"/>
<uses-sdk android:targetSdkVersion="14"/>
<!-- TI_MANIFEST -->
<application android:debuggable="false" android:icon="@drawable/appicon" android:label="Foo" android:name="FooApplication" android:theme="@android:style/Theme.Holo.Light">
<!-- TI_APPLICATION -->
@rborn
rborn / gist:3881465
Created October 12, 2012 20:57 — forked from IvanMathy/gist:2863986
A simple Drag, Drop and Resize for Titanium Mobile. (@Thedeejay92 - Mousta.ch )
/*
* I made this code for an upcoming hackaton, so, it's really, really ugly. Feel free
* to update it here so everyone will be able to use it correctly.
*
* It's pretty easy to understand, basicly the object you want to edit, an overlay,
* four handlers, and the background view.
*
* It's currently made for/tested on iPad 5.0 with Timob 2.0.2; works only in landscape.
*
* This code is under the Moustach licence. This means you can do whatever you want with
@rborn
rborn / gist:3878280
Created October 12, 2012 09:19 — forked from kosso/gist:3877780
Making sure people log out of web-authed apps.
- (void)clearWebViewCookies:(NSMutableArray*)cleardomain
{
NSLog(@"[INFO] called webView clearWebViewCache to clear : %@", [cleardomain objectAtIndex:0]);
for(NSHTTPCookie *cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) {
//NSLog(@"[INFO] cookie for : %@",[cookie domain]);
if([[cookie domain] isEqualToString:[cleardomain objectAtIndex:0]]) {
//NSLog(@"[INFO] deleting cookie for : %@",[cookie domain]);
[[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
}
}
@kosso
kosso / gist:3877780
Created October 12, 2012 07:24
Making sure people log out of web-authed apps.
- (void)clearWebViewCookies:(NSMutableArray*)cleardomain
{
NSLog(@"[INFO] called webView clearWebViewCache to clear : %@", [cleardomain objectAtIndex:0]);
for(NSHTTPCookie *cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) {
//NSLog(@"[INFO] cookie for : %@",[cookie domain]);
if([[cookie domain] isEqualToString:[cleardomain objectAtIndex:0]]) {
//NSLog(@"[INFO] deleting cookie for : %@",[cookie domain]);
[[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
}
}
@rborn
rborn / examples.js
Created October 4, 2012 20:21 — forked from rblalock/examples.js
sample patterns
/**
* Javascript example patterns
*/
/**
* Singleton Object
* Should be used for global, static objects. You should not place memory
* intensive items in here unless they are meant to be used throughout the application
* at anytime. If the item is meant to be reused or instantiated multiple times
* a singleton should not be used.
@raulriera
raulriera / ImageHelper.js
Created October 3, 2012 02:04
Load iPhone5 retina graphics
// I am pretty sure there is a sexier approach, but this works nicely
var isPhone5 = Ti.Platform.displayCaps.platformHeight == 568;
parse568hImages = function(imagePath) {
if (isPhone5){
// Do this because the filename could contain dots
imagePath = imagePath.replace(".png","[email protected]");
imagePath = imagePath.replace(".jpg","[email protected]");
imagePath = imagePath.replace(".jpeg","[email protected]");
}
@aaronksaunders
aaronksaunders / InstagramMgr.js
Created September 30, 2012 19:02
Titanium Appcelerator Instagram Code ... This code is almost two years old and I havent tested it in a while
/**
*
* this code was inspired by the work done by David Riccitelli
*
* Copyright 2011 Aaron K. Saunders, Clearly Innovative Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*