Skip to content

Instantly share code, notes, and snippets.

View brentonhouse's full-sized avatar
🚀
Busy being awesome!

Brenton House brentonhouse

🚀
Busy being awesome!
View GitHub Profile
@brentonhouse
brentonhouse / appc_func_decode-jwt.js
Created April 29, 2020 02:19 — forked from adamtarmstrong/appc_func_decode-jwt.js
Decode JWT in Axway Titanium
/**
* token
* claim = "registered" || "public" || "private"
*/
exports.decodeJWT = function(token, claim) {
var base64Url;
if (claim == "registered") {
base64Url = token.split('.')[0];
} else if (claim == "private") {
base64Url = token.split('.')[2];
@brentonhouse
brentonhouse / ti_helper.js
Created April 29, 2020 02:18 — forked from adamtarmstrong/ti_helper.js
Titanium Helper Functions
//var tiHelper = require('ti_helper');
/*
* USAGE
* tiHelper.currency(numberToFormat,0);
*/
exports.currency = function(number, decimals, decSymbol, thousSymbol) { //number, decimal places , decimal symobl (.), thousands separator (,)
decimals = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals,
decSymbol = decSymbol == undefined ? "." : decSymbol,
// https://jira.appcelerator.org/browse/TIMOB-12291
exports.compareQueries = function () {
testCommonWay();
testGroupConcat();
};
const TEST_QUERY_EXEC_COUNT = 50;
function testCommonWay() {
@brentonhouse
brentonhouse / IMPORT.md
Created March 10, 2020 14:57 — forked from FokkeZB/IMPORT.md
Add support for @import to Alloy styles

@import TSS for Alloy

NOTE: This is out-dated, I suggest using https://github.com/dbankier/ltss instead.

This alloy.jmk adds support for using CSS-like @import "file.tss"; statements in Alloy TSS styles.

The idea for this came when discussing adding the option of including a CSS-like reset stylesheet in Alloy to make up for platform differences in (background)color, but also some good practices.

I think one of the key issues in this discussion is that there is no such thing as the base style for an app. iOS fans would like to reset to iOS-like styles, Android fans like to reset to theirs, flat UI fanatics would like everything minimalized and Bootstrap adepts will ask for a huge library of styles.

@brentonhouse
brentonhouse / CXCallObserver-example.js
Created January 29, 2020 22:40 — forked from hansemannn/CXCallObserver-example.js
CXCallObserver in Hyperloop and Titanium
var CXCallObserver = require('CallKit/CXCallObserver'); // Require native class from CallKit
var CallDelegate = require('callDelegate'); // Require delegate class from app/lib/ (Alloy) or Resources/ (Classic)
var myDelegate = new CallDelegate(); // Instantiate Delegate
myDelegate.callChanged = function (callObserver, call) {
if (call.hasConnected) {
Ti.API.info('********** voice call connected **********\n');
} else if(call.hasEnded) {
Ti.API.info('********** voice call disconnected **********/n');
}
@brentonhouse
brentonhouse / deep-linking-manager.js
Created January 29, 2020 22:35 — forked from hansemannn/deep-linking-manager.js
Titanium Deep Linking Manager (iOS)
export default class DeepLinkingManager {
constructor () {
this.handledLinks = {};
this.activityType = 'io.lambus.app.universalLink';
const activity = Ti.App.iOS.createUserActivity({
activityType: this.activityType
});
@brentonhouse
brentonhouse / ti.speech.example.js
Created November 28, 2019 03:59 — forked from hansemannn/ti.speech.example.js
Realtime Speech Recognition in Titanium
var TiSpeech = require('ti.speech');
TiSpeech.initialize('en_US'); // locale is optional
var win = Ti.UI.createWindow({
backgroundColor: '#fff'
});
var currentValue = '';
@brentonhouse
brentonhouse / push-manager.js
Created November 28, 2019 03:56 — forked from hansemannn/push-manager.js
Handle iOS push notifications in Appcelerator Titanium
import FirebaseMessaging from 'firebase.cloudmessaging';
export default class PushManager {
listenForPushNotifications() {
// Called when the Firebase token is ready
FirebaseMessaging.addEventListener('didRefreshRegistrationToken', event => {
const fcmToken = event.fcmToken;
// Update push token here …
@brentonhouse
brentonhouse / resetsims.js
Created October 29, 2019 15:30 — forked from cb1kenobi/resetsims.js
Resets all iOS, watchOS, and tvOS simulators
'use strict';
const execSync = require('child_process').execSync;
const json = JSON.parse(execSync('xcrun simctl list --json'));
for (const runtime of Object.keys(json.devices)) {
for (const device of json.devices[runtime]) {
console.log(`Removing ${device.name} (${device.udid})`);
execSync(`xcrun simctl delete ${device.udid}`);
}
@brentonhouse
brentonhouse / Components.js
Created September 19, 2019 14:21 — forked from zo0m/Components.js
Custom tags in go-od
const createFunctionsSet = {};
function buildCreatorFor(tagName, controllerName) {
const createFuntionName = `create${tagName}`;
createFunctionsSet[createFuntionName] = function (args) {
return Alloy.createController(controllerName, args).getView();
}
}
buildCreatorFor('BaseWindow', 'components/common/base-window/BaseWindow');