mysql小工具openarkkit

Standard

下载地址 http://code.google.com/p/openarkkit/

oak-apply-ri: apply referential integrity on two columns with parent-child relationship.
oak-block-account: block or release MySQL users accounts, disabling them or enabling them to login.
oak-chunk-update: perform long, non-blocking UPDATE/DELETE operation in auto managed small chunks.
oak-get-slave-lag: print slave replication lag and terminate with respective exit code.
oak-hook-general-log: hook up and filter general log entries based on entry type or execution plan criteria.
oak-kill-slow-queries: terminate long running queries.
oak-modify-charset: change the character set (and collation) of a textual column.
oak-online-alter-table: perform a non-blocking ALTER TABLE operation.
oak-prepare-shutdown: make for a fast and safe MySQL shutdown.
oak-purge-master-logs: purge master logs, depending on the state of replicating slaves.
oak-repeat-query: repeat query execution until some condition holds.
oak-security-audit: audit accounts, passwords, privileges and other security settings.
oak-show-limits: show AUTO_INCREMENT “free space”.
oak-show-replication-status: show how far behind are replicating slaves on a given master.

记下备用.

phpsysinfo on my vps

Standard


在本站当前所在VPS下装了个用PHP做的用于查看系统信息的小工具.
今后要是需要用PHP做一些系统管理后台时可以参考.

官方链接: http://sourceforge.net/projects/phpsysinfo/

Happy Birthday to me

Standard


一早打开邮箱就收到公司的邮件贺卡,提醒自己时间真是越过越快.
一晃就虚岁30喽~
想想之前上学时的那些个小目标基本也算是达成了.
等再那么十年一晃的时候~
我想~ 全家庭和睦身体健康~ 收入翻N番~ 换更大的house~ 等等好多好贪的目标,哈~

CentOS下Tomcat7+Solr3的安装配置

Standard

下载

wget http://mirror.bjtu.edu.cn/apache/lucene/solr/3.1.0/apache-solr-3.1.0.tgz
wget http://labs.renren.com/apache-mirror/tomcat/tomcat-7/v7.0.12/bin/apache-tomcat-7.0.12.tar.gz
tar zxvf apache-solr-3.1.0.tgz
tar zxvf apache-tomcat-7.0.12.tar.gz
mv apache-solr-3.1.0 /usr/local/solr
mv apache-tomcat-7.0.12 /usr/local/tomcat

配置

vi /etc/profile
#加在最底下
export JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk
export CLASSPATH=.:$JAVA_HOME/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
export TOMCAT_HOME=/usr/local/tomcat
export JAVA_OPT="$JAVA_OPTS -Dsolr.solr.home=/usr/local/solr/example/solr"
cp /usr/local/solr/dist/apache-solr-3.1.0.war /usr/local/tomcat/webapps/solr.war
 
vi /usr/local/tomcat/conf/Catalina/localhost/solr.xml
<Context docBase="/usr/local/tomcat/webapps/solr.war" debug="0" crossContext="true">
    <Environment name="solr/home" type="java.lang.String" value="/usr/local/solr/example/solr" override="true" />
</Context>
vi /usr/local/solr/example/solr/conf/solrconfig.xml
#初始
<dataDir>${solr.data.dir:}</dataDir>
#修改为
<dataDir>${solr.data.dir:/usr/local/solr/example/solr/data}</dataDir>
vi /usr/local/tomcat/conf/tomcat-users.xml
#去掉注释块,加入以下内容
  <role rolename="admin-gui"/>
  <role rolename="admin-script"/>
  <role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <role rolename="manager-jmx"/>
  <role rolename="manager-status"/>
  <user username="tomcat" password="s3cret" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-script,admin-gui"/>

启动
/usr/local/tomcat/bin/startup.sh

浏览
http://localhost:8080/manager/status

http://localhost:8080/solr/

转载请注明出处:http://yemaosheng.com

Confessions of your worst WTF moment 摘录

Standard

原贴链接: http://stackoverflow.com/questions/63668/confessions-of-your-worst-wtf-moment

No.1
Our product was used by police forces to input data about people that are arrested and what they are charged with. It would also store digital mugshots and fingerprints, and electronically submit the fingerprints to the FBI. While testing, we would routinely use our own fingerprints for fake bookings that got inserted into the test database. Except for the time that I “temporarily” switched the test machines over to the production database and forgot to switch them back…

