很早之前就想有这么一款工具:将apache的.htaccess中的rewrite规则转换成nginx用的。
发现了这么一款工具,挺好用的:http://www.anilcetin.com/convert-apache-htaccess-to-nginx/
刚刚碰到个很奇怪的问题,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,修改其中的代码即可。怎么修改就不提了吧?
今天对于所有的果粉来说是灰色的一天。那位神再也不会站在那舞台上说:”There is one more thing!”
R.I.P Steve Jobs!

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
有时候复制了一个svn库中的目录到其他svn库中,原来的信息也被带过来了(当然可以用export),目录比较多的情况下,手动删除肯定不方面(况且默认还隐藏了.svn – -),其实很简单,使用rm和find命令很快解决问题
cd /some/of/your/folders/
rm -rf `find . -type d -name .svn`
今天Steve Jobs宣布辞去Apple CEO,虽然知道这一天迟早都要到来,不过还是挺遗憾和伤感的。
相信很多朋友想在键盘上直接敲出苹果的Logo,Google了一下,很简单
先按住键盘上的Shift+Alt,然后按下K就可以了
nginx官方有个strip插件,可以去除页面中的空白符(空格,回车,制表符等)
在ubuntu下需要重新编译一下,主要参考:
http://wiki.nginx.org/Modules http://wiki.nginx.org/3rdPartyModules
今天下午发现,在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
