Posts

The power of Intel Quad core * 2 + FreeBSD 8 amd64

Image
因工作上的需求,我必須處理 Subversion 因為 svn blame 造成的高系統負載問題。 作業環境如下: FreeBSD 7.2 Apache 2.x Subversion 1.x viewvc 1.x 在原來的硬體環境: CPU: Intel Xeon 3.06 GHz with HT RAM: 2GB HDD: SCSI FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs cpu0 (BSP): APIC ID: 0 cpu1 (AP/HT): APIC ID: 1 cpu2 (AP): APIC ID: 6 cpu3 (AP/HT): APIC ID: 7 一旦使用者透過 viewvc 執行 annotate 的工作,只要一個! 且單一檔案內容超過萬行的情況下,就會造成系統高負載 (average load 破百) 的情況,最嚴重的狀況是連 console 操作都會 hang 住! 而且 httpd 和 svn 的 process 數量也 fork 很多出來! 深究其因,應該是 viewvc 造成的! 其次,CPU 僅是透過 HT 虛擬成 4 個 cpu,而並非真正 multiple core,因此運算能力也相對較弱! 以提供服務的角度來看,這個功能是使用者經常用到的! 因此,除了去 trace viewvc 外,唯一可解的就是硬體升級了! 新的硬體環境: CPU: Intel Xeon E5420 2.5 GHz RAM: 48 GB HDD: SAS FreeBSD/SMP: Multiprocessor System Detected: 8 CPUs FreeBSD/SMP: 2 package(s) x 4 core(s) cpu0 (BSP): APIC ID: 0 cpu1 (AP): APIC ID: 1 cpu2 (AP): APIC ID: 2 cpu3 (AP): APIC ID: 3 cpu4 (AP): APIC ID: 4 cpu5 (AP): APIC ID: 5 cpu6 (AP): APIC ID: 6 cpu7 (AP): APIC ID: 7 OS 改用 FreeBSD 8 amd64 的版本,將 /tmp 透過 md 掛載大小為 18G ...

Indexers in C# and VB.net

What are Indexers? Indexers allow instances of a class or struct to be indexed just like arrays. Indexers resemble properties except that their accessors take parameters. A class can have only one Indexer In VB.net, default keyword is required to make it indexer Index can be accessed either by a numeric index or even string How to Use (C#)? using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CSconsole { class NamesList { public int Length { get { return objList.Count; } } List String > objList = new List string >(); public string this [ int index] { get { return objList[index]; } set { objList.Add ( value ); } } } public class TestIndexers { public static void Main () { ...

Convert nrg file to iso

There are 2 options on Debian/Linux: nrg2iso iat I tried nrg2iso at first, it told me the nrg file is already in ISO9660 format and did not covert. And I tried iat then that. It works fine! $ iat image.nrg image.iso Iso9660 Analyzer Tool v0.1.3 by Salvatore Santagati Licensed under GPL v2 or later Detect Signature ISO9660 START at 32768 Detect Signature ISO9660 END at 36864 Image offset start at 0 Sector header 0 bit Sector ECC 0 bit Block 2048 Done The outputed iso can be used with no wrong.

Handling Dropdownlist inside gridview

Often there is a need to handle OnSelectedIndexChanged event of a dropdown residing inside a GridView. This can be handled as following: 1. Specify an event handler from dropdown in ASPX < asp : GridView ID ="GridView1" runat ="server" AutoGenerateColumns ="False"> < Columns > < asp : TemplateField > < ItemTemplate > < asp : DropDownList OnSelectedIndexChanged ="ddl_Change" DataTextField ="UserName" AutoPostBack ="true" DataValueField ="userId" ID ="ddl" runat ="server"/> 2. Add event handler in ASPX.cs Protected Sub ddl_Change( ByVal sender As Object , ByVal e As EventArgs) 'You can retrieve Dropdown as: Dim DropDownControl As DropDownList = CType (sender, DropDownList) 'You can retrieve Parent GridRow as: Dim gridRow As GridViewRow = CType ( CType (sender, DropDownList).NamingContainer, GridViewRow) ...

Whats new in C# 2.0 3.0 4.0

What's new in C# 2.0 1. Generics 2. Nullable Types 3. Iterators 4. Partial Class Definitions 5. Anonymous Methods 6. The :: Alias Qualifier 7. Static Classes 8. Covariance and Contravariance 9. Fixed-Size Buffers 10. Friend Assemblies 11. extern Aliases 12. Method Group Conversion 13. Accessor Access Control 14. The #pragma Directive What's new in C# 3.0 1. Lambda expressions 2. Extension methods 3. Implicitly typed local variables 4. Query comprehensions 5. Anonymous types 6. Object initializers 7. Implicitly typed arrays 8. Automatic properties 9. Partial methods 10. Expression trees What's new in C# 4.0 1. Named and Optional Parameters 2. Dynamic Support 3. Variance 4. COM Interop

Memory based file system (ramdisk) on FreeBSD

To create a ramdisk for /tmp and detach it on FreeBSD 8 # /sbin/mdmfs -M -S -o async -s size md0 /tmp Don't forget to chmod +w for read/write # chmod +w /tmp Detach it and delete from /dev/md0 # /sbin/mdconfig -d -u 0 There is a shell script for the operation %cat ramdisk.sh #!/bin/sh case "$1" in create) /sbin/mdmfs -M -S -o async -s 18432m md0 /tmp /bin/chmod 777 /tmp echo "18G ramdisk created on md0 and mounted on /tmp" exit 0 ;; destory) /sbin/umount /tmp /sbin/mdconfig -d -u 0 echo "ramdisk umounted from /tmp and destory from md0" ;; *) echo "Usage: `basename $0` {create|destory}" >&2 exit 64 ;; esac Caution ! This is for specificed purpose only! You have to modify the parameters if you want to use it.

Install Pidgin 2.6.4 from source on OpenBSD 4.6

At first, following content is just my experience to install a newer version from source, it may not works as well as you guys used on LINUX. Do following steps: You have to install following packages before you start to compile pidgin! gmake gstreamer gnutls libnss python cyrus-sasl2 tcl/tk farsight Well, a GTK based desktop environment is needed! (I use XFCE4, Gnome is the best!) Download the source from Pidgin's official site Extract the source Run configure with parameters # ./configure --disable-vv --disable-meanwhile --disable-nm --with-gnutls-includes=/usr/local/include --with-gnutls-libs=/usr/local/lib --with-tclconfig=/usr/local/lib/tcl8.5 --with-tkconfig=/usr/local/lib/tk8.4 Compile # gmake Install as root # sudo gmake install If all the procedures are work properly, you can just start pidgin and enjoy it on OpenBSD 4.6 now! :)