Skip to content

Instantly share code, notes, and snippets.

View benbahrenburg's full-sized avatar

Ben Bahrenburg benbahrenburg

View GitHub Profile
@viezel
viezel / build-module-android.sh
Last active August 29, 2015 14:01
Build and copy android module
##
## Build an Appcelerator Android Module
## Then copy it to the default module directory
##
## (c) Napp ApS
## Mads Møller
##
## HOW TO GUIDE
@mattapperson
mattapperson / Instructions
Last active August 29, 2015 14:05
CommonJS Controllers for alloy
In your Alloy project, add the alloy.jmk file to the app folder and create a directory called template, in the template directory, add the component.js file. Then simply start building your alloy apps with commonjs style controller.
Want to require in another controller? simply access it like this:
var otherController = require('otherController').class;
Events are now namespaced to the `C` variable for views.
@jonalter
jonalter / app.js
Created May 3, 2011 17:44
Creating Reusable Factories and Using Ti.App with a Namespace
// Please note that this is a dirty solution.
// It does work, but Appcelerator does not support it (adding things to the Ti namespace).
// There is a very good chance that it will not be possible in future releases.
var ui = {};
var labels = {};
Ti.include('ui.js');
Ti.include('labels.js');
@MorningZ
MorningZ / helpful_prototypes.js
Created May 6, 2011 05:16
Helpful JavaScript prototypes!
/*********************************************/
/* Prototypes that work against primitives */
/*********************************************/
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); };
String.prototype.contains = function(t) { return this.indexOf(t) >= 0 ? true : false; };
String.prototype.beginsWith = function(t, i) { if (i == false) { return (t == this.substring(0, t.length)); } else { return (t.toLowerCase() == this.substring(0, t.length).toLowerCase()); } };
String.prototype.endsWith = function(t, i) { if (i == false) { return (t == this.substring(this.length - t.length)); } else { return (t.toLowerCase() == this.substring(this.length - t.length).toLowerCase()); } };
Object.prototype.merge = (function (ob) {var o = this;var i = 0;for (var z in ob) {if (ob.hasOwnProperty(z)) {o[z] = ob[z];}}return o;});
/* Examples:
@pec1985
pec1985 / deleterow.js
Created June 10, 2011 01:35
delete a row in a table view in android
var win = Ti.UI.createWindow({
backgroundColor:'#ccc'
});
// create the table view
var tableView = Ti.UI.createTableView({});
// create an empty array
var data = [];
// this is the alert message + deleting the row from the array
function confirmDel(rowId,rowName) {
@pec1985
pec1985 / app.js
Created June 13, 2011 17:43
Simple Single-Context app
// namespace for the windows
var W = {};
// namespace for custom UI
var UI = {};
// store the tabs in this array for later use
var tabs = [];
// include the necessary files to run the app
Ti.include('ui.js');
Ti.include('other.js');
Ti.include('window1.js');
@pec1985
pec1985 / app.js
Created July 22, 2011 23:50
Scroll to position - iOS - Appcelerator
var win = Ti.UI.createWindow({
title:'Row #50'
});
var buttonBar = Ti.UI.createButtonBar({
labels:['top','middle','bottom']
});
win.rightNavButton = buttonBar;
@kwhinnery
kwhinnery / flow.md
Created August 11, 2011 21:27
Secure Web API Flow

A Rough Flow for a simple, secure web API

  • Step One: Third party app developer (hereafter "the app") registers an application with the service provider (called here and afterwards "the service provider"), like Twitter or Gimme Bar. The app receives an API key, where it is made explicitly clear that storing username/password combinations is not necessary and is a violation of the terms of service for the API.

  • Step Two: Over SSL/TLS, the app exchanges a username/password combination given to them by the end user, and provides it to the service provider, along with their API key in exchange for an access token.

####But wait, isn't that insecure? Why is the user giving you their password? oAuth prevents this!!!!

If the app is a malicious mobile or desktop application, the app can very easily steal your password if desired - the app can redirect you to a "web browser", which it controls, and steal your username and password if the app is a dick. This is only one avenue of several a malicious app

@bob-sims
bob-sims / 00-readme.txt
Created November 28, 2011 22:28
CommonJS module to pull XML response from from (undocumented) Google Weather API, for use with Titanium Mobile
// console dump of sample returned object
I/TiAPI ( 244): (kroll$4: app://app.js) [797,3312] Object
I/TiAPI ( 244): {
I/TiAPI ( 244): weatherData => Object
I/TiAPI ( 244): {
I/TiAPI ( 244): forecastInfo => Object
I/TiAPI ( 244): {
I/TiAPI ( 244): city => 'Bydgoszcz, Kuyavian-Pomeranian Voivodeship',
@pec1985
pec1985 / app.js
Created December 30, 2011 17:21
LinkedIn effect - Titanium
// right navigation button
var btn = Ti.UI.createButton({
title:'button'
});
// window
var win = Ti.UI.createWindow({
rightNavButton:btn,
backgroundColor:'blue'
});