Skip to content

Instantly share code, notes, and snippets.

View alexrozanski's full-sized avatar

Alex Rozanski alexrozanski

View GitHub Profile
tell application "Finder"
open trash
end tell
tell application "Finder"
empty trash
end tell
alexrozanski / screensaver.scpt
Created May 21, 2020 13:38
Start screensaver
tell application "System Events"
start current screen saver
end tell
alexrozanski /
Created January 1, 2014 10:16
Shell script which gets the version of a particular target from its info plist file
# Thanks to for help with the parsing.
relativeInfoPlistLocation=`/usr/bin/xcrun xcodebuild -showBuildSettings -target ${targetName} 2>/dev/null | grep "INFOPLIST_FILE" | sed 's/[ ]*INFOPLIST_FILE = //'`
version=`/usr/libexec/Plistbuddy -c 'Print :CFBundleShortVersionString' $absoluteInfoPlistLocation`
alexrozanski / PXProtocolMethodList.h
Last active February 22, 2017 10:09
Gets information about all methods that are defined in an Objective-C protocol. Returns an array of dictionaries with the selector and argument types for each method in NSString form.
#import <Foundation/Foundation.h>
extern NSString * const PXProtocolMethodListMethodNameKey;
extern NSString * const PXProtocolMethodListArgumentTypesKey;
NSArray *px_allProtocolMethods(Protocol *protocol);
alexrozanski / gist:972958
Created May 15, 2011 08:00
Reposition Traffic Lights
NSButton *closeButton = [self standardWindowButton:NSWindowCloseButton];
NSView *themeFrame = [closeButton superview];
CGFloat buttonYOrigin = NSMaxY(themeFrame.frame)-34;
//Alter the button frames
NSRect closeFrame = closeButton.frame;
closeFrame.origin.y = buttonYOrigin;
closeButton.frame = closeFrame;
@interface NSArray (PXArrayAdditions)
- (id)initWithObject:(id)object;
- (id)firstObject;
alexrozanski / NSMutableDictionary+PXDictionaryAdditions.h
Created February 18, 2010 10:48
NSMutableDictionary category to handle setting nil as an object for a key, adding [NSNull null] instead.
#import <Cocoa/Cocoa.h>
@interface NSMutableDictionary (PXDictionaryAdditions)
- (BOOL)setObjectOrNull:(id)anObject forKey:(id)aKey;