Skip to content

Instantly share code, notes, and snippets.

@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:

@pwc3
pwc3 / SkypeMenuUpdater.rb
Created May 18, 2012 23:42
Shows the number of unread Skype conversations in the menu bar
#!/usr/bin/env ruby
FSCRIPT_PATH = "/Library/Frameworks/FScript.framework"
GDB = IO.popen("gdb", "w")
def gdb(cmd)
GDB.puts cmd
GDB.flush
end
set appleID to "ENTER YOUR APPLE ID HERE"
activate application "Xcode"
tell application "System Events"
tell process "Xcode"
-- open the preferences dialog
click menu item "Preferences…" of menu "Xcode" of menu bar 1
-- find and select the Accounts tab
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)
@pwc3
pwc3 / gist:5078925
Created March 3, 2013 23:44
Type checking assignments.
NSDictionary *aDictionary = nil;
NSArray *anArray = nil;
void (^aBlock)() = ^{ };
// no warning
aDictionary = aBlock;
// no warning
anArray = aBlock;
// warning assigning NSArray to NSDictionary, but not for block assignment
aDictionary = anArray = aBlock;
@pwc3
pwc3 / edit-plist.py
Created August 6, 2013 01:17
Opens a property list file in a text editor, converting from binary if necessary.
#!/usr/bin/env python
import argparse
import subprocess
import sys
EDITOR = 'vim'
BINARY = 'Apple binary property list'
XML = 'XML document text'
@pwc3
pwc3 / alfred-shell-script.sh
Created August 16, 2013 03:13
Alfred workflow shell script
# set interpreter to /bin/bash
case "{query}" in
"monday") code="12345#,,#" ;;
"wednesday") code="23456#,,#" ;;
"friday") code="34567#,,#" ;;
*) code="{query}#,,#" ;;
esac
$HOME/bin/skypecall "800-555-1212" "$code"
@pwc3
pwc3 / ExtractMarkdownFromVoodoopad.py
Created August 29, 2013 01:07
Python script to extract Markdown from a VoodooPad file used for static blog generation.
#!/usr/bin/env python
import argparse
import codecs
import glob
import os
import plistlib
import re
import sys