2010年12月19日 星期日

the precreated templates for OpenVZ

Backup tools for Mac

Carbon Copy Cloner
http://www.bombich.com/index.html

TCFail Snow Leopard 繁體中文系統字體修改工具

2010年12月9日 星期四

CUDA Certification – Exam Scheduling Now Open

CUDA Certification – Exam Scheduling Now Open



NVIDIA CUDA Professional Developer Program Study Guide
As part of the process of achieving the standards expected from an NVIDIA CUDA Professional Developer, all candidates are required to take a series of self-study lectures and exercises.
Please read this entire document before starting your study course.
The foundation of this training is provided by the text book,  Programming Massively Parallel Processors: A Hands-on Approach, authors, David B. Kirk, Wen-mei W. Hwu.
You can also make use of podcasts in mp4 format of the lectures below; the reading assignments will help to make the lecture more productive, so please complete in advance.
  1. Introduction to GPU Computing (60.2 MB)
    1. Assignment please read Chapter 1 of Textbook
  2. CUDA Programming Model (75.3 MB)
    1. Assignment please read Chapter 2 of Textbook
  3. CUDA API (32.4 MB) 
  4. Simple Matrix Multiplication in CUDA (46.0 MB)
    1. Assignment please read Chapter 3 of Textbook 
  5. CUDA Memory Model (109 MB)
    1. Assignment please read Chapter 4 of Textbook 
  6. Shared Memory Matrix Multiplication (81.4 MB) 
  7. Additional CUDA API Features (22.4 MB) 
  8. Useful Information on CUDA Tools (15.7 MB) 
  9. Threading Hardware (140 MB) 
    1. Assignment please read Chapter 5 of Textbook 
  10. Memory Hardware (85.8 MB)
  11. Memory Bank Conflicts (115 MB) 
  12. Parallel Thread Execution (32.6 MB) 
  13. Control Flow (96.6 MB) 
  14. Precision (137 MB)
    1. Assignment please read Chapter 6 of Textbook
    2. Assignment please read Chapter 7 of Textbook
Please download all the documents and files that are relevant to your operating system.
As part of the study process, please ensure you also download and study the following documents:
CUDA C Programming Guide 3.0
CUDA C Best Practices Guide 3.0
CUDA C Online Documentation
Additional CUDA Programming Tools and Compiler Documentation can be found at this link:
http://www.nvidia.com/object/cuda_programming_tools.html
Please download the following additional documents:
CUDA Compiler Driver NVCC 2.0
PTX: Parallel Thread Execution ISA Version 1.2
CUDA Occupancy Calculator
Additional Course Exercises with Solutions (Supports CUDA Basics)
Exercise Instructions
Exercise files for Visual Studio
Exercise files for Mac & Linux
Additional Supporting Materials
NVIDIA is hosting a series of Webinars about the CUDA Architecture.  NVIDIA staff is available during the presentations to answer questions, and the recordings are available for download.
http://developer.nvidia.com/object/gpu_computing_online.html
For technical questions please use the public CUDA developer forums:
http://forums.nvidia.com/index.php?showforum=62

2010年12月8日 星期三

解讀 Drupal 的 hook_menu()

