Skip to content

Instantly share code, notes, and snippets.

View joshjensen's full-sized avatar

Josh Jensen joshjensen

View GitHub Profile
@joshjensen
joshjensen / alloy.py
Last active November 30, 2016 18:25
Alloy Grid - Open Alloy controllers, views, and styles in Sublime Text grid layout.
# Version: 0.0.022
# Please note: This has only been tested on Sublime Text 3 Build 3065
# Installation:
# 1. Click "Download Gist"
# 2. Put alloy.py in: ~/Library/Application Support/Sublime Text 3/Packages/User/
# 3. Set your layout to Grid 4 - Go to view > layout > Grid: 4
# 4. Add to the bliss of working with Alloy...
@joshjensen
joshjensen / push.js
Created May 28, 2014 13:39
Sample Push Handler.
CloudPush.retrieveDeviceToken({
success: function(_data) {
Ti.API.info("ACS.init @success");
exports.deviceToken = _data.deviceToken;
Ti.App.Properties.setString("PUSH_DEVICETOKEN", _data.deviceToken);
CloudPush.addEventListener('callback', function (evt) {
if (appActive) {
@joshjensen
joshjensen / bizcard.js
Created April 24, 2014 16:32
Business Card
#!/bin/env node
var util = require("util");
var jediMindTrick = function(details) {
util.print("This is the developer you are looking for: \n");
for (var key in details) {
if (details.hasOwnProperty(key)) {
util.print(key + ": " + details[key] + "\n");
}
@joshjensen
joshjensen / viewer.js
Created April 17, 2014 18:37
Android Intents PDF Viewer
// Found here: https://developer.appcelerator.com/question/72361/open-pdf-file-on-android
try {
var f = Ti.Filesystem.getFile('your.pdf');
Ti.Android.currentActivity.startActivity(Ti.Android.createIntent({
action: Ti.Android.ACTION_VIEW,
type: 'application/pdf',
data: f.getNativePath()
}));
}
@joshjensen
joshjensen / app.js
Last active August 29, 2015 13:59
Titanium PDF Viewer
var pdfUrl = "http://www.irs.gov/pub/irs-pdf/fw4.pdf";
Ti.Platform.openURL("https://docs.google.com/gview?embedded=true&url=" + Ti.Network.encodeURIComponent(pdfUrl));
@joshjensen
joshjensen / app.js
Last active August 29, 2015 13:55
PubNub Demo
// ----------------------------------
// INIT PUBNUB
// ----------------------------------
var pubnub = require('/lib/pubnub')({
publish_key : '--PUBKEY--',
subscribe_key : '--SUBKEY--',
ssl : true,
origin : 'pubsub.pubnub.com'
});
function deviceTokenSuccess(e) {
Ti.API.info('Device Token: ' + e.deviceToken);
deviceTokenLabel.text = 'Device Token:' + e.deviceToken;
enablePush.enabled = true;
var Cloud = require("ti.cloud");
Cloud.PushNotifications.subscribeToken({
device_token: APP.Push.deviceToken,
channel: "test,
type: Ti.Platform.name === 'android' ? 'android' : 'ios'
@joshjensen
joshjensen / Count.ly Titanium Instructions
Last active December 16, 2015 08:18
Cross-platform Appcelerator Titanium example for Count.ly
Install required modules
Android - https://github.com/shivakumars/Titanium-Android-Count.ly/blob/master/dist/ly.count-android-0.1.zip
iOS - https://github.com/euforic/Titanium-Count.ly/blob/master/count.ly-iphone-0.2.1.zip
To use the modules you can use this example:
var countly = require('analytics');
countly.event({
name: 'App | Installed'
});
@joshjensen
joshjensen / set_simulator.applescript
Created November 20, 2012 14:20
Switch iOS Simulators
set selectedDevices to {"iPhone (Retina 3.5-inch)"}
if selectedDevices is not false then
set selectedDevice to item 1 of selectedDevices as string
set thePListFolderPath to path to preferences folder from user domain as string
set thePListPath to thePListFolderPath & "com.apple.iphonesimulator.plist"
tell application "System Events"
tell property list file thePListPath
tell contents
set value of property list item "SimulateDevice" to selectedDevice
@joshjensen
joshjensen / index.php
Created May 7, 2012 17:26
Pull Images and Return JSON Array
<?php
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json;');
$file_array = array();
if ($handle = opendir('.')) {
while (false !== ($entry = readdir($handle))) {