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
class Polygon | |
@@sides = 10 | |
def self.sides | |
@@sides | |
end | |
end | |
puts Polygon.sides # => 10 | |
class Triangle < Polygon |
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
# put this in your lib folder as logger_format.rb and | |
# require it in your environment or an initializer | |
class Logger | |
def format_message(level, time, progname, msg) | |
"#{time.to_s(:long)} -- #{msg}\n" | |
end | |
end |
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
# useful nginx configuration for reverse proxy with Apache | |
# edit lines 8, 11, and 30 | |
# taken from: http://syslog.tv/2010/01/11/debian-apache-2-nginx-wordpress-mu/ | |
# edits by jakebellacera (http://github.com/jakebellacera && http://jakebellacera.com) | |
server { | |
listen 80; | |
server_name domain.com *.domain.com; # edit this to your domain |
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
- (NSString *)documentPathForFile:(NSString *)fileName | |
{ | |
NSArray *pathArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES); | |
NSString *documentPath = [pathArray objectAtIndex:0]; | |
NSString *filePath = [documentPath stringByAppendingPathComponent:fileName]; | |
return filePath; | |
// return [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:fileName]; | |
} | |
- (NSMutableArray *)loadLocalBooksFromDocument:(NSString *)fileName |
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
- (void)getContactList | |
{ | |
ABAddressBookRef addressBook = ABAddressBookCreate(); | |
NSMutableArray *peopleArray = (NSMutableArray *)ABAddressBookCopyArrayOfAllPeople(addressBook); | |
for (id *people in peopleArray) | |
{ | |
// phone | |
ABMultiValueRef phones = (ABMultiValueRef) ABRecordCopyValue(people, kABPersonPhoneProperty); | |
int nCount = ABMultiValueGetCount(phones); |
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 <UIKit/UIKit.h> | |
@interface DragView : UIImageView | |
{ | |
CGPoint startLocation; | |
} | |
@end | |
@implementation DragView |
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. 将你需要的splash界面的图片,存成Default.png | |
2. 在XXXAppDelegate.m程序中,插入如下代码: | |
- (BOOL)application:(UIApplication *)application | |
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
//–insert a delay of 5 seconds before the splash screen disappears– | |
[NSThread sleepForTimeInterval:5.0]; | |
// Override point for customization after application launch. | |
// Add the view controller’s view to the window and display. | |
[window addSubview:viewController.view]; |
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
# OAuth认证包括以下四步内容 | |
# 1. 获取Request Token | |
# 2. 用户确认授权 | |
# 3. 换取Access Token | |
# 4. 访问受限资源 | |
require 'rubygems' | |
gem 'oauth','0.4.3' | |
require 'oauth' |
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
# Douban OAuth认证包括以下四步内容 | |
# 1. 获取Request Token | |
# 2. 用户确认授权 | |
# 3. 换取Access Token | |
# 4. 访问受限资源 | |
require "rubygems" | |
gem 'oauth','0.4.3' | |
require 'oauth' |
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
- (void) fadeOut: (id) sender | |
{ | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
[UIView beginAnimations:nil context:context]; | |
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; | |
[UIView setAnimationDuration:1.0]; | |
[[self.view viewWithTag:999] setAlpha:0.0f]; | |
[UIView commitAnimations]; | |
self.navigationItem.rightBarButtonItem = BARBUTTON(@"Fade In", @selector(fadeIn:)); | |
} |