假若  
$items['mypath/%objectA'] = array( ... 

需要實作
function objectA_load() { return $object;}

page callback 就能取得完整 object 或是 array,而非只是 id

參考這篇
Anatomy of hook_menu

2010年12月5日 星期日

使用 php 產生 /etc/shadow 的 hashed password

/etc/shadow 格式
http://www.linux.org.tw/CLDP/HOWTO/admin/Shadow-Password-HOWTO/Shadow-Password-HOWTO-2.html

<?php
// MD5
echo crypt($_GET['password'], '$1$');

2010年12月2日 星期四

SONY VAIO TZ37 無法開啟無線網路。Wireless Keeps turning itself off.



手動把硬體的 wireless/bluetooth 開關設成 off,然後 on,接著就無法使用 wlan,機殼上的 wlan 的燈沒亮,無法使用 VAIO 所附的 wireless switch software 去設定 wlan (只顯示藍芽的部分),而裝置管理員看到的 wlan 網卡又似乎很正常。重灌 intel wlan driver 也沒用。


據 SONY 光華維修中心的工程師說,bluetooth 及 wireless 的狀態,有被記錄在 CMOS 上面,但從 BIOS 又無法設定 on/off,他們猜測是我的系統有問題,以致於進系統後,wireless 又被設成 off。他們搞很久還是無法修復我的 VAIO,建議我重灌 XP。當下接上另一台 TZ37 的硬碟,wireless 卻很正常,最後,唯一能確定的是硬體方面沒問題。


後來回家,在 google 查到以下的方法,確實可行,在此留下記錄,希望可以幫到大家。


- turn the wireless and bluetooth on by the hardware switch or button or Fn+
- close the wireless switch software ( the wireless icon on the windows bar )
- hibernate the laptop (休眠)
- take off the laptop battery and take the power cable off (取下電源線及電池)
- wait for around 1 min. (等待一分鐘)
- turn the hardware switch to on- put everything back in place and start the laptop, you should be able to see the wireless working now. (打開無線網路的硬體開關,接上電源)
- make sure the bluetooth and wireless are working
- go to control panel and uninstall the wireless switch software
- restart you laptop and everything should be working fire and smooth now.


http://www.wirelessforums.org/troubleshooting/sony-vaio-wireless-network-connection-problems-52551.html


結論是,不要安裝 wireless switch software。我現在用硬體開關切換,一切正常。

2010年12月1日 星期三

Compiling with GCC on low memory

 
# 8MB for min heapsize 
CFLAGS="$CFLAGS --param ggc-min-expand=0 --param ggc-min-heapsize=8192" 

Compiling with GCC on low memory VPS

2010年11月30日 星期二

2010年10月21日 星期四

2010年9月7日 星期二

Drupal 用 php 讀取欄位 (CCK) 屬性

<?php

$node_type = 'page';
$cck_video_field = content_fields('field_video', $node_type);
// content_fields( ) in cck/content.module

2010年8月14日 星期六

於下次重開機時,自動執行 fsck

方法一:
# touch /forcefsck
# reboot

方法二:
# shutdown -rF now

2010年8月13日 星期五

sed & awk 的用法

http://www.delightpress.com.tw/bookRead/skns00004_read.pdf

windows 要使用 awk, sed 的話,請下載
http://sourceforge.net/projects/unxutils/
可把 \usr\local\wbin 目錄設定到 PATH

2010年8月11日 星期三

2010年7月14日 星期三

macbook 闔上螢幕時,不進入睡眠

可以安裝這個軟體

insomniax
http://www.macupdate.com/info.php/id/22211/insomniax

2010年7月9日 星期五

Intel 945 支援 1920x1200 (1920x1080)

我的 VAIO TZ37 外接螢幕一直無法支援 1920x1200 (1920x1080) 的解析度
網路上找到這篇 hacking,修改 intel driver 的 .inf ,再重裝 driver,一試之下,果然可行!
步驟很多,要一行一行仔細看

http://komku.blogspot.com/2009/10/how-to-get-1920x1080-full-hd-resolution.html

2010年6月29日 星期二

2010年6月25日 星期五

Python Code (.py) 編成執行檔

使用 pyinstaller 把 .py 原始碼編成執行檔,用來保護原始碼

http://www.pyinstaller.org/%20

http://www.dev.idv.tw/mediawiki/index.php/PyInstaller%E4%BD%BF%E7%94%A8%E7%B0%A1%E4%BB%8B

在 win32 下,可以用 py2exe

2010年6月11日 星期五

轉換 vdi 成為 vmdk

vboxmanage 是 virtualbox 所附的指令
最常看到的是這行指令,但轉出來的 vmdk 無法在 vmware server 1.0.x 中使用  
# VBoxManage internalcommands converthd -srcformat VDI -dstformat VMDK file.vdi file.vmdk
 
以下指令在 virtualbox 3.1.8 產生的 vdi 轉出來 vmdk 可在 vmware server 1.0.8 中使用 
# VBoxManage internalcommands  converttoraw file.vdi file.raw
# VBoxManage convertfromraw  -format VMDK file.raw file.vmdk
缺點是 raw 所佔的空間是固定大小,非動態大小
 
 
 

2010年5月30日 星期日

使用 macport 安裝 flvtool2

http://tech.howcast.com/2008/06/tools-for-adding-keyframe-metadata-to-flash-video-flvs/


macport 沒有 flvtool2,先安裝所需要的 lib,再手動編 flvtool2 原始碼


或是用 yamdi,同樣 macport search 不到,要手動 build
http://yamdi.sourceforge.net/
在 debian 下面,yamdi 處理速度較快

2010年5月19日 星期三

Flipside : 進入 BootCamp 更快的辦法

http://www.frostyplace.com/index.php?story_id=7092

JVM內存段分配,Java垃圾回收調優,Heap設定

http://hi.baidu.com/kingtckingtc/blog/item/ca5606f4decd5767ddc4740b.html

摘錄

1. java -server
2. 設置Xms=Xmx=3/4物理內存
3. 如果是CPU密集型服務器,使用–XX:+UseParallelOldGC, 否則–XX:+UseConcMarkSweepGC
4. 新生代,Parallel/ParallelOld可設大於Xmx1/4,CMS可設小,小於Xmx1/4
5. 優化程序,特別是每個用戶的session中的集合類等。我們的一個模塊中session中曾經為每個用戶使用了一個ConcurrentHashMap, 裡面通常只有幾條記錄,後來改成數組之後,每台機大概節約了1~2G內存。

2010年5月18日 星期二

讓 iTerm for Mac 有 Color

vi ~/.profile
加上
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad

2010年5月1日 星期六

Kill Process by Name

http://www.neurophys.wisc.edu/ravi/software/killproc/

類似 taskkill,但是 taskkill 並非每個 windows 版本都有內建
找了 c 的版本,把它改寫成獨立的工具
此範例只會 kill 其中一個 instance,要刪全部的 instance 要改一下 code

while((iRes=KILL_PROC_BY_NAME(szName)) != 603){
}

2010年4月25日 星期日

Programming Android Application in Scala.

今天在 OSDC 聽到的課程,印象非常深刻,相當認同講者的觀點

2010年4月22日 星期四

ActionScript: Tween Engine

TweenLite, TweenMax
http://www.greensock.com/

Locking a File

http://docstore.mik.ua/orelly/webprog/pcook/ch18_25.htm

$fh = fopen('guestbook.txt','a')         or die($php_errormsg);
flock($fh,LOCK_EX)                       or die($php_errormsg);
fwrite($fh,$_REQUEST['guestbook_entry']) or die($php_errormsg);
fflush($fh)                              or die($php_errormsg);
flock($fh,LOCK_UN)                       or die($php_errormsg);
fclose($fh)                              or die($php_errormsg);


$fh = fopen('guestbook.txt','a')         or die($php_errormsg);
$tries = 3;
while ($tries > 0) {
    $locked = flock($fh,LOCK_EX | LOCK_NB);
    if (! $locked) {
        sleep(5);
        $tries--;
    } else {
        // don't go through the loop again 
        $tries = 0;
    }
}
if ($locked) {
    fwrite($fh,$_REQUEST['guestbook_entry']) or die($php_errormsg);
    fflush($fh)                              or die($php_errormsg);
    flock($fh,LOCK_UN)                       or die($php_errormsg);
    fclose($fh)                              or die($php_errormsg);
} else {
    print "Can't get lock.";
}

2010年4月21日 星期三

Thread-local storage

http://en.wikipedia.org/wiki/Thread-local_storage


Thread-local storage (TLS) is a computer programming method that uses static or global memory local to a thread.
This is sometimes needed because all threads in a process share the same address space. In other words, data in a static or global variable is normally always located at the same memory location, when referred to by threads from the same process. Variables on the stack however are local to threads, because each thread has its own stack, residing in a different memory location.
Sometimes it is desirable that two threads referring to the same static or global variable are actually referring to different memory locations, thereby making the variable thread local, a canonical example being the C error code variable errno.
If it is possible to make at least a memory address sized variable thread local, it is in principle possible to make arbitrarily sized memory blocks thread local, by allocating such a memory block and storing the memory address of that block in a thread local variable.

ProgressBar in Windows

使用 msctls_progress32

在 xp 必須先呼叫
InitCommonControls(); // libcomctl32.a
否則連它 parent 的 Dialog/Window 也不會出現

在 win7 下
不管有沒有呼叫此函式,progress bar 都會出現

2010年4月20日 星期二

最佳化 Flex, Flash

Flex性能優化常用手法總結
http://www.5uflash.com/Flex-AIR/Flexziliao/5577.html

Flash性能優化的一些細節
http://www.5uflash.com/flashjiaocheng/Flashyingyongkaifa/5576.html

2010年4月19日 星期一

Apache 取得透過 Reverse Proxy 的 Client 真正 IP (mod_rpaf)

參考以下兩篇

Apache 取得透過 Reverse Proxy (Varnish) 的 Client 真正 IP (mod_rpaf)
使位在Reverse Proxy後端的Apache 可以取得正確的Client IP -- mod_rpaf-2.0

Debian 安裝如下
apt-get install libapache2-mod-rpaf

修改
/etc/apache2/mods-available/rpaf.conf

2010年4月15日 星期四

Fail2ban

看到 apache.org 的 JIRA 被駭客惡搞的新聞
http://www.ithome.com.tw/itadm/article.php?c=60623

Apache 修正了問題,還很佛心地公開他們的修正方法
https://blogs.apache.org/infra/entry/apache_org_04_09_2010

其中一項是
"Use Fail2Ban to protect web application login failures from brute force attacks"

原來有 Fail2Ban 這種東西,字面上的意思就是,失敗(Fail)就把你給擋掉(Ban)
http://net.nthu.edu.tw/2009/security:fail2ban

主機若有開放 SSH, FTP, Apache 登入 ,都應該裝這個來加強安全性。Fail2Ban 是 monitor log,所以一般的 web 程式應該也可以產生文字 log的方式來 trigger 它的 action,像是擋 Client IP 之類的。

另有 denyhosts 似乎也不錯,但使用這類軟體時,千萬要看清楚設定項目,免得不小心把自己也給擋了...
[FreeBSD] DenyHosts 設定在 hosts.allow 注意事項

安裝在 Debian
apt-get install denyhosts

PHPUnit

Change to your php5 installation folder
cd c:\php5 

You have to install pear if you don't have it
go-pear.bat 


For convenience, a REG file is available under C:\php5\PEAR_ENV.reg
This file creates ENV variables for the current user.
Double-click this file to add it to the current user registry.

Start to install phpunit
pear install phpunit/PHPUnit 

optional for phpunit
pear install pear/Image_GraphViz

optional for phpunit
pear install --alldeps pear/Log

Check the installation is fine

phpunit --version
PHPUnit 3.4.12 by Sebastian Bergmann.


Modify phpunit.bat, change PHPBIN to your realpath, like this
set PHPBIN="C:\php5\php.exe"


Set envirment variable "PATH"
PATH=....;C:\php5
and we can call phpunit.bat in anywhere

What kind of assertion do we have ?
Check this, PHPUnit\framework\Assert.php

Examples:
http://www.phpunit.de/manual/current/en/test-driven-development.html

2010年4月13日 星期二

Yii: Custom PageSize in CGridView

<?php

// Custom PageSize
$data = $model->search();
$data->pagination->pageSize = 5;

$this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'table-grid',
    'dataProvider'=>$data,
    // 'filter'=>$model,
    'columns'=>array(
        'id',
        'userId',
        array(
            'class'=>'CButtonColumn',
        ),
    ),
)); ?>

