Skip to content

Instantly share code, notes, and snippets.

@smorr
smorr / getFSEventUUID.m
Last active June 5, 2018 17:39
Quick program to fetch the current FSEventUUID for boot device on macOS
#import <Foundation/Foundation.h>
#include <sys/param.h>
#include <sys/mount.h>
// adapted from http://www.cocoabuilder.com/archive/cocoa/203717-looking-for-sample-code-to-read-uuid-from-disk-volume.html
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
struct statfs stat;
@smorr
smorr / MailApp.m
Created August 2, 2017 14:15 — forked from lukele/MailApp.m
- (void)MASetPreferencesController:(NSWindowController *)windowController {
// minor test to change code here
[self MASetPreferencesController:windowController];
if(!windowController) {
return;
}
NSToolbarItem *toolbarItem = [[NSToolbarItem alloc] initWithItemIdentifier:@"gpgmail"];
toolbarItem.label = @"GPGMail";
toolbarItem.image = [NSImage imageNamed:@"GPGMail"];
@smorr
smorr / MailTabViewController Swizzle
Created August 2, 2017 13:50
Common swizzle for dealing with multiple plugins and Preferences on Mail in 10.13
-(void)MTsetSelectedTabViewItemIndex:(NSUInteger)idx{
if ([[NSThread currentThread] threadDictionary][@"pluginExclusionLock"]){
[swizzledSelf MTsetSelectedTabViewItemIndex:idx];
return;
}
// grab the pluginExclusionLock
[[NSThread currentThread] threadDictionary][@"pluginExclusionLock"] = @YES;
@smorr
smorr / boxingCommonObjCStructs
Last active June 27, 2016 09:50
Using macros to box common structs (point, size, range, rect) in object-c
/* the following macros will create a mechanism to box common cocoa structures so can be easily added to NSArrays etc
*
* The macros can take multiple arguments allowing you to pass in an existing struct, or the components of the struct
*
* for example:
* NSValue * pointValue1 = @point(3,5); // pass in the two values that make up the point
*
* NSPoint * myPoint = NSMakePoint(3,5);
* NSValue * pointValue2 = @point(myPoint); // pass in a existing point.
*