Skip to content

Instantly share code, notes, and snippets.

#import "EGOCache.h"
@interface EGOCache (NSArray)
- (void)setArray:(NSArray*)array forKey:(NSString*)key;
- (void)setArray:(NSArray*)array forKey:(NSString*)key withTimeoutInterval:(NSTimeInterval)timeoutInterval;
- (NSArray*)arrayForKey:(NSString*)key;
@end
@shnhrrsn
shnhrrsn / GetTextHeight.java
Created March 1, 2012 15:51
Get the height of a block of text constrained to a max width.
public static int getTextHeight(String text, int maxWidth, float textSize, Typeface typeface) {
TextPaint paint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
paint.setTextSize(textSize);
paint.setTypeface(typeface);
int lineCount = 0;
int index = 0;
int length = text.length();
<?php
while(TRUE) {
$contents = @file_get_contents("http://store.apple.com/");
if(strpos($contents, "backsoon") != FALSE) {
exec("osascript -e 'tell app \"System Events\" to display dialog \"Apple Store appears to be up.\"'");
exit;
} else {
sleep(5);
}
#import <UIKit/UIKit.h>
@interface UIImage (Resizing)
- (UIImage*)scaleToSize:(CGSize)size;
@end
- (void)someMethod {
UIImage* scaledImage = [[UIImage imageNamed:@"largeImage"] scaleToSize:CGSizeMake(100.0f, 100.0f);
}
@shnhrrsn
shnhrrsn / UIDevice+AvailableMemory.h
Created March 10, 2012 19:16
UIDevice AvailableMemory
#import <UIKit/UIKit.h>
@interface UIDevice (AvailableMemory)
- (double)availableMemory;
@end
- (void)someMethod {
NSLog(@"Available Memory: %f", [[UIDevice currentDevice] availableMemory]);
}
# Disable Access to .svn directories
RewriteRule \.svn - [F]
# Disable Access to .git directories
RewriteRule \.git - [F]
# Disable Access to .svn directories
$HTTP["url"] =~ "\.svn" {
url.access-deny = ("")
}
# Disable Access to .git directories
$HTTP["url"] =~ "\.git" {
url.access-deny = ("")
}
EGODatabase* database = [EGODatabase databaseWithPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/database.db"]];
EGODatabaseResult* result = [database executeQuery:@"SELECT * FROM `posts` WHERE `post_user_id` = ?", [NSNumber numberWithInt:10]];
for(EGODatabaseRow* row in result) {
NSLog(@"Subject: %@", [row stringForColumn:@"post_subject"]);
NSLog(@"Date: %@", [row dateForColumn:@"post_date"]);
NSLog(@"Views: %d", [row intForColumn:@"post_views"]);
NSLog(@"Message: %@", [row stringForColumn:@"post_message"]);
}