Skip to content

Instantly share code, notes, and snippets.

View MLKrisJohnson's full-sized avatar

Kris Johnson MLKrisJohnson

View GitHub Profile
@MLKrisJohnson
MLKrisJohnson / README.md
Last active March 10, 2020 16:04
Instructions for changing a new Xcode 11 app so it will run on iOS 9.0

Making A Simple App with Xcode 11 That Will Run in iOS 9+

If you create a new iOS Single View App project in Xcode 11, the generated boilerplate code is not compatible with iOS versions earlier than iOS 13, because it assumes the new SceneDelegate API is available.

What follows are the steps needed to make the application compatible with iOS 9 and later.

For a Swift app:

  • In the target's General properties, set the deployment target to iOS 9.0.
  • Remove the SceneDelegate.swift file from the project.
@MLKrisJohnson
MLKrisJohnson / Set Terminal Background Colors.applescript
Created December 11, 2019 18:55
AppleScript that sets background colors of terminal windows to different colors, for easier identification
-- Set background colors of terminal windows to different colors, for easier identification
tell application "Terminal"
set window_colors to {¬
{8192, 0, 0}, ¬
{0, 8192, 0}, ¬
{0, 0, 8192}, ¬
{4096, 4096, 0}, ¬
{0, 4096, 4096}, ¬
{4096, 0, 4096}, ¬
@MLKrisJohnson
MLKrisJohnson / Tail Services Log.applescript
Created November 27, 2019 19:35
AppleScript that directs Terminal to tail a log file and apply a filter to it.
-- Opens a new terminal window displaying MobileLabs.DeviceConnect.Services.log
-- Relies on these definitions in ~/.bashrc:
--
-- alias filter-mllog='sed -e '\''s/MobileLabs/ML/g'\'' -e '\''s/DeviceConnect/DC/g'\'' -e '\''s/AirStream/AS/g'\'' -e '\''s/Gateway/Gw/g'\'' -e '\''s/Services/Sv/g'\'' -e '\''s/Framework/Fw/g'\'
-- alias tail-services='tail -F /Users/kris/.dcdata/Logs/MobileLabs.DeviceConnect.Services.log | filter-mllog'
tell application "Terminal"
set newTab to (do script "tail-services")
tell newTab
@MLKrisJohnson
MLKrisJohnson / Viscosity Reconnect.applescript
Last active November 18, 2019 12:53
Disconnect and reconnect all Viscosity connections
#!/usr/bin/osascript
tell application "Viscosity"
activate
display notification "Disconnecting Viscosity"
disconnectall
delay 5
@MLKrisJohnson
MLKrisJohnson / Clean and Build.applescript
Created November 11, 2019 18:53
AppleScript that tells Xcode to do a "Clean" and then a "Build"
tell application "Xcode"
tell active workspace document
set actionResult to clean
repeat
if completed of actionResult is true then
exit repeat
end if
delay 0.5
end repeat
@MLKrisJohnson
MLKrisJohnson / appium_test.py
Last active October 4, 2019 17:26
A very simple Appium test script for an iOS device
#!/usr/bin/env python3
# Simple Appium script that connects to an iOS device and prints the page source.
#
# Requires Python 3.x
#
# Run 'pip3 install Appium-Python-Client' to install dependencies
# Set these variables as appropriate for the device and app you want to launch
@MLKrisJohnson
MLKrisJohnson / Makefile
Last active November 18, 2019 13:02
Simple C++ program that immediately crashes. Useful for playing with debuggers and other diagnostic tools.
crash: crash.cpp
# Run 'make test' to build and run the program
test: crash
./crash
.PHONY: test
@MLKrisJohnson
MLKrisJohnson / logXmlDocument.m
Created December 11, 2018 20:53
Log contents of an xmlDoc to NSLog
static void logXmlDocument(xmlDocPtr doc)
{
xmlChar *xmlbuff = nil;
int buffersize = 0;
xmlDocDumpFormatMemory(doc, &xmlbuff, &buffersize, 1);
int remainingsize = buffersize;
xmlChar *p = xmlbuff;
char dumpbuff[80+1];
while (remainingsize > 0) {
@MLKrisJohnson
MLKrisJohnson / pluralize.py
Created December 10, 2018 18:24
Return the singular or plural form of text
def pluralize(count, arg1=None, arg2=None):
"""Return pluralized string.
If the count is 1, then if two additional arguments are provided, return the
first one. Otherwise, return an empty string.
if the count is not 1, then if two additional arguments are provided, return
the second one. If one additional argument is provided, return it.
Otherwise return "s".
@MLKrisJohnson
MLKrisJohnson / connect_postgres.py
Created August 13, 2018 15:01
Example of connecting to a PostgreSQL database and getting a Pandas DataFrame for a table
import psycopg2 as pg
import pandas as pd
conn = pg.connect(database="mydatabase",
user="myuser",
password="mypassword")
df = pd.read_sql('select * from event', conn)