jQuery iPod-style Drilldown Menu

http://filamentgroup.com/lab/jquery_ipod_style_drilldown_menu

Soft KVM, 一組 keyboard, mount 多台電腦及 monitor

http://synergy2.sourceforge.net/

因為使用 W2XW 時,mouse 經常會卡住,所以改用這套
Win32, Linux, Mac 可用

Server (有 mouse, keyboard 端)






Client

2010年4月6日 星期二

Datagrid (AdvancedDataGrid), break line in case of very long string

<mx:Datagrid variableRowHeight="true"
<mx:DataGridColumn wordWrap="true"

2010年3月30日 星期二

2010年3月16日 星期二

Flex 隱藏物件的方法(小技巧)

http://alin0913.pixnet.net/blog/post/25717430

visible = false;
includeInLayout = false;

2010年3月15日 星期一

gccgo Debian Package

gccgo Debian Package
http://www.atoztoa.com/2009/11/gccgo-debian-package.html

What is gccgo ?
http://golang.org/

Redis - A persistent key-value database with built-in net interface written in ANSI-C for Posix systems


Redis
http://code.google.com/p/redis/

Redis is an advanced key-value store. It is similar to memcached but the dataset is not volatile, and values can be strings, exactly like in memcached, but also lists, sets, and ordered sets

A twitter clone by Redis + PHP
http://code.google.com/p/redis/wiki/TwitterAlikeExample

2010年3月11日 星期四

ClassLoader in Java

ArrayList<URL> classPath = new ArrayList<URL>();
classPath.add(new File(workDir+"/").toURL());
classPath.add(file.toURL());
classPath.add(new File(workDir, "classes/").toURL());
File[] libs = new File(workDir, "lib").listFiles();
if (libs != null) {
    for (int i = 0; i < libs.length; i++) {
      classPath.add(libs[i].toURL());
    }
}

ClassLoader loader =
    new URLClassLoader(classPath.toArray(new URL[0]));


Thread.currentThread().setContextClassLoader(loader);
Class<?> mainClass = Class.forName(mainClassName, true, loader);
Method main = mainClass.getMethod("main", new Class[] {
    Array.newInstance(String.class, 0).getClass()
});

    String[] newArgs = Arrays.asList(args).subList(firstArg, args.length).toArray(new String[0]);
try {
    main.invoke(null, new Object[] { newArgs });
} catch (InvocationTargetException e) {
    throw e.getTargetException();
}

2010年3月10日 星期三

2010年3月6日 星期六

Netbeans 下載點

netbeans 官網首頁突然連不上,找到了另一個 netbeans 載點








2010年3月3日 星期三

XML driven Flash Tag Cloud

這支可包含 image

http://www.artviper.net/website-design/xml-flash-tag-cloud.php


另一個叫 Cumulus,下面是給 Drupal 用的 module,它不是用 XML 給參數,而是直接用 flashvars
http://drupal.org/project/cumulus

Linux 下面類似 putty 的工具: secpanel

2010年3月2日 星期二

The easy Flash & AIR Debugger

簡易的 log class,類似 log4j
http://arthropod.stopp.se/index2.php/

2010年3月1日 星期一

用 SQL formatter 增加 SQL 指令的可讀性

SQL Pretty Printer
它官網的 Web 版,而 desktop 版要 $$,但可以外掛在 VS 上。
http://www.dpriver.com/pp/sqlformat.htm?ref=g_wangz

SQLinForm,這套要裝 JRE
http://www.sqlinform.com/online.phtml

2010年2月24日 星期三

Wine 小技法

想把 Flash Builder 4 for windows 裝在 Linux 下面 
How to install Flash Builder on Linux


其中提到了 winetricks
http://wiki.winehq.org/winetricks


這程式可以選擇要裝什麼 win32 元件,像是 vc runtime, .net runtime
$ wget http://www.kegel.com/wine/winetricks
$ sh winetricks
 

ZK Framework 相關

Data Binding
http://docs.zkoss.org/wiki/Data_binding#Associate_UI_Components_with_a_Collection

Using scrolling tabs on tabbox
http://www.zkoss.org/smalltalks/scrollingtabs/

ZK Calendars Doc
http://docs.zkoss.org/wiki/ZK_Calendars

ZK Layout
http://docs.zkoss.org/wiki/Layout_and_Windows


ZK 開發文件 (html, pdf)
http://docs.huihoo.com/zk/

• ZK中文開發手冊 3.5.1
• ZK Developer's Guide Version 3.0.4
• ZK Developer's Reference Version 3.0.4
• ZK Quick Start Guide Version 3.0.4
• ZK JSP Tags User Guide Version 1.2
• ZK Studio User Guide Version 0.5.2
• ZK Mobile for Android The Quick Start Guide Version 0.8.1
• ZK Mobile The Quick Start Guide Version 0.8.6

Anatomy of the Linux slab allocator

2010年2月23日 星期二

DropBox 的替代品

DropBox 相當好用,類似的服務也很多 http://alternativeto.net/desktop/ifolder/
若資料比較敏感的話,像是公司的文件,根本不敢隨便上傳...
(雖然沒人會在意我這個小咖的資料)


目前看到 opensource 的方案有 iFolder
但官網釋出的 server 版,"只有" for openSUSE
改天有空再來試試怎麼裝在 Debian/Ubuntu
http://www.x2b4.com/howto/how-to-install-ifolder-on-ubuntu-server/
這樣一來,空間要多少有多少,也不必擔心資料隱私的問題

另外 DropBox 也有提供 CLI 工具
http://wiki.dropbox.com/DropboxAddons/DropboxLinuxCLI

Pythonic Web 應用平台對比

http://wiki.woodpecker.org.cn/moin/PyWebFrameVs

2010年2月22日 星期一

幾種 Flex Data Binding 的方法

http://blog.flexexamples.com/2007/10/01/data-binding-in-flex/

使用變數 Binding 到 Label/Text


[Bindable]
var str:String;


<s:Label id="clabel" text="Label"/>
<fx:Binding source="{labelText}" destination="clabel.text"/>
<mx:Text text="{labelText}"/>

Java 啟動參數大全

JAVA啟動參數大全之一:標準參數
http://blog.csdn.net/sfdev/archive/2008/01/23/2062042.aspx

JAVA啟動參數大全之二:非標準參數
http://blog.csdn.net/sfdev/archive/2008/01/24/2063464.aspx

JAVA啟動參數大全之三:非Stable參數
http://blog.csdn.net/sfdev/archive/2008/01/24/2063928.aspx

Java Support for Large Memory Pages

http://java.sun.com/javase/technologies/hotspot/largememory.jsp

JBoss performance tuning

Part 1
http://www.mastertheboss.com/en/jboss-application-server/113-jboss-performance-tuning-1.html

Part 2
http://www.mastertheboss.com/en/jboss-application-server/130-jboss-performance-tuning-part-2.html

Innodb Performance Optimization Basics

http://www.mysqlperformanceblog.com/2007/11/01/innodb-performance-optimization-basics/

HOWTO: Monitor i/o performance

sudo iostat -xcknd 15

http://www.aspdeveloper.net/tiki-index.php?page=Linuxiostat

Read I/Os

  • rrqm/s: # read requests merged per second queued for the device
  • r/s: Read requests issued to the device (realize requests can be joined together, so you are basically looking at the total of rrqm + r to get total read requests, assuming SOME may not be merged, I'm not 100% sure about that, but at a minium rrqm/s is reads per second)
  • rkB/s: Number of kilobytes read from the device per second
  • wrqm/s: Write version of rrqm/s
  • w/s: Write version of r/s
  • wkB/s: Write version of rkB/s
  • avgrq-sz: Average size (in sectors) of the requests that were issued to the device. Is the sector size 512 bytes for your device? Where do you check this (I'm not sure without searching, however we're primarily looking for what is relatively busy to either isolate WHY it's busy, or determine what subsystem needs to be upgraded, so I don't care a lot about this column even though it sounds fairly important).
  • avgqu-sz: The average queue length of the requests that were issued to the device - This one I do care about more - When things are queued up for the disks they aren't keeping up. Does that matter? That depends on a LOT of factors, is your software WAITING for the disk to complete it's operation? Usually reads that is the case, for writes it could be in a writeback cache and not a big concern.
  • await: The average time (in milliseconds) for I/O requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them. - This one again I DO care about. This is even more important than the number in the queue for some applications (for example copying a file, you really don't care about the NEXT item in the queue when you are doing sequential writes). On the other hand if you are a file server and have a million small files you care about this, but at least as importantly you care about how many other requests were pending.
  • svctm: The average service time (in milliseconds) for I/O requests that were issued to the device - I view this one as useful for finding if you devices are performing roughly as expected. In this case my demo is using a quite old single disk, I don't doubt it took 11.5ms to seek to another sector, read/write it, and return. If I had a 15k rpm latest generation scsi drive and saw 11.5ms I'd maybe wonder why that was. This will also depend on how much seeking your disk has to do, this number being high is NOT always bad - for example with drives re-ordering read/write operations to make less head movement you could have this number higher on a new drive yet have significantly higher throughput. This probably is confusing, but think about trying to play hot-potatoe with 100 people between point A and B - if your ONLY goal is to get every person to hold the potatoe do you want it just randomly tossed about ONLY to decrease the time it spent in someones hands? Instead moving it so each person only sees it once should decrease your total time to reach all 100 people.
  • %util: Percentage of CPU time during which I/O requests were issued to the device (bandwidth utilization for the device). Device saturation occurs when this value is close to 100%.

2010年2月12日 星期五

忘記 mysql 密碼

mysqld --skip-grant-tables

>use mysql
>update user set password=password("new_pass") where user="root";
>flush privileges; 

Linux Kernel with PAE

http://en.wikipedia.org/wiki/Physical_Address_Extension

Ubuntu
Linux jimmy-desktop 2.6.31-19-generic-pae #56-Ubuntu SMP

Debian
Linux server 2.6.18-4-686-bigmem #1 SMP

2010年2月8日 星期一

TRUNCATE TABLE Syntax (MySQL)

若是  Innodb, 在 5.0.3 之前的 truncate 是一筆一筆把 row 給刪除
之後是先 drop table 再 create table,因為這點,所以要注意權限設定
truncate table 需要有 drop table 的權限。

http://dev.mysql.com/doc/refman/5.0/en/truncate-table.html

程式執行時,吐說找不到 lib

經 Jack 大師指教,除了 ldd 之外,原來還有 strace, objdump 可以用,先記一下

Partition, Mounting in Linux

GParted
http://gparted.sourceforge.net/

PySDM
http://pysdm.sourceforge.net/

 

fstab with UUID

http://wiki.linux.org.hk/w/Use_filesystem_label

http://linux.byexamples.com/archives/321/fstab-with-uuid/

2010年2月4日 星期四

NVIDIA Nexus - Visual Studio-based GPU Development

NVIDIA Nexus - Visual Studio-based GPU Development
http://developer.nvidia.com/object/nexus.html

CUDA Toolkit 3.0 beta released, now with public downloads
http://forums.nvidia.com/index.php?showtopic=149959

MySQL Backup/Restore Large Databases/Tables

To dump large tables, you should combine the --single-transaction option with --quick.

http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_quick

--single-transaction
It will allow the live application to use the mysql database as normal without locking any tables and preventing the application to change the database.

In most of case, we have to avoid to use "extended insert" , It will generate too many command line (sql commands)

DO NOT USE "mysqldump --extended-insert", especially huge table!

instead of "mysqldump --extended-insert=FALSE"


MySQL Dump Importer (called BigDump)
http://www.ozerov.de/bigdump.php
In this file, after mysql_connect(), It has to execute "@mysql_query("SET NAMES 'utf8'");" to avoid 亂碼


change the configuration, like below
$linespersession = 600;  // lines per session, It's perhaps to avoid "max_packet_size is too small"
$delaypersession = 6000;  
// how many micro seconds delay after one session

SQLite with Network

http://www.sqlite.org/cvstrac/wiki?p=SqliteNetwork

http://www.it77.de/sqlite/sqlite.htm

2010年2月2日 星期二

2010年1月31日 星期日

Mac OS X Internals: A Systems Approach, by Amit Singh

http://osxbook.com/

Libusb for win32

http://libusb-win32.sourceforge.net/

Libusb-win32 is a port of the USB library libusb to the Windows operating systems (Win98SE, WinME, Win2k, WinXP). The library allows user space applications to access any USB device on Windows in a generic way without writing any line of kernel driver code.

NSIS : Nullsoft Scriptable Install System

NSIS (Nullsoft Scriptable Install System) is a professional open source system to create Windows installers. It is designed to be as small and flexible as possible and is therefore very suitable for internet distribution.

http://nsis.sourceforge.net/Home

Windows Driver Kit: User-Mode Driver Framework

Windows Driver Kit: User-Mode Driver Framework
http://msdn.microsoft.com/en-us/library/aa510983.aspx

WinUSB
http://msdn.microsoft.com/en-us/library/aa476426.aspx

General Requirements on HIDClass Drivers
http://msdn.microsoft.com/en-us/library/ms789962.aspx

USBVIEW Sample Application
http://msdn.microsoft.com/en-us/library/dd163454.aspx

JRebel (JavaRebel) : Do you need to rebuild/deploy your application ?

JRebel is an award-winning productivity tool for Java EE development. It enables your team to complete more features, fix more bugs, and release quality software on schedule and under budget by eliminating time-wasting build and redeploy phases.

http://www.zeroturnaround.com/jrebel/ 

JRebel Netbeans Plugin
http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=22254

2010年1月29日 星期五

MSSQL: The best performance of datatypes

有人覺得 char 比 varchar 快速,所以全部欄位都用 char @@
該用什麼,常理就能判斷,懶得幫他實驗,所以找了這些資料

http://blogs.techrepublic.com.com/10things/?p=381
http://www.sql-server-performance.com/tips/datatypes_p1.aspx

2010年1月27日 星期三

Java String replaceAll 真的很 tricky

String start = "yours now for just <amount>";
String price = "12$9.99";
// 必須取代 $ 成為 \$,別懷疑就是六個 backslash!!!

price = price.replaceAll("\\$", "\\\\\\$");
String end = start.replaceAll("<amount>", price);


replaceAll 第一個參數要小心特殊符號,大家都知道...
而且,它的第二個參數,不能包含 $,否則會出現
java.lang.StringIndexOutOfBoundsException
是因為 "$數字",會被當成 regex 在 replace 用的 "變數" (ex. $&, $1, $2...)
若 $ 不是變數,就要用 backslash 去 escape $
或是用 $$ 來跳脫 $ (把所有的 $ 取代成兩個 $$)
 

Refactorings 重構

http://www.refactoring.com/catalog/index.html

2010年1月25日 星期一

PRADO PHP Framework

http://www.pradosoft.com/

Qiang Xue - founder of PRADO framework, core development
He is in developer team of Yii Framework now.

PRADOTM is a component-based and event-driven programming framework for developing Web applications in PHP 5. PRADO stands for PHP Rapid Application Development Object-oriented.

Main Features of PRADO

  • Object-oriented and highly reusable code
  • Event-driven programming
  • Separation of presentation and logic
  • Configurable and pluggable modular architecture
  • Full spectrum of database support
  • Feature-rich Web components: HTML input controls, validators, datagrid, wizard...
  • AJAX-enabled Web components
  • Built-in support of internationalization (I18N) and localization (L10N)
  • Customizable and localizable error/exception handling
  • Multiway message logging with filters
  • Generic caching modules and selective output caching
  • Extensible authentication and authorization framework
  • Security measures: cross-site script (XSS) prevention, cookie protection...
  • XHTML compliance
  • Rich documentation and strong userbase

2010年1月23日 星期六

2010年1月22日 星期五

How to use TortoiseGit

http://wiki.github.com/multitheftauto/multitheftauto/how-to-use-tortoisegit

Online Chord Book

http://yourmusicarena.com/jamorama.html

Zend Server Community Edition

http://www.zend.com/en/products/server-ce/index







Yii : How to upload a file using a model

How to upload a file using a model
http://www.yiiframework.com/doc/cookbook/2/


Multi File upload - CFileValidator and CUploadedFile
http://www.yiiframework.com/forum/index.php?/topic/3035-multi-file-upload-cfilevalidator-and-cuploadedfile/

Usefull Yii Extension


Datafilter
This extension can be used to add search and filtration capabilities to data grids.
http://www.yiiframework.com/extension/datafilter/

grbac
This module is for User-Management
http://www.yiiframework.com/extension/grbac/

extendedclientscript
With this extension you can transparently reduce page load times by combining and compressing the used Javascript and CSS files.
http://www.yiiframework.com/extension/extendedclientscript/

euploadify
This extension adds a flash based file-upload with progress-bar and multi-file upload capability.
http://www.yiiframework.com/extension/euploadify/

cfile
This extension offers commonly used functions for filesystem objects (files and directories) manipulation.
http://www.yiiframework.com/extension/cfile/

esanitizer
This extension sanitizes all user input ($_POST, $_GET, $_COOKIE,$_FILES) with html purifier to protect against XSS
http://www.yiiframework.com/extension/esanitizer/

cvsout
http://www.yiiframework.com/extension/csvout/reviews/

printout
http://www.yiiframework.com/extension/printout/

Image Extension, Convert Kohana Image Library to Yii

Provides methods for the dynamic manipulation of images. Various image formats such as JPEG, PNG, and GIF can be resized, cropped, rotated and sharpened.

http://www.yiiframework.com/extension/image/

How to add more information to Yii::app()->user

在 Yii 中,一般情況會用
$id=Yii::app()->user->id; // 取得 username

第一次在 view 裡面使用時,覺得很怪異,我要 id 怎麼取到 username (LoginID)...

以下文件說明
1) 如何把 id 取代成 table 的 id 欄位 (sequence id)
2) 如何增加 user 的欄位,如 lastLoginTime

