Skip to content

Instantly share code, notes, and snippets.

View ewanharris's full-sized avatar

Ewan Harris ewanharris

View GitHub Profile
@ewanharris
ewanharris / app.js
Created August 23, 2017 11:14
XAML Style tests
var win = Ti.UI.createWindow({ backgroundColor: 'white' });
var lbl = Ti.UI.createLabel({text: 'label', top: 0});
var btn = Ti.UI.createButton({title: 'button', top: 50});
var sb = Ti.UI.createSearchBar({top: 150});
var view = Ti.UI.createView({top:250, width: 100, height: 100});
var style = Ti.UI.Windows.createStyle({ source: 'ms-appx:///Style.xaml' });
style.apply(lbl, 'LabelStyle');
style.apply(btn, 'ButtonStyle');
style.apply(view, 'ViewStyle');
style.apply(sb, 'SBStyle')
@ewanharris
ewanharris / app.js
Created August 29, 2017 13:28
ti.barcode example + permissions
/**
* In this example, we'll use the Barcode module to display some information about
* the scanned barcode.
*/
var Barcode = require('ti.barcode');
Barcode.allowRotation = true;
Barcode.displayedMessage = ' ';
Barcode.allowMenu = false;
Barcode.allowInstructions = false;
Barcode.useLED = true;
@ewanharris
ewanharris / app.js
Created June 29, 2018 15:12
Require URI and ID issue on iOS
const json = require('./jsonfile.json');
console.log(json);
console.log(json.id);
const foo = require('./foo');
console.log(foo);
console.log(foo.id);
const win = Ti.UI.createWindow({
backgroundColor: 'white'
});
@ewanharris
ewanharris / text.md
Created July 25, 2019 14:55
Debugging iOS connection for debugger
  1. With the simulator launched, lookup the simulator socket
    • lsof -aUc launchd_sim
  2. Look for a name that ends in com.apple.webinspectord_sim.socket, copy that.
  3. Spawn ios_webkit_debug_proxy passing in that socket prefixed with unix:
    • ios_webkit_debug_proxy -s unix:<socket from step 2>
    • It should output something like the below
$ios_webkit_debug_proxy -s unix:/private/tmp/com.apple.launchd.y7tX5zeZ81/com.apple.webinspectord_sim.socket
Listing devices on :9221
@ewanharris
ewanharris / IMPORT.md
Last active March 10, 2020 11:40 — 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.

@ewanharris
ewanharris / Tiapp Permissions.md
Last active June 25, 2021 12:09
Download and update an APK in Titanium

Add the below to your tiapp

<android xmlns:android="http://schemas.android.com/apk/res/android">
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1">
      <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
      <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
      <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    </manifest>
 
@ewanharris
ewanharris / check-module.sh
Last active January 11, 2021 08:55
Script to check Titanium modules for references to UIWebView
#!/usr/bin/env bash
FOLDER=$1
echo "Checking $FOLDER"
# Check for references to UIWebView in the build .a files using strings
for file in "$FOLDER"/*.a; do
strings "$file" | grep UIWeb > /dev/null 2>&1
if [ $? -eq 0 ]
@ewanharris
ewanharris / app.js
Created November 24, 2020 12:36
Image creation from LivePhoto
const win = Ti.UI.createWindow({ layout: 'vertical' });
const singleBtn = Ti.UI.createButton({ title: 'Select single', top: 50 });
singleBtn.addEventListener('click', () => {
selectImage(false);
});
win.add(singleBtn);
const multiBtn = Ti.UI.createButton({ title: 'Select multiple' });
multiBtn.addEventListener('click', () => {
selectImage(true);
});
@ewanharris
ewanharris / index.mjs
Last active June 9, 2021 22:49
Check for all PRs that had more than 30 commits
/**
* Requirements:
*
* node 14
* these dependencies - npm i @octokit/rest date-fns fs-extra
*/
import fs from 'fs-extra';
import { isAfter } from 'date-fns';
import Octokit from '@octokit/rest';
@ewanharris
ewanharris / app.js
Created June 28, 2021 09:26
Calendar sample iOS
const win = Ti.UI.createWindow();
function createEvent() {
let calendarId;
for (const calendar of Ti.Calendar.allCalendars) {
Ti.API.info(calendar.name, calendar.id);
// This probably is not good enough for an app, the calendar most likely should be selected by the user
if (calendar.name === 'Calendar') {
calendarId = calendar.id
}