This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var sizes = [29, 40, 50, 57, 58, 72, 76, 80, 100, 114, 120, 144, 152, 1024]; | |
| var acorn = JSTalk.application("Acorn"); | |
| var doc = acorn.open("/Users/Douglas/Desktop/icon.acorn"); | |
| for (idx = 0; idx < sizes.length; idx++) { | |
| doc.flattenImage(); | |
| doc.scaleImageToWidth(sizes[idx]); | |
| doc.dataRepresentationOfType("public.png").writeToFile("/Users/Douglas/Desktop/icon-" + sizes[idx] + ".png"); | |
| doc.undo(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NSString * NSStringFromCATransform3D(CATransform3D t) | |
| { | |
| return [NSString stringWithFormat:@"CATransform3D {\n% 7.2f % 7.2f % 7.2f % 7.2f\n% 7.2f % 7.2f % 7.2f % 7.2f\n% 7.2f % 7.2f % 7.2f % 7.2f\n% 7.2f % 7.2f % 7.2f % 7.2f\n}", t.m11, t.m12, t.m13, t.m14, t.m21, t.m22, t.m23, t.m24, t.m31, t.m32, t.m33, t.m34, t.m41, t.m42, t.m43, t.m44]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NSString * const ShakeEventNotification = @"ShakeEventNotification"; | |
| @implementation ShakeApplication | |
| { | |
| BOOL _shakeStarted; | |
| } | |
| - (void)sendEvent:(UIEvent *)event | |
| { | |
| [super sendEvent: event]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/python | |
| # coding=utf-8 | |
| # http://stackoverflow.com/questions/295135/turn-a-string-into-a-valid-filename-in-python | |
| import os, os.path, re | |
| max_length = 100 | |
| file_name = 'Untitled.txt' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /bin/bash | |
| NOTE_PATH=~/Dropbox/Notes/New\ note\ `date "+%H-%M-%S"`.txt | |
| touch "$NOTE_PATH" | |
| open "$NOTE_PATH" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @import Foundation; | |
| @import CoreServices; | |
| int main(int argc, char *argv[]) { | |
| @autoreleasepool { | |
| NSString * UTI = (__bridge NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, | |
| (CFStringRef)@"plist", | |
| NULL); | |
| NSLog(@"UTI is %@", UTI); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // NSObject+AccessibilityInspect.h | |
| // Created by Douglas Hill on 29/09/2012. | |
| // | |
| #import <Foundation/Foundation.h> | |
| @interface NSObject (AccessibilityInspect) | |
| - (void)logAccessibiltyProperties; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static NSString * DHStringFromRange(NSRange range); | |
| @implementation NSIndexSet (DHDescription) | |
| - (NSString *)dh_description | |
| { | |
| return [self dh_descriptionShowingRanges:YES]; | |
| } | |
| - (NSString *)dh_descriptionShowingRanges:(BOOL)shouldShowAsRanges |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import <Foundation/Foundation.h> | |
| int main(int argc, char *argv[]) { | |
| @autoreleasepool { | |
| NSCountedSet *set = [NSCountedSet set]; | |
| NSError *error; | |
| NSString *corpus = [NSString stringWithContentsOfFile:@"some-file.txt" encoding:NSUTF8StringEncoding error:&error]; | |
| [corpus enumerateSubstringsInRange:NSMakeRange(0, [corpus length]) options:NSStringEnumerationByWords usingBlock:^(NSString *word, NSRange substringRange, NSRange enclosingRange, BOOL *stop) { | |
| [set addObject:word]; | |
| }]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| + (NSArray *)dh_preferredLocalizationsFromArray:(NSArray *)requestedLocalisations | |
| { | |
| NSMutableSet *possibleLocalisations = [NSMutableSet setWithArray:requestedLocalisations]; | |
| BOOL shouldLimitToAvailableLocalisations = YES; // Set to YES to match what NSBundle seems to do, or NO to be more like the documentation. | |
| if (shouldLimitToAvailableLocalisations) { | |
| [possibleLocalisations intersectSet:[NSSet setWithArray:[[NSBundle mainBundle] localizations]]]; | |
| } | |
OlderNewer