http://www.yiiframework.com/doc/cookbook/6/

2010年1月21日 星期四

Yii extension:從 mwb file 產生 model

mwbmodelcommand  

http://www.yiiframework.com/extension/mwbmodelcommand/

php.ini 需載入 zip extension,不然會出現以下錯誤

Warning: simplexml_load_file(): I/O warning : failed to load external entity "zip://db.mwb#document.mwb.xml" in ...commands\shell\mwbModelCommand.php on line 78

Flex : Windows Bitmap Format Encoder Decoder AS3 Flex 4 SDK

Flex 不能直接讀 BMP/TIFF,需要用非官方元件

http://code.google.com/p/windowsbitmapdencoder/

Flex 4 (Gumbo) Skinning with States and Animation

其中的 "Red Alert" 滿有趣的,剛好用得到
View the Project in Action
Explore the Source Code

全文出處:
http://www.adambergman.com/2009/06/28/flex-4-gumbo-skinning-with-states-and-animation/

Flex 4 (Flash Builder 4): 使用 state 及 transitions

與 Flex 3 有些不同,筆記一下~


http://www.artima.com/articles/flex_4_states.html

    <s:states>
        <s:State name="InitState"/>
        <s:State name="ReadyState"/>
    </s:states>   
   
    <s:transitions>
        <s:Transition fromState="*" toState="ReadyState">
            <s:Sequence duration="2500">
                <s:Parallel>
                    <mx:Blur target="{this.gios_image}" blurXFrom="10" blurXTo="0" blurYFrom="10" blurYTo="0"/>
                    <mx:Resize target="{this.gios_image}" widthFrom="1" heightFrom="1" widthTo="290" heightTo="297"/>
                    <mx:Fade target="{this.gios_image}" alphaFrom="1" alphaTo="0"/>
                </s:Parallel>
               
            </s:Sequence>
        </s:Transition>
    </s:transitions>

Adobe - Flash Player : Settings Manager - Global Security Settings Panel

http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html

2010年1月20日 星期三

DooPHP Sitemap Generator tool

可以用來快速產生 route table 及 controller




DooPHP Sitemap Generator tool from Leng Sheng Hong on Vimeo.

2010年1月17日 星期日

2010年1月12日 星期二

Drupal Translation



