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
CGContextRef context = UIGraphicsGetCurrentContext(); | |
// Flip the coordinate system | |
// Make an attributed string | |
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:@"Hello CoreText!"]; | |
CFAttributedStringRef attributedStringRef = (CFAttributedStringRef)attributedString; | |
// Simple CoreText with CTFrameDraw | |
CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(attributedStringRef); |
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
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
CGRect frame = self.view.bounds; | |
for (NSInteger i=0; i<10; i++) { | |
CGFloat left = (frame.size.width-100)/2+i%2*10; | |
CGFloat top = (frame.size.height-100)/2+i%3*10; | |
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
memcached -d -l 127.0.0.1 -p 11211 -m 64 |
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
//1 Creating a New Managed Object Context | |
//To create a new managed object context, you need a persistent store coordinator. | |
NSPersistentStoreCoordinator *psc = <#Get the coordinator#>; | |
NSManagedObjectContext *newContext = [[NSManagedObjectContext alloc] init]; | |
[newContext setPersistentStoreCoordinator:psc]; | |
//using the same coordinator as the existing one | |
NSManagedObjectContext *context = <#Get the context#>; | |
NSPersistentStoreCoordinator *psc = [context persistentStoreCoordinator]; | |
NSManagedObjectContext *newContext = [[NSManagedObjectContext alloc] init]; |
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
#vim ~/.subversion/config | |
global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo | |
*.rej *~ #*# .#* .*.swp .DS_Store *.xcuserdatad |
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
#Show Unversioned Files | |
svn status --no-ignore | grep '^\?' | sed 's/^\? //' | |
#Delete Unversioned Files | |
svn status --no-ignore | grep '^\?' | sed 's/^\? //' | xargs -Ixx rm -rf xx | |
#via http://www.guyrutenberg.com/2008/01/18/delee-unversioned-files-under-svn/ |
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> | |
@interface Singleton : NSObject | |
+(Singleton*)sharedSingleton; | |
-(void)sayHello; | |
@end |
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
// Check UTF-8 BOM | |
// go run cbom.go -path=hello.txt | |
package main | |
import( | |
"flag" | |
"os" | |
"log" | |
"fmt" | |
) |
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
/* | |
*@fileOverview gravator proxy | |
* reuqire node.js v0.6.7 | |
*/ | |
if(process.argv.length>1&&process.argv[2]=='-d'){ | |
var HOST = '127.0.0.1'; | |
var PORT = 1337; | |
} | |
var HOST = HOST||'0.0.0.0'; | |
var PORT = PORT||80; |
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+Split.h | |
// Categories | |
// | |
// Created by Darcy Liu on 6/17/12. | |
// Copyright (c) 2012 Close To U. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |