Skip to content

Instantly share code, notes, and snippets.

Avatar

Ben Bahrenburg benbahrenburg

View GitHub Profile
@viezel
viezel / build-module-android.sh
Last active Aug 29, 2015
Build and copy android module
View build-module-android.sh
##
## 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 Aug 29, 2015
CommonJS Controllers for alloy
View Instructions
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
Creating Reusable Factories and Using Ti.App with a Namespace
View app.js
// 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
Helpful JavaScript prototypes!
View helpful_prototypes.js
/*********************************************/
/* 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 Jun 10, 2011
delete a row in a table view in android
View deleterow.js
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 Jun 13, 2011
Simple Single-Context app
View app.js
// 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 Jul 22, 2011
Scroll to position - iOS - Appcelerator
View app.js
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 Aug 11, 2011
Secure Web API Flow
View flow.md

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 Nov 28, 2011
CommonJS module to pull XML response from from (undocumented) Google Weather API, for use with Titanium Mobile
View 00-readme.txt
// 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 Dec 30, 2011
LinkedIn effect - Titanium
View app.js
// right navigation button
var btn = Ti.UI.createButton({
title:'button'
});
// window
var win = Ti.UI.createWindow({
rightNavButton:btn,
backgroundColor:'blue'
});