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
# subview walker for iphone-rubycocoa | |
def walk(v, g) | |
g[:subviews] = v.subviews.to_a.map {|sv| walk(sv, geom(sv))} | |
g | |
end | |
def geom(v) | |
{:name=>v.to_s, :subviews=>[], :frame=>v.frame.to_a} | |
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
// NSDate#descriptionWithTwitterStyle | |
@interface NSDate(TwitterStyle) | |
- (NSString*)descriptionWithTwitterStyle; | |
@end | |
@implementation NSDate(TwitterStyle) | |
- (NSString*)descriptionWithTwitterStyle { | |
time_t now = [[NSDate date] timeIntervalSince1970]; | |
time_t t = [self timeIntervalSince1970]; |
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)drawRect:(CGRect)rect { | |
CGContextRef ctx = UIGraphicsGetCurrentContext(); | |
// CGFontRef font = CGFontCreateWithFontName((CFStringRef)[[self font] fontName]); | |
CGFontRef font = CGFontCreateWithFontName((CFStringRef)@"HiraKakuProN-W3"); | |
// CGFontRef font = CGFontCreateWithFontName((CFStringRef)@"Helvetica"); | |
CGContextSetFont(ctx, font); | |
CGContextSetFontSize(ctx, 14); | |
// Transform text characters to unicode glyphs. |
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
MPMusicPlayerController *mpc = [MPMusicPlayerController iPodMusicPlayer]; | |
MPMediaItem *item = [mpc nowPlayingItem]; | |
NSString *tw = [NSString stringWithFormat:@"Now Playing: %@ - %@ - %@", | |
[item valueForProperty:MPMediaItemPropertyTitle], | |
[item valueForProperty:MPMediaItemPropertyAlbumTitle], | |
[item valueForProperty:MPMediaItemPropertyArtist]]; | |
NSLog("%@", tw); |
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
+ (UIImage*)resizedImage:(UIImage*)image withSize:(CGSize)size { | |
UIGraphicsBeginImageContext(size); | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
CGContextSetInterpolationQuality(context, kCGInterpolationNone); | |
// CGContextSetInterpolationQuality(context, kCGInterpolationLow); | |
[image drawInRect:CGRectMake(0, 0, size.width, size.height)]; | |
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return newImage; | |
} |
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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd"> | |
<!-- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" | |
"http://www.w3.org/TR/html4/strict.dtd"> --> | |
<HTML> | |
<HEAD> | |
<META HTTP-EQUIV="Refresh" CONTENT="0.1"> | |
<META HTTP-EQUIV="Pragma" CONTENT="no-cache"> | |
<META HTTP-EQUIV="Expires" CONTENT="-1"> | |
<TITLE></TITLE> | |
</HEAD> |
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
>> Hoge = "Hage" | |
=> "Hage" | |
>> Hoge + "atama" | |
=> "Hageatama" | |
>> HA = Hoge + "atama" | |
=> "Hageatama" | |
>> HA | |
=> "Hageatama" | |
>> |
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
[[[NSURLConnection alloc] initWithRequest: | |
[NSURLRequest requestWithURL: | |
[NSURL URLWithString: | |
[NSString stringWithFormat:@"%@/statuses/home_timeline.json", API_URL]]]] autorelease]; |
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
@interface UIImage(ImmediateLoad) | |
+ (UIImage*)imageImmediateLoadWithContentsOfFile:(NSString*)path; | |
@end | |
@implementation UIImage(ImmediateLoad) | |
+ (UIImage*)imageImmediateLoadWithContentsOfFile:(NSString*)path { | |
UIImage *image = [[UIImage alloc] initWithContentsOfFile: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
/* | |
NSData+XMLParser | |
Simple XML Parser for iPhone | |
Usage: | |
* -I /usr/include/libxml2 | |
* -L libxml2 |