十一 112011
 

刚刚碰到个很奇怪的问题,iPad发出的网络请求无法获取User-Agent,而使用浏览器去请求就可以正常获取。
iPad中,是使用ASIHttpRequest去发出请求的,NSLog了一下User-Agent,发现其中有中文,因为如果没有指定ASIHttpRequest发出的请求的User-Agent的话,ASIHttpRequest会默认的建立一个User-Agent。
结构是:appName, appVersion, deviceName, OSName, OSVersion, locale
其中appName默认是CFBundleDisplayName,这个在中文程序中一般为中文。所以只要修改这里就可以了。
在ASIHttpRequest.m的第4091行可以看到+ (NSString *)defaultUserAgentString 这个getter,修改其中的代码即可。怎么修改就不提了吧?

062011
 

今天对于所有的果粉来说是灰色的一天。那位神再也不会站在那舞台上说:”There is one more thing!”
R.I.P Steve Jobs!

 Posted by at 3:43 下午
052011
 

monit是一款非常不错的进程监控程序,占用资源极少。官网:http://mmonit.com/monit/

可以使用monit来监控系统负载,进程是否正常运行等。

最近每天凌晨使用crontab统计数据的时候,map reduce 计算过大,容易造成mongodb崩溃,在没有检查出明确的问题之前,为了确保正常运行,所以需要在mongodb挂掉的时候自动重启,因此就找到了这么一段脚本(From:https://gist.github.com/345611


check process mongodb with pidfile /db/path/mongod.lock
group database
start program = "/etc/init.d/mongodb start"
stop program = "/etc/init.d/mongodb stop"
if failed host 127.0.0.1 port 28017 protocol http
and request "/" with timeout 10 seconds then restart
if 5 restarts within 5 cycles then timeout
312011
 

有时候复制了一个svn库中的目录到其他svn库中,原来的信息也被带过来了(当然可以用export),目录比较多的情况下,手动删除肯定不方面(况且默认还隐藏了.svn – -),其实很简单,使用rm和find命令很快解决问题



cd /some/of/your/folders/

rm -rf `find . -type d -name .svn`

252011
 

今天Steve Jobs宣布辞去Apple CEO,虽然知道这一天迟早都要到来,不过还是挺遗憾和伤感的。

相信很多朋友想在键盘上直接敲出苹果的Logo,Google了一下,很简单

先按住键盘上的Shift+Alt,然后按下K就可以了



 Posted by at 11:24 下午
162011
 

原文是Apple 的 Custom Icon and Image Creation Guidelines 做一下备忘吧

给retina屏幕用的图标的命名是@2x哦,曾经犯了个错,写成了@x2,显示不正确=。=

自定义图标尺寸
描述 Size for iPhone and iPod touch (in pixels) Size for iPad (in pixels) 指南
Application icon (required) 57 x 57

114 x 114 (high resolution)

72 x 72 “Application Icons”
App Store icon (required) 512 x 512 512 x 512 “Application Icons”
Small icon for Spotlight search results and Settings (recommended) 29 x 29

58 x 58 (high resolution)

50 x 50 for Spotlight search results

29 x 29 for Settings

“Small Icons”
Document icon (recommended for custom document types) 22 x 29

44 x 58 (high resolution)

64 x 64

320 x 320

“Document Icons”
Web clip icon (recommended for web applications and websites) 57 x 57

114 x 114 (high resolution)

72 x 72 “Web Clip Icons”
Toolbar and navigation bar icon (optional) Approximately 20 x 20

Approximately 40 x 40 (high resolution)

Approximately 20 x 20 “Icons for Navigation Bars, Toolbars, and Tab Bars”
Tab bar icon (optional) Approximately 30 x 30

Approximately 60 x 60 (high resolution)

Approximately 30 x 30 “Icons for Navigation Bars, Toolbars, and Tab Bars”
Launch image (required) 320 x 480

640 x 960 (high resolution)

For portrait:

  • 768 x 1004

For landscape:

  • 1024 x 748
“Launch Images”
142011
 

今天下午发现,在UITabBar的子显示对象的- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 有点问题,屏幕旋转了,只是调用了UITabBar的shouldAutorotateToInterfaceOrientation,容器内部的显示对象并不会做出反应。那么只能检测屏幕的旋转事件了再做出相应的动作了

 



// Do any additional setup after loading the view from its nib.

//----- SETUP DEVICE ORIENTATION CHANGE NOTIFICATION -----

UIDevice *device = [UIDevice currentDevice]; //Get the device object

[device beginGeneratingDeviceOrientationNotifications]; //Tell it to start monitoring the accelerometer for orientation

NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; //Get the notification centre for the app

[nc addObserver:self //Add yourself as an observer

selector:@selector(orientationChanged:)

name:UIDeviceOrientationDidChangeNotification

object:device];

 

 

 



- (void)orientationChanged:(NSNotification *)note

{

UIView *ftView = [self.view viewWithTag:200];

if([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft || [[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)

{

[ftView setFrame:CGRectMake(0, 0, 480, 200)];

}else

{

[ftView setFrame:CGRectMake(0, 0, 320, 360)];

}

}

 ref:http://www.ios-developer.net/iphone-ipad-programmer/development/notifications/orientation-change-notification
 Posted by at 6:01 下午  Tagged with: