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
class Polygon | |
@@sides = 10 | |
def self.sides | |
@@sides | |
end | |
end | |
puts Polygon.sides # => 10 | |
class Triangle < Polygon |
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
# 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 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
require 'rubygems' | |
require 'httparty' | |
APP_KEY = "48578869" | |
class Sina | |
include HTTParty | |
base_uri "api.t.sina.com.cn" | |
default_params :source => APP_KEY |
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
#define activityViewTag 0x98751234 | |
@interface UIView (UIViewUtils) | |
- (void)showActivityViewAtCenter; | |
- (void)hideActivityViewAtCenter; | |
- (UIActivityIndicatorView*)createActivityViewAtCenter:(UIActivityIndicatorViewStyle)style; | |
- (UIActivityIndicatorView*)getActivityViewAtCenter; | |
@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
require 'rubygems' | |
require 'net/http' | |
require 'digest/md5' | |
require 'json' | |
API_KEY = "679826437258ff2c66d19e28a96c55fa" | |
SECRET_KEY = "830f73caf91179b68106fa5bcf0de4ce" | |
SESSION_KEY = "23536043_100001974_23536043_1284951867_701ca12bcf155352212387aec74c99e6" | |
API_SERVER = "http://rest.kaixin001.com/api/rest.php" |
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 /etc/apache2/httpd.conf | |
# restart | |
sudo apachectl restart |
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
#pragma mark - | |
#pragma mark MKMapViewDelegate | |
- (void)showDetails:(id)sender | |
{ | |
[self.navigationController setToolbarHidden:YES animated:NO]; | |
// navigation to detail view | |
} | |
- (UIImage *)resizeImage:(UIImage *)flagImage |
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 <QuartzCore/QuartzCore.h> | |
[self.content.layer setBackgroundColor:[[UIColor whiteColor] CGColor]]; | |
[self.content.layer setBorderColor:[[UIColor grayColor] CGColor]]; | |
[self.content.layer setBorderWidth:1.0]; | |
[self.content.layer setCornerRadius:8.0]; | |
[self.content.layer setMasksToBounds:YES]; | |
self.content.clipsToBounds = YES; | |
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
- (NSIndexPath *)indexPath | |
{ | |
NSUInteger row = [sender tag] - 300; | |
NSUInteger section = 0; | |
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section]; | |
return indexPath; | |
} | |
- (void)removeCellAtIndexPath:(NSIndexPath *)indexPath | |
{ |