Skip to content

Instantly share code, notes, and snippets.

tell application "System Events"
tell process "Tweetbot"
repeat
-- need to put this in a try block as it sometimes fails
try
-- loop over all of the windows
repeat with _window in windows
-- if the title isn't "Main Window"...
if title of _window is not "Main Window" then
-- ... close it by performing AXPress on button 1 (which corresponds to the red stoplight button)
tell application "Xcode"
set _workspace to active workspace document
set _workspaceFile to file of _workspace
end tell
tell application "Finder"
set _posixTargetPath to quoted form of POSIX path of _workspaceFile
end tell
tell application "Xcode"
@pwc3
pwc3 / swift-repl
Last active August 29, 2015 14:02
#!/usr/bin/env bash
/Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift
#import <Foundation/Foundation.h>
#import <stdio.h>
@interface ExampleObject : NSObject
// BLOCK AS A PROPERTY
// -------------------
//
// @property (copy, ...) return_type (^block_name)(parameter_types);
//
@pwc3
pwc3 / keybase.md
Created August 14, 2014 15:57
Verifying myself for Keybase.io

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:

#!/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)
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
@pwc3
pwc3 / simulator-floating-name.py
Last active October 24, 2019 21:41
Show/HIde the floating name at the bottom of the iOS Simulator
#!/usr/bin/env python
import argparse
import codecs
import subprocess
import sys
def parse_args(argv):
if argv is None:
argv = sys.argv[1:]
@pwc3
pwc3 / unfuck-xcode
Last active October 14, 2021 14:19
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 / pdf2appicon.py
Created March 27, 2020 17:42
Converts a PDF to an iOS app icon
#!/usr/bin/env python
import argparse
import codecs
import json
import subprocess
import sys
def parse_args(argv):
if argv is None: