urlencode() {
local l=${#1}
for (( i = 0 ; i < l ; i++ )); do
local c=${1:i:1}
case "$c" in
[a-zA-Z0-9.~_-]) printf "$c" ;;
' ') printf + ;;
*) printf '%%%.2X' "'$c"
esac
done
}
urldecode() {
local data=${1//+/ }
printf '%b' "${data//%/\x}"
}
PHP Coding Standards Fixer 是在不破壞相容性的情況下,將 PHP 的程式碼往 PSR-2 的方向修正。
安裝的方式很簡單,直接抓下來:
wget http://cs.sensiolabs.org/get/php-cs-fixer.phar -O php-cs-fixer
chmod a+x php-cs-fixer
看是要丟到 /usr/local/bin 下,還是丟到自己的目錄裡都可以。
裝完後就玩:
php-cs-fixer fix foo.php
如果 PHP 程式碼有進版本控制系統,在執行後就可以用 diff 看看改了什麼。
也可以對整個目錄修正:
php-cs-fixer fix foo/
預設是 PSR-2 以及一些作者自訂的規則,如果要強制只用 PSR-2 的話可以用 --level=psr2:
By default, all PSR-2 fixers and some additional ones are run.
有一些要注意的地方是,php-cs-fixer 因為是在不破壞相容性的前提下修正的,所以有些 method naming 的規則就無法修。不過比起手動修正 legacy code,可以省下不少時間…
From http://kalug.linux.org.tw/
HTML 看到縮成一排, 要拉出來檢查比對, 看看是否有漏掉某些 HTML Tag 得結尾, 有沒有工具可以自動將 HTML 格式化, 做好縮排呢? HTML Tidy 就可以做這樣子的事, HTML Tidy 可以將 HTML Tag 做巢狀式的 Indent(縮排), 看起來就會清爽許多.
From http://sites.google.com/site/neotechni/Home/playstation#TOC-Grip
FUNCTION # 1
Button Configuration
The ASCII Grip button configuration can be arranged to the following three choices. After you have changed the arrangement, it stays that way even after turning the PlayStation off. The configuration only changes if you manually reconfigure it.
Arrangement 1 - Standard Arrangement
This is the arrangement when the product was purchased.
To select this arrangement from arrangements 2 or 3, hold the SELECT and START button down, simultaneously, while turning on the PlayStation.
Arrangement 2
Press the SELECT button while turning on the PlayStation.
Arrangement 3
Hold the START button down while turning on the PlayStation. This arrangement allows you to use the programmable buttons.
FUNCTION # 2
Programmable Buttons
The programmable buttons can only be used in arrangement 3. The back buttons, which are the O and X buttons (in the standard arrangement), become programmable button 1 and programmable button 2. The programmable buttons can memorize all the buttons you were pressing while you turned on the PlayStation.
To erase the settings of the programmable buttons, press only the programmable buttons you want to erase while turning on the PlayStation.
NOTES:
The programmable buttons cannot memorize the directional pad or other programmable button.
Even when the button arrangement is changed, the settings for programmable button 1 and programmable button 2 are maintained when arrangement 3 is resumed.
When programmable button 1 and programmable button 2 are both pressed while turning on the PlayStation, programmable button 1 always takes precedence.
When you set the programmable button while in arrangement 1 or 2, it automatically switches to arrangement 3.
From http://bigacid.wordpress.com/2008/12/08/jm20337-read-data-corruption-solution/
Some time ago I bought hard drive enclosure. To my surprise recently I’ve found out that read operation is giving random corrupted data, in other words if you copy data from IDE HD connected to that enclosure, your fill will be corrupted on target media. Without any hope that I will get some answer, I wrote an e-mail to enclosure chipset vendor –JMicron. To my second surprise I got immediate response from very kind person Alex Lee working in that company. He was very prompt and professional and eventually helped to fix the problem, which was enclosure vendor design issue rather than chipset. I will share with this information just in case if some one else need it.
The enclosure box I bought is below. The model NTY-M35HD. I bought it from South Korean local market online, through gmarket.co.kr.
The chipset used is JM20337.
Some PCB pictures of my enclosure.
And here goes recommended patch, click on the picture to see full size. Basically you have to remove resistor R15 4.72k.
Click on the picture to zoom and see that resistor.
Right after patch I have created a batch file for continuous reading / comparing over 2 days and not a single error.
So I want to thank Alex Lee for his great work and JMicron company for amazing products which I believe are leading in the market.