Cleaning up our production database was easy, but it took a court order signed by the superintendent of the Boston Police Department to remove my colleague’s fingerprints from the FBI database — she had booked herself under the name “Elroy Jetson”.

No.2
I was given a GPS system that was used on ships and given the task of getting a program to interface with it and collect co-ordinates. We didn’t have a manual for the device, but once I got it powered on, I found a big help button. I thought that might at least get us started with how to use it.
After pressing the button, it beeped a couple of times, and then the screen started flashing: Sending S.O.S. signal
Gosh damn – I unplugged the power cable, hoping the thing would turn off, but it must have had an emergency battery inside, because it carried on going, and there was no stopping it.
I waited, very anxiously, expecting a Sea King helicopter to appear outside the office at any moment, wondering how I was going to explain what had happened.
Fortunately – either because I was indoors and the signal didn’t get through or because the receiver of the signal realized an S.O.S. originating 100 miles inland probably wasn’t a real shipping incident – no sea king turned up. Phew.

No.3
I had just imported a bunch of old data into a new system, had taken about 5 hours and was due to go live two hours later, this was around 4 in the morning.
For some reason I tried to delete something:
DELETE from important_table; where id=4
Yeah, I didn’t notice the semicolon either. And no, there was no safety net.

No.4
I shipped my administrator password for an FTP site inside an open source project I was working on.

No.5
I worked for a large bank and added an error message to a piece of code that the application should never have been able to reach (theoretically)…
One Monday morning the unthinkable happened. The error message was proudly displayed on over 10,000 monitors across 1800 branches, and would return when you dismiss the message.
The message read: “If you can see this message the system is all F**KED UP and we might as well go home. Have a nice day.”
Thank goodness this happened before source control systems were implemented at the bank.

No.6
I was logged into my new dedicated server box and configuring some firewall rules over ssh. The first thing I did was set it to not accept any connections from anyone. Then I saved it to test that before going through and adding the various ports I wanted to allow.
Needless to say, the first rule worked…

No.7
When I set up a new VMware instance at the evening and went home keeping it running. What I didn’t noticed was that I used the IP of the Nameserver as IP of the VMware instance. Suddenly all hosts in our building tried to connect to the VMware for DNS lookups.
Our whole network was practically down.
Since this was a VMware our Admins were not able to track down the MAC address. So they had to plug off every single computer in our office (~500) until the problem was gone.
At the next day I found a letter on my desk: “Who dares to switch this computer on will die”.

No.8
Near the end of the dot com bubble, my company was doing research on a sector of the market. We had been given a database with company names in that sector, and we weren’t sure if many of them were still viable companies. I wrote a quick and dirty app which looped through the database and tried the URLs to see if it got a valid response… the assumption being that a 404 would be a failed company. The app used the IE browser COM component and actually displayed the pages while it processed. I split the database into three sections and set it to run on three machines beginning at the close of business and running overnight. My cube was extremely proximate to the CEO and CFO.
Upon arrival the next day, I discovered that the database was not at all accurate. Apparently it was open to the public for update, and numerous spammers and porn companies had inserted records and URLs of their own. This, in itself, was not terrible. What was terrible is that many of the pages when loaded, spawned pop-up windows of extremely explicit details and while the program moved on to the next page, the pop-up windows were orphaned and visible for all to see.
I had some ‘splaining to do.

No.9
I rewrote a whole module that was working perfectly but that looked “messy” to me. I had managed to convince my boss that it was the Right Thing To Do, and the rewrite took me 3 weeks.
I still remember the pearls of sweat running from my armpits as my boss, looking over my shoulder, was commenting on bug after bug in my new shiny super-clean module…
I’m no longer “rewriting from scratch” without a really good reason.

No.10
Ooh! Embarrassing confessional time. The first one that comes to mind was shortly after I switched to OS X from years on Windows and had basically forgotten anything I knew about unix.
I was working on a personal project and decided I was at a point where I should backup my stuff. So I opened up the command line:
gzip *.py
Oh man! It zipped every file individually! Right, I have to tar them first. Okay
rm *.gz
Wait! Why is my directory empty?! Oh no….
Yeah, I also forgot that gz doesn’t copy and zip, it zips in-place.
I got lucky, though, and still had most of the files open in my editor.
This was what convinced me to finally install a version control system on my home machine and use it for my own stuff.

