Skip to content

Instantly share code, notes, and snippets.

@toco
toco / Mail alias recovery
Created October 1, 2015 14:06
Apple Script to migrate old e-mail aliases (which where lost when upgrading to El Capitan) to Mail 9.0.
tell application "System Events"
set plistFile to property list file "~/Library/Mail/V2/MailData/Accounts.plist"
set plistRoot to contents of plistFile
tell plistRoot to set accountsPlist to value of property list item "MailAccounts"
end tell
tell application "Mail"
@toco
toco / gist:9dddb3035430f6c12b73
Created February 17, 2015 17:53
let Keynote reevaluate all cells of the next slide
tell application "Keynote"
repeat
set allSlides to slides of front document
set currentslide to current slide of front document
set nextSlideNumber to (slide number of currentslide) + 1
if nextSlideNumber < (count of allSlides) then
set nextSlide to item nextSlideNumber of allSlides
repeat with aCell in cells in every table of nextSlide
set tmpFormula to formula of aCell
if tmpFormula is not missing value then
@toco
toco / VLC_add_folders_in_Documents.diff
Last active August 29, 2015 14:06
Add support for directories when scanning documents directory.
diff --git a/Sources/VLCAppDelegate.m b/Sources/VLCAppDelegate.m
index ef5f12f..e80422b 100644
--- a/Sources/VLCAppDelegate.m
+++ b/Sources/VLCAppDelegate.m
@@ -278,16 +278,28 @@
- (void)updateMediaList
{
NSString *directoryPath = [self directoryPath];
- NSArray *foundFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:directoryPath error:nil];
- NSMutableArray *filePaths = [NSMutableArray arrayWithCapacity:[foundFiles count]];
@toco
toco / TOCMotionEffectsEngine.m
Created September 27, 2013 11:14
Enable UIMotionEffects when AirPlay mirroring is turned on.
// Copyright (c) 2013 Tobias Conradi
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
@toco
toco / App Delegate
Last active December 19, 2015 03:48
Category for https://github.com/toco/DTAUS to create http://www.bezahlcode.de URLs using the BezahlCode library.
- (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename {
NSData *fileData = [NSData dataWithContentsOfFile:filename];
DTAData *aDTAData = [DTAParser parseData:fileData];
for (NSURL *aUrl in [aDTAData bezahlCodeURLs]) {
[[NSWorkspace sharedWorkspace] openURL:aUrl];
}
BOOL success = aDTAData!=nil;
if (!success) {
// handle error
}
@toco
toco / gist:5055909
Created February 28, 2013 10:55
Partial mocking with OCMockito, OCHamcrest sut calls showAlert (verified in debugger) but the test fails
- (void)testShowsAlertViewWhenOpenInSafariFails
{
sut = spy(sut);
// given
[sut view];
UIApplication *application = mock([UIApplication class]);
sut.application = application;
// when