This file contains 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
enum ShiftKeyType { | |
case None | |
case Once | |
case Always | |
} | |
enum PunctuationSwitcherType { | |
case More | |
case Numeric | |
} |
This file contains 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
// BridgeHeader.h | |
#import <unicode/uchar.h> | |
// UnicodeBlock.swift | |
import Foundation | |
class UnicodeBlock { | |
class var blocks: UnicodeBlock[] { |
This file contains 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
#ifdef __OBJC__ | |
#import <Foundation/Foundation.h> | |
#define BUNDLE_NAME CXAFileManagerResourceBundle | |
extern NSBundle *BUNDLE_NAME; | |
#undef NSLocalizedString | |
#define NSLocalizedString(key, comment) [BUNDLE_NAME localizedStringForKey:(key) value:@"" table:nil] | |
#ifdef COMPILE_ONCE |
This file contains 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
int fiddle = open("DOCUMENT_DIRECTORY", O_EVTONLY); | |
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); | |
dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE, fiddle, DISPATCH_VNODE_WRITE, queue); | |
dispatch_source_set_event_handler(source, ^{ | |
// how to determine if a file has finished copying? | |
}); |
This file contains 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
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user |
This file contains 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 <ApplicationServices/ApplicationServices.h> | |
#import <Foundation/Foundation.h> | |
int main(int argc, char *argv[]) | |
{ | |
if (argc != 2) | |
return 0; | |
NSAutoreleasePool *pool = [NSAutoreleasePool new]; | |
CFStringRef name = (CFStringRef) [NSString stringWithUTF8String: argv[1]]; |
This file contains 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
typedef struct FontHeader { | |
int32_t fVersion; | |
uint16_t fNumTables; | |
uint16_t fSearchRange; | |
uint16_t fEntrySelector; | |
uint16_t fRangeShift; | |
}FontHeader; | |
typedef struct TableEntry { | |
uint32_t fTag; |
This file contains 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
CGFloat pointSize = 17.0; | |
CTFontDescriptorRef descLatin = CTFontDescriptorCreateWithNameAndSize(CFSTR("TimesNewRomanPSMT"), pointSize); | |
CTFontDescriptorRef descZh = CTFontDescriptorCreateWithNameAndSize(CFSTR("STHeitiSC-Light"), pointSize); | |
NSArray *cascade = [NSArray arrayWithObjects:(id)descLatin, (id)descZh, nil]; | |
NSDictionary *attrs = [NSDictionary dictionaryWithObject:cascade forKey:(id)kCTFontCascadeListAttribute]; | |
CTFontDescriptorRef desc = CTFontDescriptorCreateWithAttributes((CFDictionaryRef)attrs); | |
CTFontRef font = CTFontCreateWithFontDescriptor(desc, pointSize, NULL); | |
// use the font | |
... | |
CFRelease(descLatin); |
This file contains 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
#define DEFAULTS(type, key) ([[NSUserDefaults standardUserDefaults] type##ForKey:key]) | |
#define SET_DEFAULTS(Type, key, val) do {\ | |
[[NSUserDefaults standardUserDefaults] set##Type:val forKey:key];\ | |
[[NSUserDefaults standardUserDefaults] synchronize];\ | |
} while (0) |
This file contains 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
#define CHAR_MAX 32 | |
NSString* toChineseNumer(NSUInteger num){ | |
static NSString *cnums = @"〇一二三四五六七八九"; | |
unichar ch[32]; | |
int i = 0; | |
do ch[i++] = [cnums characterAtIndex:num%10]; | |
while ((num /= 10) > 0); |