No.x…

Gtk+ HTML backend update

Standard

转贴,原文链接:http://blogs.gnome.org/alexl/2011/03/15/gtk-html-backend-update/

The last few days I spent fixing up some more details in the new HTML5 gdk backend. Not everything is supported yet (keyboard input in particular is very weak), but much more things work now. Even thought the backend is not of production quality it is now good enough that I think its interesting for a larger audience to play around with. So, today I merged the branch into the Gtk+ master branch (i.e. what will be Gtk+ 3.2).

The new multi-backends setup in Gtk+ 3.0 makes this much easier to test. All you have to do is build Gtk+ with –enable-x11-backend –enable-broadway-backend.This will give you a normal X11-based Gtk+ where you can enable the broadway backend at runtime by setting the GDK_BACKEND enviroment variable.

The backend only supports firefox 4 atm, and Mozilla disabled websockets by default, so you have to enable enable websockets for any input to work. However when this is done you can test any app by running:

GDK_BACKEND=broadway your-application&
firefox http://127.0.0.1:8080/
I recorded a small screencast to show this stuff:

Note that the recording is using a local connection, it will be slower over the network depending on the network bandwidth.

warning: Can’t open file ‘/root/.subversion/servers’ …

Standard

我们用PHP写了个Release界面用来做svn up及rsync操作,之前运行正常,今早发现报错如下:
warning: Can’t open file ‘/root/.subversion/servers’: Permission denied

解决方法:
因为php以apache用户运行,所以最简单的办法就是直接把config-dir放到apache目录下
svn status –config-dir /etc/apache/.subversion;
svn info –config-dir /etc/apache/.subversion;

乐风AT的经验贴

Standard

下面这贴子写得不错,很详细。
不知这贴何时会删或沉,请容许我稍微整理转载于此方便查找。
此外,还加了些别处搜到内容。
原贴链接 http://bbs.auto.sina.com.cn/329/216/thread-2013338-1-1.html

选车原则

1、日X车不考虑,韩X车更不考虑。
2、油耗不考虑,因为用的少,一年省不了几个钱。就算100KM省2升,一年也就省1000元。
很多打着省油号子的车,车价贵1-2万元,用10年车都省不回来。
还有些靠减轻重量来省油的车就更不值得了,安全要紧。
3、外观要好看,虽然很多两厢车很好看,本人偏爱三厢车。
因为要用5年以上,外观要耐看,毕竟不是随便就换的衣服。
有些车新的时候好看,过了几年,觉得很难看。
4、性能安全,质量可靠,操控性好。
5、经过市场考验的,销量好的。
6、不要太贵。车是自己用的,够用就行。
在发达国家,几个月的工资能买一辆不错的新车,我们要几年的工资,很冤。
越贵的、功能越多的车(特别是那些附加的机械和电子功能),维护费用也越高。
7、不要天窗,一年用不了几回。
8、要AT自动车。LP不会开MT手动车,连AMT也开不好。
因为AMT的车要加油才走,慢速不好控制,右脚要在油门和刹车间变换。
虽然新赛欧的EMT自动车在AMT上加了专利的爬行功能,但上市不久,未经考验。

选定乐风2010款1.4AT

乐风外观不错,前脸完全是雪佛兰的风格。
乐风1.4发动机的功率和扭矩与1.6的捷达差不多,选择1.4就够了。
两者都是低速高扭矩特性,1.6的捷达满载时,上山很轻松,适合城市路况。
两者大小及空间也差不多。
乐风比捷达:短7厘米,高9厘米,宽1.6厘米,轴距长1厘米,空间要大些。