Drupal 的 Translation 是類似 GNU Gettext 的做法
直接用特定函式把要 transalation 的字串包起來,然後用工具 (potx-cli.php) 把這些字串從 code  extract 成文字檔,再用一般的 text editor 去修改成 target language。

Translation template extractor (含 potx-cli.php)
http://drupal.org/project/potx
Command line extraction: Copy potx.inc and potx-cli.php to the directory you would like to generate translation templates for and run php potx-cli.php. The translation templates will get generated as separate files in the current directory. Use php potx-cli.php --help to get a list of command line options.

 

BitBake User Manual

http://bitbake.berlios.de/manual/

SQUASHFS - A squashed read-only filesystem for Linux

Official Site
http://squashfs.sourceforge.net/

SquashFS HOWTO
http://www.tldp.org/HOWTO/SquashFS-HOWTO/index.html

Microsoft.XMLDOM for ASP

同事問到 xml 解析,利用 Microsoft.XMLDOM 可以支援 xpath

<xml masterProduct="3949">
<product1 mainProduct="yes">
   <color>Red</color>
   <price>23.99</price>
   <onHand>483948</onHand>
</product1>
<product2 productID="2222"></product2>
<product3 productID="3333"></product3>
</xml>


<%@ LANGUAGE=VBSCRIPT %>
<%Option Explicit%>

<%
Response.Buffer = True

Dim objXML, strPath, oRoot, x, strColor, strPrice
strPath = "[YOUR_PATH_TO_THE_XML_FILE]"
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.async = False
objXML.load (Server.MapPath(strPath))

If objXML.parseError.errorCode <> 0  Then
 Response.Write(objXML.parseError.reason)
 Response.Write(objXML.parseError.errorCode)
End If

Set oRoot = objXML.selectSingleNode("//xml/product1")
 for each x in oRoot.childNodes
  Select Case x.baseName
   case "color"
    strColor = x.text
   case "price"
    strPrice = x.text
   case else
  end select
 next
set objXML = nothing
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>ASP to read XML file Page</title>
</head>
<body>
<b>COLOUR:</b> <%=strColor%><br />
<b>PRICE:</b> <%=strPrice%>
</body>
</html>

自己 "編輯" 漫畫劇情

相當有趣的網站 (Drupal 架構)
http://www.zimmertwins.com/movie/starters

BitBake Data class

http://olvaffe.blogspot.com/2008/12/bitbake-data-class.html

What is "Et cetera" (etc)

Et cetera

http://en.wikipedia.org/wiki/Et_cetera

Psyco is a Python extension module which can greatly speed up the execution of any Python code.

http://psyco.sourceforge.net/

2010年1月11日 星期一

VMWare 在 Power On the Guest OS 時出現 Failed to Lock the File

刪除目錄下 *.vmdk.lck 的子目錄,容易發生在重新安裝 vmware 再 Add Virtual Machine to Inventory 的時候。

VMware server 2 登入時出現 http://localhost:8222/sdk 連不上的錯誤

The VMware Infrastructure Web Service at "http://localhost:8222/sdk" is not responding (Connection Refused)

安裝 VMWare server 2 時,會要求輸入 FQDN,若輸入 localhost 則需要以下設定
修改 C:\Windows\System32\Drivers\etc\hosts 以下兩行 uncomment
::1 localhost
127.0.0.1 localhost

http://winromulus.com/Other/Work-Related/VMware-Server-The-VMware-Infrastructure-Web-Service-is-not-responding-Connection-Refused.html

2010年1月10日 星期日

Artisteer : Template Generator

商業軟體,可用來產生 joomla, drupal, wordpress 的 template

http://www.artisteer.com/

2010年1月7日 星期四

PHP 5.2.6 (Win32) 有個奇怪的問題

<?php
echo 169926.25841615902027 * 31.19;
?>

在版本
5.2.1
5.2.9-2
5.2.11-2 結果都是 5300000

在 5.2.6 結果是 5.3E+6

通常科學符號表示不是我們要的,所以我認定這是個 BUG

2010年1月6日 星期三

Ubercart 電子商務模組

Drupal 5.x + Ubercart 的購書網站
http://www.go8.com.tw

東豐農業網
http://www.dongfon.com/products

2010年1月5日 星期二

設定 Apache2 自訂的 php.ini 位置

有時不指定 libmySQL.dll 會出現 (error.log)
win32 下面測試有效,Linux 還未試過

PHP Warning:  PHP Startup: Unable to load dynamic library 'D:/appserv/php5/ext/php_mysql.dll' - \xa7\xe4\xa4\xa3\xa8\xec\xab\xfc\xa9w\xaa\xba\xbc\xd2\xb2\xd5\xa1C\r\n in Unknown on line 0

> httpd.conf

LoadModule php5_module "C:/AppServ/php5/php5apache2.dll"
LoadFile "C:\AppServ2.0\php5\php5ts.dll"

# 避免 php_mysql.dll 無法被載入
LoadFile "C:\AppServ2.0\php5\libmySQL.dll"

# 避免php_mcrypt.dll 無法被載入
LoadFile "D:\AppServ\php5\libmcrypt.dll"

# 指定 php.ini 的目錄
PHPINIDir "C:\AppServ2.0\php5"