Skip to content

Instantly share code, notes, and snippets.

var player = Ti.Media.createSound({url:"/sound.mp3"});
player.play();
define(["Ti/_/Evented", "Ti/_/lang"], function(Evented, lang) {
return lang.setObject("Ti.Media", Evented, {
constants: {
UNKNOWN_ERROR: 0,
DEVICE_BUSY: 1,
NO_CAMERA: 2,
NO_VIDEO: 3,
@troscoe
troscoe / purchase.js
Last active December 16, 2015 06:19
singleton model for #tialloy InApp purchases for iOS using StoreKit module
var Storekit = require('ti.storekit');
Storekit.receiptVerificationSandbox = true;
Storekit.receiptVerificationSharedSecret = "********************************";
var verifyingReceipts = false;
exports.definition = {
config: {
"columns": {
@troscoe
troscoe / app.js
Last active December 16, 2015 10:48 — forked from FokkeZB/app.js
/* /Resources/app.js - Generated by Alloy, here to understand the flow */
var Alloy = require("alloy"), _ = Alloy._, Backbone = Alloy.Backbone;
Alloy.createController("index");
<ListView id="login_table_view" class="table">
<Templates>
<ItemTemplate name="email_template">
<TextField id="email" hintText="Email" onFocus="handleFocus" onBlur="handleBlur" onReturn="focusPassword" onChange="checkTextField" />
</ItemTemplate>
<ItemTemplate name="password_template">
<TextField id="password" hintText="Password" passwordMask="true" onFocus="handleFocus" onBlur="handleBlur" onReturn="attemptLogin" onChange="checkTextField" />
</ItemTemplate>
</Templates>
<ListSection>
@troscoe
troscoe / app.js
Created May 7, 2013 21:30
Track App Opens with @parseit using Javascript and #appceleartor #titanium
var xhr = Ti.Network.createHTTPClient();
xhr.open("POST", "https://api.parse.com/1/events/AppOpened", true);
xhr.setRequestHeader("X-Parse-Application-Id", "your application id");
xhr.setRequestHeader("X-Parse-REST-API-Key", "your REST API key");
xhr.setRequestHeader("Content-Type", "application/json");
var d = JSON.stringify({});
xhr.send(d);
var questions = Alloy.Collections.questions;
var exam = Alloy.createModel("exam", {
type: type,
date: moment().format('YYYY-MM-DD'),
length: num_questions,
location: 0,
time: time,
started: 0,
progress: 0,
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
${ti_header}
<title>${project_name | h,trim}</title>
<meta name="description" content="${app_description | h,trim}">
<meta name="author" content="${app_publisher | h,trim}">
<meta name="generator" content="${ti_generator | h,trim}">
@troscoe
troscoe / alloy.js
Created September 9, 2013 18:29 — forked from FokkeZB/alloy.js
// For iOS7 only, set the window's top to 20 so they start under the status bar.
Alloy.Globals.windowTop = (OS_IOS && parseInt(Ti.Platform.version[0], 10) >= 7) ? 20 : 0;
// Optionally set the backgroundColor or backgroundImage to show behind the statusbar.
// Please note that the backgroundImage will cover the full screen, but only top 20px is visible.
// Ti.UI.backgroundColor = '#555';
// Ti.UI.backgroundImage = 'statusBar_bg.png';
@troscoe
troscoe / aws-ec2-linux-php7-quick-script.sh
Created March 24, 2016 14:39
Install PHP 7 on AWS EC2 Linux Instance
sudo su
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
yum install -y php70w php70w-opcache php70w-cli php70w-gd php70w-intl php70w-mbstring php70w-mysql php70w-pdo php70w-soap php70w-xml php70w-xmlrpc php70w-pspell php70w-mcrypt
yum install -y aspell aspell-en cvs memcached mysql mysql-server mod22_ssl
sudo /sbin/chkconfig mysqld on
sudo /sbin/service mysqld start
sudo /sbin/chkconfig httpd on
sudo /sbin/service httpd start
mysql_secure_installation