试驾后,感觉不错,操控性好,油门、方向很轻,刹车很好。
网上看到有人说刹车软,应该是不熟悉ABS刹车的原因。
为了防止车轮抱死,与没有ABS时的点刹不同,ABS只要一直踩住刹车,效果会很好。
乐风的车身调校的有些偏硬,底盘较高,适合各种路况,通过性好。
隔音不错,发动机盖和尾箱盖都有隔音层。
A柱有点宽,习惯后就好了。
4喇叭音响也不错。
其他:
4个电动车窗,2个电动后视镜,方向盘可调,遥控防盗门锁,中控锁,驾驶座椅高低可调,后排座椅可向前放倒使尾箱空间扩大,遥控油箱门开锁,遥控尾箱开锁,
关门提醒,未拔钥匙提醒,后窗隐形天线。

总结

1、乐风安全性高,车身稳固。
车重1145公斤(比捷达重54公斤),沉稳,没有飘的感觉。
车头和车尾都有保险杠和吸能装置,做到对乘员和行人的保护。
侧面防撞杆,整体式车门,后排椅背中镶嵌钢板,安全第一。
门重,把手宽大,关门声厚实。耗油多点也值了。
前排前面和侧面4个安全气囊。
安全带提醒。驾驶座及副驾驶座坐人后,时速20KM发出提醒。
曾经想买两个安全带扣插上去做装饰,后来决定不买,再麻烦也要系上安全带。
后视镜够大。
灯光不错。
前雾灯,在雾天时,可以看清车头左右。
后雾灯、高位刹车灯、两个倒车灯,让后车看清你,安全。
2、动力足够,满载5个人,开冷气,开起来很轻松。
3、仪表盘上没有操纵杆位置显示,有点遗憾。不过习惯后,也不需要看仪表盘。实际上很多的车型是没有显示的。
操纵杆曲线设计,从N到R要按下操纵杆,防止误碰误操作,保护人员及车辆。
操纵杆设计合理,前行时,操纵杆向后拉到不动,就是D4,不需要看仪表盘。
取消了操纵杆头上的从P移出的释放按钮,点火后,踩住刹车才能移出。
在不驻车的情况下要把操纵杆从P移出,必须撬开操纵杆解锁开关的小盖板,插进车钥匙释放,防止误操作。
起步:
钥匙插进后,在ON位置停留几秒钟,让电脑及其他电气设备通电,等提示音停止后:
点火、预热30秒、踩脚刹、操纵杆从P一直拉到D4、松手刹、松脚刹。
停车:
踩脚刹停车、操纵杆按下一直推到P、拉手刹、松脚刹、熄火。
4、HOLD保持功能,满足手动换挡需求。
按一下HOLD键,灯亮,此时操纵杆在:
D4 位置时,车一直在3挡运行,不会在1或2挡,
2 位置时,车一直在2挡运行,不会在1挡,
1 位置时,车一直在1挡运行,
这样可以手动在1、2、3挡间变换。
自动时,操纵杆在D4位置,速度较快要超车时,按一下HOLD键,就会切到3挡运行,此时转速加快,扭力加大,轻松超车。
5、开惯后,感觉乐风的刹车很好用。
起步刚松刹车时以及踩刹车后车要停止时,刹车会有响声,很多人以为有问题,其实这很正常,是ABS工作引起的,让人踏实。
ABS防抱死功能在速度快时很有用,有效防止因抱死而发生的甩尾、侧翻和打跟斗的事故。有ABS时,踩死刹车后,刹车距离可能比没有ABS还要短,而且方向盘可控;没有ABS时,踩死刹车后方向盘会失控。
6、座椅较高,坐着舒服。不像有些车好像坐在地板上。
后排座椅加高了,所谓的剧院式设计,使后座更舒服,视野与前排一样。
7、等红灯时,一分钟以内,踩住刹车;一分钟以上,推入P,拉手刹,不用N。
听设计工程师的话,N仅用于需要拖车时或行车中突然熄火后紧急点火。
有关油耗、磨损、发热等问题不用考虑,车子的设计师已经考虑完了。
另外,P位置时:输出轴被锁住,传动轴无法转动,此时不能拖动车辆,否则会造
成自动变速箱损坏。因此,在P位置被追尾时,后果比较严重,所以最好拉起手刹,
手刹的作用是锁住后轮,脚刹是锁住前后轮,万一被追尾时保护变速箱。
8、乐风隔音不错,风噪不是很大。空间安静,冷气舒适,音乐愉快,消除疲劳。
9、如果用钥匙发射器开门解除防盗系统后 30秒未打开车门或未启动发动机,所有车门重新上锁激活防盗系统。
备用钥匙上没有发射器,用钥匙开门后,自动解除防盗系统。
10、这车没有踩刹车落门锁或时速20KM落门锁功能,由驾驶座控制门锁来实现中控
锁功能。建议养成锁门的习惯。因为看过一个视频,一台车被后面的车追尾,
结果门被撞开,驾驶员被甩出车外,估计是没关门锁也没系安全带。
乐风的各个门锁可以手动开关,这个很重要。
当门锁锁了以后,如果不能通过手动拔出门锁开关,万一被困,可能开不了门。
曾经有人被忘记在一辆中级车后排睡觉,这辆车的门锁锁了后开关缩进里面,
手拔不到开关,无法开门。电控的设备,一旦有故障是个麻烦的事。
11、在窗台上发现有透气孔通向尾箱,应该是为安全考虑的,可惜,尾箱逃生拉环没装。万一被困尾箱里,无法逃出。
另外,万一车窗和车门因为某些原因打不开,可以放倒后排椅背,按动驾驶座门侧的遥控尾箱开锁按钮,打开尾箱,通过尾箱逃出。
乐风的尾箱盖要用手拍下才会关闭。不像很多种车的尾箱盖轻轻拉到位置后是会自己关闭的,不需要用手拍。乐风没有这个功能,可能是省掉了助力弹簧的结果。
12、开冷气后,停车前,最好关掉冷气,吹风2分钟,把冷凝器的水吹干,防止异味。
13、新车气味不是特别大,经常开门通风,十几天后就没啥味了,用材还是蛮环保的。
原配的绒布座椅没有异味和异响,不像有些真皮座椅有味和摩擦时有声响。
14、CD机不能播放MP3格式的光盘。
15、油耗:这台乐风新车刚走了400KM,城市路况,平均时速20-30KM,磨合期,一半路程开冷气,平均两个人,用油50升,约12.5升/100KM。
如果按网友的综合油耗,磨合期后10升/100KM,就能接受了。

