安裝gma 500 driver:
sudo add-apt-repository ppa:gma500/ppa && sudo apt-get update
sudo apt-get install poulsbo-driver-2d poulsbo-driver-3d poulsbo-config
修正 touch screen:
xinput list
找出IDEACOM IDC 6680 的id
sudo gedit /etc/X11/Xsession.d/98x11-common_touchscreen
xinput set-int-prop 8 "Evdev Axis Calibration" 32 300 7900 400 7800
把8改為你找到的id
2010年12月8日星期三
2010年10月2日星期六
optimize jquery selector
var items = '
var list = $('#list');
list.html(items);
console.time('direct');
for (i=0; i<10000; i++) {
var s = $('.item');
}
console.timeEnd('direct');
console.time('Specific tag');
for (i=0; i<10000; i++) {
var s = $('li.item');
}
console.timeEnd('Specific tag');
console.time('Specific class');
for (i=0; i<10000; i++) {
var s = $('.item.anotherClass');
}
console.timeEnd('Specific class');
console.time('Specific another class');
for (i=0; i<10000; i++) {
var s = $('li.item.anotherClass');
}
console.timeEnd('Specific another class');
console.time('with ancestor');
for (i=0; i<10000; i++) {
var s = $('#ulId .item');
}
console.timeEnd('with ancestor');
console.time('with context');
for (i=0; i<10000; i++) {
var s = $('.item','#ulId');
}
console.timeEnd('with context');
console.time('specific tag with context');
for (i=0; i<10000; i++) {
var s = $('.item','#ulId');
}
console.timeEnd('specific tag with context');
console.time('direct with jquery context');
for (i=0; i<10000; i++) {
var s = $('.item',$('#ulId'));
}
console.timeEnd('direct with jquery context');
得出
direct: 3791ms
Specific tag: 3483ms
Specific class: 4128ms
Specific another class: 3001ms
with ancestor: 3094ms
with context: 72ms
specific tag with context: 73ms
direct with jquery context: 75ms
最緊要係加context!
- ';
- item ';
for (i=0; i<1000; i++) {
items += '
}
items += '
var list = $('#list');
list.html(items);
console.time('direct');
for (i=0; i<10000; i++) {
var s = $('.item');
}
console.timeEnd('direct');
console.time('Specific tag');
for (i=0; i<10000; i++) {
var s = $('li.item');
}
console.timeEnd('Specific tag');
console.time('Specific class');
for (i=0; i<10000; i++) {
var s = $('.item.anotherClass');
}
console.timeEnd('Specific class');
console.time('Specific another class');
for (i=0; i<10000; i++) {
var s = $('li.item.anotherClass');
}
console.timeEnd('Specific another class');
console.time('with ancestor');
for (i=0; i<10000; i++) {
var s = $('#ulId .item');
}
console.timeEnd('with ancestor');
console.time('with context');
for (i=0; i<10000; i++) {
var s = $('.item','#ulId');
}
console.timeEnd('with context');
console.time('specific tag with context');
for (i=0; i<10000; i++) {
var s = $('.item','#ulId');
}
console.timeEnd('specific tag with context');
console.time('direct with jquery context');
for (i=0; i<10000; i++) {
var s = $('.item',$('#ulId'));
}
console.timeEnd('direct with jquery context');
得出
direct: 3791ms
Specific tag: 3483ms
Specific class: 4128ms
Specific another class: 3001ms
with ancestor: 3094ms
with context: 72ms
specific tag with context: 73ms
direct with jquery context: 75ms
最緊要係加context!
2010年9月1日星期三
Ubuntu 10.04 上, 定時用ClamAV 掃毒並 email log
安裝
更新病毒庫
設定cron
設定限權
把shell加到 crontab 內
# 記得更改 LOG_FILE , SCAN_FOLDER
# 想用gmail寄可參考 ubuntu 10.04 上,透過 gmail 用命令列寄信
shell 修改自http://ubuntuforums.org/showthread.php?t=631293
$ sudo apt-get install clamav
更新病毒庫
$ sudo freshclam
設定cron
$ sudo vim /usr/local/bin/virus_scan.sh
#!/bin/bash
# ----------------------------------------------------------------------
# Virus scan with ClamAV
# ----------------------------------------------------------------------
# Disabling PATH improves the security of the script
unset PATH
# Declare the variables
ECHO=/bin/echo;
DATE=/bin/date;
FRESHCLAM=/usr/bin/freshclam;
CLAMSCAN=/usr/bin/clamscan;
LOG_FILE=/home/user/clamscan.log;
SCAN_FOLDER=/;
# Start the log entry
$ECHO Complete system virus scan starting >> $LOG_FILE;
$DATE >> $LOG_FILE;
$ECHO \* >> $LOG_FILE;
# Update Virus definitions
$FRESHCLAM >> $LOG_FILE;
# Run the scan
$CLAMSCAN -ri $SCAN_FOLDER >> $LOG_FILE;
# Finish the log entry
$ECHO \* >> $LOG_FILE;
$ECHO Complete system virus scan finished >> $LOG_FILE;
$DATE >> $LOG_FILE;
$ECHO \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* >> $LOG_FILE;
$cat clamscan.log | mail -s "ClamAV Scan" someone@server.com
$rm clamscan.log
設定限權
sudo chown root /usr/local/bin/virus_scan.sh
sudo chmod u=rwx /usr/local/bin/virus_scan.sh
sudo chmod go= /usr/local/bin/virus_scan.sh
把shell加到 crontab 內
sudo vim /etc/crontab
20 3 * * * root /usr/local/bin/virus_scan.sh
# 記得更改 LOG_FILE , SCAN_FOLDER
# 想用gmail寄可參考 ubuntu 10.04 上,透過 gmail 用命令列寄信
shell 修改自http://ubuntuforums.org/showthread.php?t=631293
ubuntu 10.04 上,透過 gmail 用命令列寄信
$ sudo apt-get install heirloom-mailx msmtp
$ vim ~/.mailrc
$ vim ~/.msmtprc
$ chmod 600 ~/.msmtprc
$ echo "Hello, world!" | mail -s "Test from command line" -a attachment.txt somebody@somedomain.org
ssmtp也有相同作用, 但ssmtp會把帳密以明碼存在/etc/下,會增有gmail被帳號被盜。
參考
How To Use Gmail Account To Relay Email From a Shell Prompt
在 Ubuntu 8.04 上透過 gmail 用命令列寄信
$ vim ~/.mailrc
set from="YOURNAME@gmail.com (YOURNAME)"
set sendmail="/usr/bin/msmtp"
set message-sendmail-extra-arguments="-a gmail"
$ vim ~/.msmtprc
defaults
logfile /home/USER/msmtp.log
# gmail account
account gmail
auth on
host smtp.gmail.com
port 587
user YOURNAME@gmail.com
password YOURPASSWORD
from YOURNAME@gmail.com
tls on
tls_trust_file /usr/share/ca-certificates/mozilla/Equifax_Secure_CA.crt
# set default account to use (not necessary with single account)
account default : gmail
$ chmod 600 ~/.msmtprc
$ echo "Hello, world!" | mail -s "Test from command line" -a attachment.txt somebody@somedomain.org
ssmtp也有相同作用, 但ssmtp會把帳密以明碼存在/etc/下,會增有gmail被帳號被盜。
參考
How To Use Gmail Account To Relay Email From a Shell Prompt
在 Ubuntu 8.04 上透過 gmail 用命令列寄信
2010年5月7日星期五
雨
又一個訓唔著既晚上。唔同既係,今晚有雷雨上映。
狂風首先響起左前奏, 雨聲令我既注意力再度分散, 走左出去露台觀雨。雨似雨, 又不似雨。初聽之下,雨聲就是雨聲, 突然雨聲變了沙鎚聲,然後一下閃電, 又一下,就好像要說明佢係特別既。 不知何時,雨聲又變回雨聲。
回想最初對雨既印象,就係細個阿媽買左一套黃色既雨衣同雨BOOT, 但係等左好耐都無落雨。過左好似三年咁耐, 終於可以穿甲上陣。雖然同樣都係返學日,但係係雨水陪伴之下就變得有趣得多。雨聲就好似無數既朋友不斷同你傾計,你只要細心傾聽,就可以聽到佢地既言語。冰涼既雨水隔住雨衣都可以感受到,令夏日既刺熱感完全消退。青蛙既叫聲取代左吵耳既蟬聲,好似氣定神閒咁唱緊歌。雨聲又掩蓋左人們煩燥既談話聲,感覺就好似去左熱帶雨林,平時既不自覺既壓力消去得無影無終。我, 愛雨。
回到現實,蛙叫聲已經聽唔到, 換黎既黎低沈既船鳴聲, 可能它在悲叫吧? 在這七百萬人的都市中,也許只有我聽到, 但我又能做什麼? 破!! 突然雷聲一響,喝止了雨, 也喝止了夢。
又,雨停了又落, 就好似女人既心情咁, 永遠都睇唔通。
狂風首先響起左前奏, 雨聲令我既注意力再度分散, 走左出去露台觀雨。雨似雨, 又不似雨。初聽之下,雨聲就是雨聲, 突然雨聲變了沙鎚聲,然後一下閃電, 又一下,就好像要說明佢係特別既。 不知何時,雨聲又變回雨聲。
回想最初對雨既印象,就係細個阿媽買左一套黃色既雨衣同雨BOOT, 但係等左好耐都無落雨。過左好似三年咁耐, 終於可以穿甲上陣。雖然同樣都係返學日,但係係雨水陪伴之下就變得有趣得多。雨聲就好似無數既朋友不斷同你傾計,你只要細心傾聽,就可以聽到佢地既言語。冰涼既雨水隔住雨衣都可以感受到,令夏日既刺熱感完全消退。青蛙既叫聲取代左吵耳既蟬聲,好似氣定神閒咁唱緊歌。雨聲又掩蓋左人們煩燥既談話聲,感覺就好似去左熱帶雨林,平時既不自覺既壓力消去得無影無終。我, 愛雨。
回到現實,蛙叫聲已經聽唔到, 換黎既黎低沈既船鳴聲, 可能它在悲叫吧? 在這七百萬人的都市中,也許只有我聽到, 但我又能做什麼? 破!! 突然雷聲一響,喝止了雨, 也喝止了夢。
又,雨停了又落, 就好似女人既心情咁, 永遠都睇唔通。
訂閱:
文章 (Atom)