2010年5月26日 星期三

修改 OpenOffice 介面(UI)字型

升級 OO 3.x 後,所有介面都無法顯示中文,只會出現 口口 如下圖



到 工具(T)/選項(O)/檢視 下 取消 "使用使用者介面的系統字型" 後


OO 就會自動用系統裡的字型來取代,也就可以看到中文字
但 OO 會隨便挑選系統中可以顯示中文的字型來使用,有時特殊美工用字型並不適合
如下圖,用 古印體 顯示看起來很不清楚


在網路上找到很多說把 Andale Sans UI 取代成 新細明體
但是不管我怎麼設定他都沒有作用,只好把會被優先找到的字型由系統移除...
直到最近找到有人分享 OO 字型設定檔才發現
原來新版 OO 有針對不同語系設計不同的字型取代順序
已經不再是用 Andale Sans UI 為預設介面字型
對中文語系使用者,其介面字型預設為 "方正明體"
因此只要把 方正明體 用其他你喜歡有中文的字型取代即可呈獻美美的介面


這個神奇的設定檔在 /usr/lib/openoffice/basis3.2/share/registry/data/org/openoffice/VCL.xcu
開啟後找 zh-tw 字串,接下來就會看到很多 方正明體;AR PL Mingti2L Big5;細明體;MingLiU; 之類的字型取代順序
也才發現原來他預設的介面字型對中文使用者來說已經改成 方正明體
奇怪的是,照他裏面列表的順序,應該可以優先使用新細明體,不知為何他會找一個不在列表中的字型來用

參考資料:
如何修改 NeoOffice 使用者介面 (UI) 的字型

2012.05.19 update:
for libreoffice, please ref /usr/lib64/libreoffice/share/registry/main.xcd
Ref: http://ooo.tn.edu.tw/modules/xforum/viewtopic.php?post_id=10043

2010年1月26日 星期二

同步資料 lock 的處理機制

請教:spinlock,mutex,semaphore,critical section的作用和區別,都適合那些場合,謝謝
Mutex是一把鑰匙,一個人拿了就可進入一個房間,出來的時候把鑰匙交給隊列的第一個。一般的用法是用於串行化對critical section代碼的訪問,保證這段代碼不會被並行的運行。
(A mutex is really a semaphore with value 1.)


Semaphore是一件可以容納N人的房間,如果人不滿就可以進去,如果人滿了,就要等待有人出來。對於N=1的情況,稱為binary semaphore。一般的用法是,用於限制對於某一資源的同時訪問。



Binary semaphore與Mutex的差異:

在有的系統中Binary semaphore與Mutex是沒有差異的。在有的系統上,主要的差異是mutex一定要由獲得鎖的進程來釋放。而semaphore可以由其它進程釋放(這時的semaphore實際就是個原子的變量,大家可以加或減),因此semaphore可以用於進程間同步。 Semaphore的同步功能是所有系統都支持的,而Mutex能否由其他進程釋放則未定,因此建議mutex只用於保護critical section。而semaphore則用於保護某變量,或者同步。



另一個概念是spin lock,這是一個內核態概念。 spin lock與semaphore的主要區別是spin lock是busy waiting,而semaphore是sleep。對於可以sleep的進程來說,busy waiting當然沒有意義。對於單CPU的系統,busy waiting當然更沒意義(沒有CPU可以釋放鎖)。因此,只有多CPU的內核態非進程空間,才會用到spin lock。 Linux kernel的spin lock在非SMP的情況下,只是關irq,沒有別的操作,用於確保該段程序的運行不會被打斷。其實也就是類似mutex的作用,串行化對critical section的訪問。但是mutex不能保護中斷的打斷,也不能在中斷處理程序中被調用。而spin lock也一般沒有必要用於可以sleep的進程空間。



Mutex vs. Semaphore, what is the difference?

The Toilet Example (c) Copyright 2005, Niclas Winquist ;)

Mutex:

Is a key to a toilet. One person can have the key - occupy the toilet - at the time. When finished, the person gives (frees) the key to the next person in the queue.

Officially: "Mutexes are typically used to serialise access to a section of re-entrant code that cannot be executed concurrently by more than one thread. A mutex object only allows one thread into a controlled section, forcing other threads which attempt to gain access to that section to wait until the first thread has exited from that section."
Ref: Symbian Developer Library

(A mutex is really a semaphore with value 1.)

Semaphore:

Is the number of free identical toilet keys. Example, say we have four toilets with identical locks and keys. The semaphore count - the count of keys - is set to 4 at beginning (all four toilets are free), then the count value is decremented as people are coming in. If all toilets are full, ie. there are no free keys left, the semaphore count is 0. Now, when eq. one person leaves the toilet, semaphore is increased to 1 (one free key), and given to the next person in the queue.

Officially: "A semaphore restricts the number of simultaneous users of a shared resource up to a maximum number. Threads can request access to the resource (decrementing the semaphore), and can signal that they have finished using the resource (incrementing the semaphore)."
Ref: Symbian Developer Library

2010年1月13日 星期三

在「磁碟整理」程序中禁止使用「壓縮舊檔案」功能

http://support.microsoft.com/kb/812248/zh-tw

壓縮舊檔時「磁碟清理」工具停止回應

當您嘗試壓縮舊檔案時,「磁碟清理」工具可能會停止回應,而您可能會收到下列訊息:
磁碟清理正在計算您可以在 C: 上釋放多少空間。
可能要幾分鐘時間才能完成。
正在掃描:壓縮舊檔案


回此頁最上方
發生的原因
當「磁碟清理」公用程式使用不正確的登錄項目來尋找壓縮檔案時,便會發生這個問題。

