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
#!/bin/sh | |
# Configure homebrew permissions to allow multiple users on MAC OSX. | |
# Any user from the admin group will be able to manage the homebrew and cask installation on the machine. | |
# allow admins to manage homebrew's local install directory | |
chgrp -R admin /usr/local | |
chmod -R g+w /usr/local | |
# allow admins to homebrew's local cache of formulae and source files | |
chgrp -R admin /Library/Caches/Homebrew |
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
""" | |
1. Store the image and create an instance of ImagefileProcessHistory with status NOT_STARTED | |
ImageFileProcessHistory | |
- local_path | |
- file_name | |
- status # enum: NOT_STARTED, STARTED, SUCCEEDED, FAILED | |
- bytes_processed | |
- bytes_total | |
""" |
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 <Foundation/Foundation.h> | |
@interface XmlParser : NSObject <NSXMLParserDelegate> | |
@property (strong, nonatomic) NSData *xmlData; | |
@property (strong, nonatomic) NSMutableDictionary *dictionary; | |
@property (strong, nonatomic) NSMutableDictionary *currentNode; | |
@property (strong, nonatomic) NSMutableDictionary *currentParentNode; | |
- (id)initWithXMLData:(NSData *)xmlData; |
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
# Keep in mind that when asking for a `return` after another, only the first one will be output. | |
# This example is meant as a simple starting point, to show how to get the information in the simplest available way. | |
# Google Chrome | |
tell application "Google Chrome" to return URL of active tab of front window | |
tell application "Google Chrome" to return title of active tab of front window | |
# Google Chrome Canary | |
tell application "Google Chrome Canary" to return URL of active tab of front window | |
tell application "Google Chrome Canary" to return title of active tab of front window | |
# Chromium |
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 getGlyphAdvanceForFont(NSString *ch, NSFont *font) { | |
// Handle tab character width, because it's not correct to get it with | |
// CTRunGetAdvances(). | |
if ([ch isEqualToString:@"\t"]) { | |
// NOTE: (TAB) This clause will never reach because when a \t is entered, | |
// We convert it into a ' '. | |
// But I will leave this code her for alternative method to | |
// get glyph width | |
CGRect rect; | |
CGFontRef cgFont = CTFontCopyGraphicsFont((CTFontRef)font, nil); |
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
/* == Old draw string method | |
*/ | |
- (CGFloat)drawString:(NSString*)ch font:(NSFont*)font context:(CGContextRef)context { | |
NSMutableAttributedString *s = [[NSMutableAttributedString alloc] initWithString:ch]; | |
[s addAttribute:NSFontAttributeName value:font range:NSMakeRange(0, 1)]; | |
[s addAttribute:NSForegroundColorAttributeName value:[NSColor blackColor] range:NSMakeRange(0, 1)]; | |
CFAttributedStringRef attrStr = (__bridge CFAttributedStringRef)(s); | |
CTLineRef line = CTLineCreateWithAttributedString(attrStr); | |
CTLineDraw(line, context); |
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
extension NSView { | |
var snapshot: NSImage { | |
guard let bitmapRep = bitmapImageRepForCachingDisplayInRect(bounds) else { return NSImage() } | |
bitmapRep.size = bounds.size | |
cacheDisplayInRect(bounds, toBitmapImageRep: bitmapRep) | |
let image = NSImage(size: bounds.size) | |
image.addRepresentation(bitmapRep) | |
return image | |
} | |
} |
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
NSFontManager *fm = [NSFontManager sharedFontManager]; | |
NSArray *fontFamilies = [fm availableFontFamilies]; | |
int i; | |
for (i = 0; i < [fontFamilies count]; i++){ | |
NSArray *familyMembers; | |
familyMembers = [fm availableMembersOfFontFamily: | |
[fontFamilies objectAtIndex: i]]; | |
int j = 0; | |
for (j = 0; j < [familyMembers count]; j++) { | |
NSLog(@"%@", [familyMembers objectAtIndex: j]); |
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
// Check if two glyphs mark a word break, function like a white space | |
// GMisc.m | |
BOOL isWordBreaks(GGlyph *a, GGlyph *b) { | |
if (a == nil || b == nil) { | |
BOOL result = NO; | |
//NSLog(@"Nil case cur: %@ next: %@ result: %d", [a content], [b content], result); | |
return result; | |
} | |
NSRect f1 = [a frame]; |
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; |