场景:在修改页面有reset按钮,在提交数据之前,行为正常。程序采用了服务器端验证,当验证失败时会自动将数据返回到页面,这时候做了任何修改,再按reset按钮就会将数据充值到服务器返回的之前验证失败的数据。 希望的结果: 1. validation发生之前及之后,reset都会将数据重置到原来的状态 2. 验证失败时,会将错误信息返回,并将之前输入的信息带回到录入页面上
Install Fcitx Under English Locale
I compiled fcitx 4.0.1 myself and installed it to /usr/local prefix and created \~/.xinput.d/fcitx with following content
XIM=fcitx
XIM_PROGRAM=/usr/local/bin/fcitx
XIM_ARGS=""
GTK_IM_MODULE=xim
QT_IM_MODULE=xim
notice here, when using im-switch like most articles did, it created a wrong link combining a path in etc, so I created a link by myself, like this:
ln -s ~/.xinput.d/fcitx ~/.xinput.d/en_US
and add en locale into gtk.immodules in /usr/lib/gtk-2.0/2.10.0/gtk.immodules like this find the xim line, add en to the last field
"xim" "X Input Method" "gtk20" "/usr/share/locale" "en:ko:ja:th:zh"
restart X server by , it should work now. btw: There’s no need to uninstall ibus, by my experience
Wordpress Permissions for Auto-Upgrade Fix
The Problem was mainly caused by function get_filesystem_method in wp-admin/includes/file.php. The method used userid to determine whether to use direct method or ftp method, which caused the ftp information page showed on selecting a plugin install or upgrade. Therefore, put a
define('FS_METHOD', 'direct');
in wp-config.php file will force wordpress to use direct filesystem access method. So here is the permission scheme I used in my blog. I use my system user as the directory owner, and set the group of the directory to group httpd or www-data. Then give write access to group on wp-contents directory, also set the stick bit, so that temporary folder created by wordpress can also accessed. Below is the commands I used
sudo chgrp -R apache /var/www/wordpress
sudo chmod g+ws /var/www/wordpress/wp-contents
Main Reference: Wordpress Permissions for Auto-Upgrade | Charles Hooper. Official Manual explaining FS_METHOD: http://codex.wordpress.org/Editing_wp-config.php#Override_of_default_file_permissions
各种流行的编程风格 | 酷壳 - CoolShell.cn
Vim与实用主义
刚刚看了一篇贴,vim的用户的脑子,讽刺的是那些因为自己会使用vim或者emacs而感到沾沾自喜的人,或是不停争论最好的编辑器是vim还是emacs的人。工具毕竟是工具,就像是哈利波特选魔杖,最华丽的材料不见得打造出最趁手的杖。拿vim来说,打1w个插件,真正常用的甚至能用上的又有几个。文章里面讲了一个个用vim的阶段,我也曾经沾沾自喜,也曾经是插件狂人,甚至就连前几天也因为一两个插件能完成某些IDE的功能向别人炫耀,路还很长。 今天被采薇问到对于软件设计的感觉,我斩钉截铁的说出了设计一定是为项目服务的,而不是一个项目只是为了验证或者使用一个设计。我们是工匠,就要拿出工匠的范儿来,不能让工具驾驭了我们的脑袋。好的工匠喜欢用自己熟悉的工具,但是工匠的思想是跟工具无关的。用张小泉的刀还是双立人的刀,最后能显示本事的是刀口,是菜品的质量。 另外,我认为一个好的工匠的一个重要特质就是不偏执,我曾经是一个对于技术非常偏执的人,喜欢的技术会拼命的维护它。比如Hibernate,比如spring,我曾经相信他们可以解决一切问题。后来发现,再好的技术也要用在合适的项目里面。今天看了好多.net的东西,不能不说,我确实很佩服微软的技术,看了sync framework,还有ado.net里面的乐观锁机制,可以让程序员没有感知的情况下,天才的解决了许多问题。尽管这样,仍然不喜欢微软的产品,仍然喜欢linux,这就是偏执了吧。
关于OOP的反思
2010/12/oop.md at master from raganwalds homoiconic - GitHub我们过去被授予的关于OOP的思想是对是错?
前几天笔试的一道题目
据说是算法导论上面的 Professor Diogenes has n supposedly identical VLSI[1] chips that in principle are capable of testing each other. The professor’s test jig accommodates two chips at a time. When the jig is loaded, each chip tests the other and reports whether it is good or bad. A good chip always reports accurately whether the other chip is good or bad, but the answer of a bad chip cannot be trusted. 下面是网友给出的中文,也就是笔试遇到的题目 有n个处理器,其中好的处理器比坏的处理器至少多一个,现在有一个测试器,测试器每次可以同时插两个处理器记为A和B,A,B两个处理器测试的时候,好的处理器可以准确的告知另外一个是好是坏,坏的处理器给的结果不可信,请设计一个算法,识别处理器中所有好的处理器 参考解法:http://topic.csdn.net/u/20100415/23/0e50a116-bee0-44a0-9b4e-86c57fa48aab.html 如果A,B两个处理器显示对方均是好的,那么A和B要么都是好的,要么都是坏的 否则,A和B至少有一块是坏的 策略很简单,不停的拿2块来测,如果显示结果有一块是坏的,就把这两块拿出来(至少有一块是坏的),剩下的还满足好的占一半以上这个条件,不停的重复这一过程,最后剩下的应该是两两互相都显示是好的 这样至少可以找到一块好的,然后再跟其他所有的测试一遍就能把所有的好的都找出来 测试的策略安排得当的话可以达到线性复杂度
代码优化概要 | 酷壳 - CoolShell.cn
修复 Ubuntu 9.10里的Flash无法点击问题_Linux 无忧时代
Ubuntu Geek