Skip to content

Instantly share code, notes, and snippets.

Avatar

Paul Calnan pwc3

View GitHub Profile
@pwc3
pwc3 / generate-git-revision.sh
Last active May 12, 2020
Generate GitRevision.swift for inclusion in an Xcode project
View generate-git-revision.sh
#!/usr/bin/env bash
set -euo pipefail
cat <<SWIFT
//
// GitRevision.swift
//
// This file was automatically generated. Do not edit manually. It will be overwritten on every build.
//
@pwc3
pwc3 / git-rmtag
Last active May 7, 2020
Remove Git Tag
View git-rmtag
#!/usr/bin/env bash
set -euo pipefail
E_BADARGS=85
if [ $# -ne 1 ]; then
echo "Usage: $(basename $0) tag-name"
exit $E_BADARGS
fi
View ValueTypeCapture.swift
import Foundation
class SimulatedOperation {
// Simulated function that collects data from multiple async calls.
// Build an array of [String] values, one element per async call. Hit the
// completion block once all of the elements are populated.
func collectData(completion: @escaping ([String]) -> Void) {
// Locally accumulate the results here. Why does this work?
@pwc3
pwc3 / ppjson
Last active May 11, 2020
Pretty-Print JSON
View ppjson
#!/usr/bin/env python
from __future__ import print_function
import sys
import json
try:
json.dump(json.load(sys.stdin), sys.stdout, sort_keys=True, indent=4)
except ValueError as err:
print("Error:", err, file=sys.stderr)
@pwc3
pwc3 / pdf2appicon.py
Created Mar 27, 2020
Converts a PDF to an iOS app icon
View pdf2appicon.py
#!/usr/bin/env python
import argparse
import codecs
import json
import subprocess
import sys
def parse_args(argv):
if argv is None:
@pwc3
pwc3 / unfuck-xcode
Last active May 13, 2020
Unfuck Xcode
View unfuck-xcode
#!/usr/bin/env bash
set -euo pipefail
echo "Exiting Xcode"
osascript -e 'quit app "Xcode"'
echo "Deleting DerivedData"
rm -rf ~/Library/Developer/Xcode/DerivedData/*
@pwc3
pwc3 / simulator-floating-name.py
Last active Oct 24, 2019
Show/HIde the floating name at the bottom of the iOS Simulator
View simulator-floating-name.py
#!/usr/bin/env python
import argparse
import codecs
import subprocess
import sys
def parse_args(argv):
if argv is None:
argv = sys.argv[1:]
View Start Screen Recording.scpt
set theProcessName to "iOS Simulator"
set theWindowNumber to 1
tell application "System Events"
tell process theProcessName
activate
tell window theWindowNumber
set thePosition to position
set theSize to size
end tell
View clickdrag.swift
#!/usr/bin/env xcrun swift
import Foundation
let kDelayUSec : useconds_t = 500_000
func DragMouse(from p0: CGPoint, to p1: CGPoint) {
let mouseDown = CGEventCreateMouseEvent(nil, .LeftMouseDown, p0, .Left)
let mouseDrag = CGEventCreateMouseEvent(nil, .LeftMouseDragged, p1, .Left)
let mouseUp = CGEventCreateMouseEvent(nil, .LeftMouseUp, p1, .Left)
@pwc3
pwc3 / keybase.md
Created Aug 14, 2014
Verifying myself for Keybase.io
View keybase.md

Keybase proof

I hereby claim:

  • I am pwc3 on github.
  • I am pwc (https://keybase.io/pwc) on keybase.
  • I have a public key whose fingerprint is 54D6 83ED A697 10D0 9197 0AC4 EB1D 31E1 F05D EB34

To claim this, I am signing this object:

You can’t perform that action at this time.