Gem::RemoteFetcher::FetchError

部署rails应用提示错误:

Gem::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0 state=unknown state: sslv3 alert handshake failure (https://d2chzxaqi4y7f8.cloudfront.net/gems/activesupport-3.2.2.gem)

问题渊源及解决方法:
http://www.ruby-lang.org/en/news/2012/04/20/ruby-1-9-3-p194-is-released/
http://railsapps.github.com/openssl-certificate-verify-failed.html

在/etc/gemrc或~/.gemrc里面添加一行

:ssl_verify_mode: 0

或者

$ rvm pkg install openssl
$ rvm install 1.9.3-head --with-openssl-dir=$rvm_path/usr
$ rmdir $rvm_path/usr/ssl/certs
$ ln -s /etc/ssl/certs $rvm_path/usr/ssl

MySQL数据库定时备份的shell脚本

MySQL数据库定时备份的脚本,仅仅保留30天之内的备份,比较简单,对05年的备份脚本进行了一些修改:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
curdate=`date +%Y-%m-%d_%H-%M`
backupdir="/opt/backup"
databasename="database"
username="root"
password="--skip-password"  # use "-pxxxxx" if password isn't empty
#the number of days to keep backups
keepbackups=`date -d '30 days ago' +%Y-%m-%d`
 
echo =====================
echo Start backup MySQL DB
mysqldump -u${username} ${password} ${databasename} > ${backupdir}/${databasename}_${curdate}.sql
echo Done.
 
echo Deleting old backups
cd $backupdir
find . -name "${databasename}_${keepbackups}*" | xargs rm -rf
echo Done.
echo =====================

RouterOS commands

/ip firewall nat print

/ip firewall nat add chain=srcnat out-interface=Wan action=masquerade
/ip firewall nat add chain=dstnat action=accept protocol=tcp dst-port=1723
/ip firewall nat add chain=dstnat action=accept protocol=gre

ip firewall service-port print

/ip firewall service-port enable gre
/ip firewall service-port enable pptp

办公室的路由总是无法连接VPN,找了些命令来开启gre协议和pptp协议以及1723端口。

jQuery.postJSON causes HTTP Error 400 (Bad Request)

The page prompts:
400 (Bad Request)
The request sent by the client was syntactically incorrect ()

The links below are not helpful:
http://stackoverflow.com/questions/5930894/can-jackson-be-used-with-spring-mvc-3-0-to-also-bind-the-requestbody-to-a-java-b
http://stackoverflow.com/questions/5908466/jquery-spring-mvc-requestbody-and-json-making-it-work-together

The solution:
On the JavaScript client side, we have to initialize all the fields of that populated object before it goes into java server side. Please also remember that, the attribute names must be the same with client and server side.

facebook app (3)

最近一直没抽出时间来,这款app于是停滞不前了。
现在需要写的功能主要有:
Native JSON Feed Render (用来包装Facebook传回的JSON数据列表)
Dynamically load more items to the ListView (在列表页自动加载更多条目,类似自动下翻页)
Facebook的Like & Comment功能(需要user access token以及graph api)

暂时收集资料,明天处理,这周末怎么都要解决掉它们。
http://stackoverflow.com/questions/8469482/android-facebook-friend-profile-picture-inflate-in-listview
http://p-xr.com/android-tutorial-dynamicaly-load-more-items-to-the-listview-never-ending-list/

深圳欧雅老板跑路,据说欠债7个亿

三月初,惊闻深圳欧雅二手车行老板钟水雄跑路了,据说欠债7个亿,这其中还有部分是公司上上下下员工的工资。相关新闻报道在这里这里,还有这里

具体跑路原因,恐怕只有通过时间才能慢慢揭开谜底了。08年中我借着帮欧雅建设网站的机会见过他几面,话语不多,不过当时看着他天天坐在公司上班,又加上白手起家的往事,确实还是比较佩服他。
至于现在,因为真相不明,也就不好妄下定论了。
恰好整理手头的一些工作,看到欧雅网站的数据躺在服务器里,于是好奇的想知道当时欧雅的经营状况,查看下汽车的销售记录:


Continue reading

Android地图App演示版开发日志

近来有朋友相托,有意向开发Android手机的地图应用。
于是在湖南文理学院计算机系李志亮同学的大力支持下,我们做了个Demo版。
目前所具有的演示功能有:
1) 用户注册
2) 用户登录
3) 在地图中显示手机用户的当前位置(红色标记)
4) 在地图中添加新位置(绿色标记)
5) 根据地图中的经纬显示地名
6) 地图放大/缩小
7) 地图移动

上图了:
Continue reading

升级到Mountain Lion 10.8 dp1

尝鲜一把,结果xcode4.3不能用了。git/hg等都没了,重装它们又木有command line tools。只好借OSX GCC Installer 10.7-v2版本来应急,下载安装后,一切正常。

顺便解决下最近的mysql2 gem的问题:

gem install mysql2 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

安装完毕,启动rails server提示错误:libmysqlclient.18.dylib (LoadError)
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql-5.5.21-osx10.6-x86_64/lib/libmysqlclient.18.dylib ~/.rvm/gems/ruby-1.9.3-head/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
问题消失。

最后顺带报告下,10.8中的mac qq 2.0无法正常运行,在聊天窗口输入信息时不时会crash。另外打开qzone个人中心也会导致safari 5.2重置所有打开的page。

2012-03-18 update:
dp1每次重新启动进入系统以后,都只剩下“美国英文”的输入法。如需中文输入法,还要在输入法设置中重新勾选。
据说dp2中没有这些问题了,包括qq crash等。