2011-4-23 注:
提车两个月了,我驾照还没考好,先让我父亲先开着转转。目前共走了一千公里,其中七百公里是高速路。平均百公里油耗8升,没之前一些网站上说得这么高。

乐风油表刻度具体数值图

————————————-

车距判断图文参考

判断轿车前端与人的距离:
以轿车为例,假设前方有一个身高1.7至1.8米左右的人,脚面高在10厘米左右,膝盖高在45厘米左右,臀部在70厘米左右。
1、当你看到车前端由地面向人体脚面或脚跟上移并停留此处时,车前端与人体之间的距离为3米。
2、当你看到车前端升高到人体膝盖高度处时,车前端与人体距离为1米。
3、当你看到车前端升高到人体臀部下端时,车前端与人体之间的距离为0.3米。

判断前车距离:
1、从挡风玻璃下沿看到前车保险杠上沿时约一米

2、从挡风玻璃下沿看到前车保险杠下沿(人的脚膝盖)时约两米;

3、从挡风玻璃下沿看到前车后轮胎下沿(或看到地面)时约三米;

4、从车内通过车窗看到停止线与前门角五厘米处,则车子与路口的停车线对齐

右后视镜判断后车距离:
1、后车影占后视镜全部时,车距约3米;

2、后车影占后视镜三分之二时,车距约5米;

3、后车影占后视镜二分之一时,车距约9米;

4、后车影占后视镜三分之一时,车距约12米;

5、左后视镜看到后轮盖罩中间(后门手握柄、车身横线或后视镜底线反射)相对地面就是车尾位置。
6、通过车内后视镜透视过后窗挡风玻璃下沿判断后车距离:若看到后车大灯上缘,则后尾箱距后车为三米半左右;若看到后车机仓盖与前挡玻璃交界处,则后尾箱距后车为一米;若看到后车前挡玻璃的水平三分之一,则基本靠上了。

判断车辆位置(车轮位置、前后位置):
1、判断路边在挡风玻璃中的位置(左轮在挡风玻璃左柱往右10-15cm位置;右轮在挡风玻璃中心线往左5-10cm位置);离路边距离可以从后视镜看到。


2、判断右轮位置(车头中部或右雨刮器):在车头盖板右边三分一处的相对地面