回此頁最上方
其他可行方案
警告 不當使用「登錄編輯程式」可能會導致嚴重的問題,甚至必須重新安裝作業系統。Microsoft 不保證可以解決您不當使用「登錄編輯程式」所導致的問題。請自行承擔使用「登錄編輯程式」的一切風險。

如果要解決這個問題,請依照下列步驟執行:
1. 按一下 [開始],然後按一下 [執行]。
2. 在 [開啟] 方塊輸入 regedit,再按下 ENTER。
3. 找出並按一下下列登錄機碼:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches
4. 在 [檔案] 功能表按一下 [匯出],再按一下 [桌面],在 [檔名] 方塊輸入 VolumeCaches,再按一下 [儲存]。

注 意 這個步驟會建立 VolumeCaches 登錄機碼的備份。如果在您完成這個程序的步驟之後仍遭遇任何問題,您可使用這個備份將 VolumeCaches 機碼還原至原始的狀態。如果要還原這個機碼,請按兩下您桌面的 VolumeCaches.reg 檔,再按一下 [是]。
5. 展開下列登錄機碼:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches
6. 刪除 [Compress old files] 登錄機碼。
7. 結束 [登錄編輯程式]。

2009年12月12日 星期六

martian source 火星連線 @ 工作雜記 :: Xuite日誌

martian source 火星連線 @ 工作雜記 :: Xuite日誌
martian source 未知的連線
大量的洗螢幕和log檔
讓人煩不勝煩
log檔 /var/log/messages

Mar 19 16:36:43 ADSLserver kernel: ll header: ff:ff:ff:ff:ff:ff:00:48:54:5b:0d:3f:08:00
Mar 19 16:36:43 ADSLserver kernel: martian source 192.168.6.255 from 192.168.1.2, on dev eth0
Mar 19 16:36:43 ADSLserver kernel: ll header: ff:ff:ff:ff:ff:ff:00:48:54:5b:0d:3f:08:00
Mar 19 16:36:43 ADSLserver kernel: martian source 192.168.6.255 from 192.168.1.2, on dev eth0
Mar 19 16:36:43 ADSLserver kernel: ll header: ff:ff:ff:ff:ff:ff:00:48:54:5b:0d:3f:08:00

這就是所謂的
逆向路徑過濾 (Reverse Path Filtering)

這個情形常發生在兩個網段共存的linux 主機上
預設情況下﹐router 會路由所有東西﹐就算該封包‘顯然’不屬於貴網路的常見的例子﹐莫過於將私有 IP 泄漏到 internet 上去。
假如您有一個界面﹐其上設定的路由為 195.96.96.0/24﹐那您不會預期來自 212.64.94.1 的封包會到達這裡


其實是無害的
如果一直跑出來
可以選擇關掉它


解决方法 :

一、取消log_martians
echo 0 > /proc/sys/net/ipv4/conf/all/log_martians

二、或是關掉rp_filter
1.清空rp_filter
echo 0 >/proc/sys/net/ipv4/conf/eth0/rp_filter

注意:
紅字 eth0 為log檔內那個 device ,不可打錯

2.另外我們還要關掉 rp_filter
vi /etc/sysctl.conf
net.ipv4.conf.default.rp_filter=0

2009年12月9日 星期三

在Gentoo中使用因License被mask的包 - Andrew's Scratch - 博客大巴

在Gentoo中使用因License被mask的包 - Andrew's Scratch - 博客大巴

今天更新了GENTOO,发现virtualbox-bin有更新,但却被mask了,把virtualbox-bin添加到/etc/portage/package.unmask也不起作用:

!!! All ebuilds that could satisfy "app-emulation/virtualbox-bin" have been masked.
!!! One of the following masked packages is required to complete your request:
- app-emulation/virtualbox-bin-3.0.10 (masked by: PUEL license(s))
A copy of the 'PUEL' license is located at '/usr/portage/licenses/PUEL'.

For more information, see the MASKED PACKAGES section in the emerge
man page or refer to the Gentoo Handbook.

Google了一下,发现这个是因为License而被mask,解决方法有二:

一是在/etc/make.conf里面加入下面一行:

ACCEPT_LICENSE="PUEL"

二是在etc/portage/package.license里面添加下面的一行就可以了:

app-emulation/virtualbox-bin PUEL

2009年12月1日 星期二

Connect to GPRS/3G over Bluetooth

PPP原理參考: http://www.xs4all.nl/~ernstagn/GPRS-HOWTO/
安裝 blueman-1.21
然後在 /etc/ppp/options 加入 noipdefault
即可透過 blueman 的PPPSupport 機制上網

2009年11月4日 星期三

JavaScript修改CSS樣式

分為改變直接樣式,改變className和改變cssText三種。需要注意的是:
注意大小寫:
javascript對大小寫十分敏感,className不能夠把「N」寫成「n」,cssText也不能夠把「T」寫成「t」,否則無法實現效果。
調用方法:
如果改變className,則事先在樣式表中申明類,但調用時不要再跟style,像document.getElementById('obj').style.className="…"的寫法是錯誤的!
只能寫成:document.getElementById('obj').className="…"
或是 this.className="..." 也可
改變cssText
但是如果用cssText的話,必須加上style,正確的寫法是:document.getElementById('obj').style.cssText="…"

改變直接樣式我就不必說了,大家記得要寫到具體樣式即可,如
document.getElementById('obj').style.backgroundColor="#003366"

來源:
http://www.wowbox.com.tw/blog/article.asp?id=3032
Related Posts Plugin for WordPress, Blogger...