Tuesday, 30 December 2008




null - Watch more free videos

Monday, 22 December 2008

Php script to resize and add watermark

$opacitypercent = 80;
$scaling = 480;

foreach ($Photos as $original){
echo '*';

function AddWM($photo,$watermark){
//xoffset of the watermark
global $xoffset;
//yoffset of the watermark
global $yoffset;

//the original image to be watermarked
//the watermark to apply
$watermarkimage = $watermark;

//top end opacity number (totally transparent)
$opacity0 = @MagickGetQuantumRange();

//bootom opacity (totally visible)
$opacity100 = 0;

//desired opacity percentage
global $opacitypercent;

//gather the actual opacity number
$opacity = $opacity0 * ( 1 - $opacitypercent/100 ) ;

//initialize the wands
$sourceWand = NewMagickWand();
$compositeWand = NewMagickWand();

//read in the images
@MagickReadImage($sourceWand, $originalimage);
@MagickReadImage($compositeWand, $watermarkimage);

//resize the original photo
global $scaling;
$PhotoWidth = MagickGetImageWidth($sourceWand);
$PhotoHeight = MagickGetImageHeight($sourceWand);
$WvsH = $PhotoWidth/$PhotoHeight;
$resizeresult = MagickScaleImage( $sourceWand, $scaling, $scaling/$WvsH);
$resizeresult = MagickScaleImage( $sourceWand, $scaling*$WvsH, $scaling);

//setting the image index
MagickSetImageIndex($compositeWand, 0);
MagickSetImageType($compositeWand, MW_TrueColorMatteType);

//seting the opacity level
MagickEvaluateImage($compositeWand, MW_SubtractEvaluateOperator, $opacity, MW_OpacityChannel) ;

//combining the images
@MagickCompositeImage($sourceWand, $compositeWand, MW_OverCompositeOp, $xoffset, $yoffset);

//create a subdirectory to store photos with watermark
mkdir("PhotosWithWaterMark", 0755);
//generate the image
MagickWriteImage( $sourceWand, "PhotosWithWaterMark/"."WM_".$photo);

function GetFileList(){
$dir = "./";
$PhotoFormats = array('jpg','jpeg');
// Open a known directory, and proceed to read its contents
if ($dh = opendir($dir)) {
$PhotosList = '';

while (($file = readdir($dh)) !== false) {
$NameExt = explode(".",$file);
if (in_array(strtolower($NameExt[count($NameExt)-1]),$PhotoFormats)){
echo "filename: $file" . "\n";
$PhotosList[] = $file;
return $PhotosList;


Sunday, 21 December 2008

HOWTO: using Php to add watermark


function makewatermark()
// php imagemagick test harness
// create a watermarked image

//xoffset of the watermark
//yoffset of the watermark

//the original image to be watermarked
$rawimage = NewMagickWand();
MagickReadImage( $rawimage, 'cyclops.gif' );
MagickWriteImage($rawimage, 'new_image.jpg' );
//the watermark to apply
$watermarkimage = "sphinx.gif";

//top end opacity number (totally transparent)
$opacity0 = @MagickGetQuantumRange();

//bootom opacity (totally visible)
$opacity100 = 0;

//desired opacity percentage
$opacitypercent = 50;

//gather the actual opacity number
$opacity = $opacity0 - ($opacity0 * $opacitypercent/100 ) ;

//validate the opacity number
if ($opacity > $opacity0){
$opacity = $opacity0;
}elseif ($opacity <0){
$opacity = 0;

//initialize the wands
$sourceWand = NewMagickWand();
$compositeWand = NewMagickWand();

//read in the images
@MagickReadImage($compositeWand, $watermarkimage);
@MagickReadImage($sourceWand, $originalimage);

//setting the image index
MagickSetImageIndex($compositeWand, 0);
MagickSetImageType($compositeWand, MW_TrueColorMatteType);

//seting the opacity level
MagickEvaluateImage($compositeWand, MW_SubtractEvaluateOperator, $opacity, MW_OpacityChannel) ;

//combining the images
@MagickCompositeImage($sourceWand, $compositeWand, MW_ScreenCompositeOp, 0, 0);

//print out the image
MagickWriteImage( $sourceWand, 'new_image.jpg' );
//header("Content-Type: image/jpeg");

Tuesday, 16 December 2008

Website Development Costs

Your website should look professional, be available all the time, and
be written to SELL so that you get some business out of it!
We can help you do it the right way - the way that gets results!
Below are some website development costs.

Initial Consultation - FREE!

* You can show us what you want, and we will suggest ways to do it
o How to take great pictures.
o How to write text that sells.
o How to save money in domain hosting and name registration.
o Then, you can decide whether you want us to help you.
o If you don't know anything about the Internet or marketing, we
will explain things in layman's terms, not in "tecky" terms!
Contact us.

Prices are approximate because of many variables. How
fast do you need it? How much development needs to be done? Who is going to
supply the text and photos? Don't forget that promotion of your website is as
important as having a website. In our opinion, there is little use for a
website that no one visits. We want to see your website succeed as much as
you do! Having visitors coming to your website in a buying mood - that is
what we want to happen for your website.

Website development costs:

Basic Package - $380

* 1 page, approximately 300 words

(Note: you provide the text)

* Your contact information

* 1 email link, 6 links within website, 6 links outside of website

* Your logo (provided by you in .jpg or .gif format)*

* 2 photos (provided by you in .jpg format)**

* Free tracker installed on website.
Contact us.

Bronze Package - $790

* 2 - 5 pages, approximately 300 words per page
(Note: you provide the text)
* Your full contact information
* Up to 5 email links, 12 links within website, 12 links outside of
* Your logo (provided by you in .jpg or .gif format) on all pages*
* Up to 10 photos (provided by you in .jpg format)**.

* Free tracker installed on website.
Contact us.

Promotion Package - $999

* For those who presently have a website, but it is not drawing
traffic. You need qualified visitors - ones that are in a buying mood
for your product or service.
* People searching on the web are looking for your product or service.
Have your website show at the top of the search engine results pile!
* Analysis of present log files, if any.
* Website pages optimized for search engines and directories

(including Meta Tags, Image Tags, and keyword "loading" of up to 6
* Locating suitable reciprocal linking websites - minimum 15
but we suggest 30.

(including finding appropriate websites, sending requests and answering
emails, and putting links with descriptions on site).
* Hand submitting to top 10 free major search engines and

(Google, Yahoo, MSN, HotBot, Lycos, Canada, etc. - package does not include
submission to search engines that charge for listings)***
Contact us.


* Basic hosting starts at $12/month. We used to recommend a
cheaper hosting service, for about $5/month, but we found that they were
unreliable - a fair number of times the website would not be viewable.
You want 99% reliability, with fast connections, full backup in case of
power failure, daily backup of data, and other critical items.
Read more about hosting.

Maintenance/Promotion - $90/month

* Your website will be professionally watched over.
* Continuous promotion - resubmission to search engines if needed.
* We will answer your questions about or respond to link requests.
* You can have changes done easily.
Click here for more
* Your website will look fresh - put your press releases on, etc.
* We will answer requests for reciprocal links, if appropriate.
* We will be available to answer your questions.
* Up to 1.5 hours per month, not compounding.
* Note: price may vary with complexity of website.

Website Link-Building

* Reciprocal linking will increase your website
visitor numbers from other websites.
* Reciprocal linking will raise your profile
on the major search engines.
* Having other websites linked to yours will
benefit your traffic for years.
* 30 other websites linked to your site -
approximately $450 (depends on certain criteria).

Hourly rate
for website development costs:

* $60/hour (USD)
* Basically, we charge for our time. We have the
proper tools and experience to get your job done quickly and
professionally. We are a home-based business with low overheads. We
constantly keep up on the latest methods of promotion, as well as
purchasing tools (programs) that help us do our job faster and more
effectively - to your benefit. We have been in the website development
business since 2000. Call us
today. Toll free in North America 1- 866-726-0788.

* How do our prices compare to other

Master level Web Development costs from $75-120/hr.

Custom Graphics costs $65-$75/hr.

On-Site Digital Photography costs $80+/hr.

Maintenance Contracts are negotiated for around $55-$75/hr.

Web Design Consulting costs $100-$300/hr.

Some companies cost $95 - $120/hr. across the board.

Setting up a Link Directory - we charge about $12/link. Here's
the competition's rate (taken from this web page:

Advertising and Marketing Services
Custom reciprocal link directory with 100
targeted reciprocal links $3000 per directory
Additional reciprocal links added to an
existing reciprocal link directory $20 per link

Thursday, 11 December 2008

SHELL: sed and tr


sed '$ w temp1' file1
sed '$a\abc' temp1>temp2
tr "\n" " "<temp2>temp3
newlastline=`cat temp3`
sed '$ d' test
sed '$a\'"$newlastline" file1

sed -i '$ s/$/abc/' file1 #更简单的方法

Wednesday, 10 December 2008

Excel to read files then plot

1. File selection: to select which file you want to plot
Public i As Integer

Sub FileSelect()

' File dialog to select files
Dim fd As filedialog
Set fd = Application.filedialog(msoFileDialogFilePicker)

'Declare a variable to contain the path
'of each selected item. Even though the path is aString,
'the variable must be a Variant because For Each...Next
'routines only work with Variants and Objects.
Dim vrtSelectedItem As Variant


With fd
If .Show = -1 Then
i = 1
For Each vrtSelectedItem In .SelectedItems
Cells(i, 1).Value = vrtSelectedItem
i = i + 1
Next vrtSelectedItem
Else 'The user pressed Cancel.
End If
End With
'Set the object variable to Nothing.
Set fd = Nothing

' Sort the file list as Ascending, otherwise it will be sorted by selecting sequence
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("A1"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range("A:A")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
End With

End Sub

2. Main module: to re-arrange the data, format them then plot it.
Sub Main()

' Initialization
Dim LastCell As String
Dim wb_1 As Object
Dim ws_3 As Worksheet
Dim ws_plot As Worksheet
Dim FileName As String
Dim R_last As Integer
Set wb_1 = ActiveWorkbook
Set ws_3 = wb_1.Sheets(3)
Set ws_plot = wb_1.Sheets(2)

' Call the files inserted in worksheet(1), and variable i is public var, declared in module 2.
Dim j As Integer
j = 1
R_last = 1
For j = 1 To i - 1
FileName = wb_1.Sheets(1).Cells(j, 1).Value
Call doloop(FileName, R_last, wb_1, ws_3, ws_plot)
Next j

' Delete some useless rows for plotting
Dim k, R_plot As Integer
For k = 2 To R_last
If Left(Cells(k, 1).Value, 1) = ":" Then
Range(Cells(k, 1), Cells(k + 3, 1)).EntireRow.Select
Selection.Delete Shift:=xlUp
R_plot = k - 1
End If
Next k

' Plot the chart
Dim xyRange, ErrAmount As String
xyRange = "A3:A" & R_plot & "," & "C3:C" & R_plot
ErrAmount = "=" & ws_plot.Name & "!N4:" & "N" & R_plot

ActiveChart.SetSourceData Source:=Range(xyRange), PlotBy:=xlColumns
ActiveChart.ChartType = xlLine
With ActiveChart.SeriesCollection(1)
.ErrorBar Direction:=xlY, Include:=xlBoth, Type:=xlCustom, Amount:=ErrAmount, MinusValues:=ErrAmount
End With

End Sub

Function doloop(FileName As String, ByRef R_last As Integer, ByRef wb_1 As Object, ByRef ws_3 As Worksheet, ByRef ws_plot As Worksheet)

Dim wb As Object
Dim PosC, R_Str, C_Str As String
Dim R, C As Integer

' Open the text file and copy contents
Workbooks.OpenText FileName:=FileName, Origin:=936, StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, Tab:=True

LastCell = Selection.Address(RowAbsolute:=True, ReferenceStyle:=xlR1C1)

PosC = InStrRev(LastCell, "C")

R_Str = Right(Left(LastCell, PosC - 1), Len(Left(LastCell, PosC - 1)) - 1)
C_Str = Right(LastCell, Len(LastCell) - PosC)

R = CInt(R_Str) ' total number of rows
C = CInt(C_Str) ' total number of columns

Range(Cells(1, 1), Cells(R, C)).Select
Set wb = ActiveSheet.Parent
With ws_3
.Cells(R_last, 1).Activate
End With
Application.CutCopyMode = False
wb.Close SaveChanges:=False

R_last = R_last + R

' Move the Standard Deviation part to the right side
Range(Cells(R_last - R, 1), Cells(R_last - R + R / 2 - 1, C)).Select
With ActiveSheet
.Cells((R_last - R - 1) / 2 + 1, 1).Activate
End With

Range(Cells(R_last - R + R / 2, 1), Cells(R_last - 1, C)).Select
With ActiveSheet
.Cells((R_last - R - 1) / 2 + 1, C + 2).Activate
End With

End Function

Sunday, 7 December 2008

HOWTO: vuze (azureus) playing flash plugin

Vuze apparently uses XulRunner as the browser, So copy or link this file:




Thursday, 4 December 2008

HOWTO: packagekit to check update per login

PackageKit only checks once per the update interval, by default once every day.
It does not check on every desktop login.

You can change this behaviour by changing

get_updates_login to TRUE in gconf-editor. The
description of this key is: "Get the update list when the session starts, even
if not scheduled to. This ensures the user has up to date and valid data in the
tray at startup."

Tuesday, 2 December 2008

iphone 安装 wedict

http://stardict.sourceforge.net/Dictionaries_zh_CN.php星际译王的巴比伦词库 http://reciteword.sourceforge.net/stardict/babylon.php
StarDict Lingvo Dictionaries http://reciteword.sourceforge.net/stardict/lingvo.php
下载tarball包,用7-zip解压,然后把dict.dz改为dict.gz再用7-zip解压,得到dict文件,然后把dict 和idx这两个文件拷到~/Library/weDict 即1.1.3为/var/mobile/Library/weDict 1.1.3以前为/var/root/Library/weDict/
安装正常后,应该为同名的两个文件 dict和idx,运行后会生成第三个同名文件idxc. 如果没有这个目录,而是在Library下有一个 weDict文件的话,请删除这个文件,重新安装。
推荐手动安装,使用winscp(windows)或 fugu(mac).


下载地址为:http://prdownloads.sourceforge.n … TS.tar.bz2?download
安装路径为 ~/Library/weDict下载后将解压好的 WyabdcRealPeopleTTS目录通过winscp(windows)或fugu(mac)上传到安装目录。

6. 1.0.2运行不了v0.8?

从目前情况来看,好像是运行不了,我的版本的是1.1.1,没有在102上测 。哪位老大愿意帮忙测一下的话,按以下步骤,把错误信息发给我。
6.1 iphone安装好openssh,weDict 0.8及相应字典。
6.2 putty联接到iphone运行如下命令:cd /Applications/weDict.app
6.3 把错误信息发给我laoren@office.weiphone.com

7. 1.1.3查本地单词死机?

不是死机,是因为权限的问题。用ziphone破解的1.1.3后安装的installer的所有者还是root,所以建立的 /var/mobile/Library/weDict的目录仍为 root所有,而weDict用户权限为mobile, 当查询时,因为权限问题,没有办法建立缓存文件,所以很慢。解决办法:chown -R mobile:mobile /var/mobile/Library/weDict

Monday, 1 December 2008

Ubuntu smb.conf, supporting 'net usershare'=nautilus-share

usershare owner only = False
workgroup = workgroup
server string = %h server (Samba, Ubuntu)
dns proxy = no
log file = /var/log/samba/log.%m
max log size = 1000
syslog = 0
panic action = /usr/share/samba/panic-action %d
encrypt passwords = no
passdb backend = tdbsam
obey pam restrictions = yes
unix password sync = yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
pam password change = yes
map to guest = bad user
usershare allow guests = yes
security = share
comment = All Printers
browseable = no
path = /var/spool/samba
printable = yes
create mask = 0700
comment = Printer Drivers
path = /var/lib/samba/printers
path = /home/cross/test
writeable = yes
; browseable = yes
guest ok = yes

lyx: insert unnumbered chapter/section to Table of Contents

Just like metioned here:

To insert unnumbered chapter:

To insert unnumbered section:

First Apple Store and younger Steve Jobs

Review: pointer, reference in c++

A Reference Guide
Last updated Jan 1, 2004.from: http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=166

Unlike most other programming languages, C++ offers an unusual diversity of argument passing mechanisms: pass by value, pass by address, and pass by reference. Additional non-standard argument-passing mechanisms are also supported by certain compilers, such as passing arguments on a register. Today I will explain the semantics of the three standard argument passing mechanisms, and focus on reference variables.

A bit of History
Most high level programming languages offer only a single argument passing mechanism. In Pascal and Ada, for example, arguments are passed by reference and that's it. In Java, objects are passed by reference, whereas fundamental types such as int and boolean are passed by value.

The crucial point, however, is that programmers cannot intervene or control the actual argument passing mechanism that the language applies. C is different in this regard. Built on the foundations of BCPL and B, which were really nothing more than high-level assembly languages, it offered two argument passing mechanisms: pass-by-value and pass by address. Oddly enough, it didn't offer the more common notion of pass by reference.

Pass by Value
Pass by Value is the default argument passing mechanism of both C and C++. When a caller passes by value an argument to a function (known as the callee), the latter gets a copy of the original argument. This copy remains in scope until the function returns and is destroyed immediately afterwards. Consequently, a function that takes value-arguments cannot change them, because the changes will apply only to local copies, not the actual caller's variables. For example:

void negate(int n) //buggy version
n=-n;//affects a local copy of n
void func()
int m=10;
negate(m);//doesn't change the value of m
std::cout<<m<<std::endl; //diplay: 10
When negate() is called, C++ creates a fresh copy of m on its stack. negate() then modifies this private copy, which is destroyed immediately when it returns. The original variable m remains intact, though. Consequently, the cout expression displays 10 rather than -10. If you want the callee to modify its arguments, you must override the default passing mechanism.

Pass by Address
In C, the only way to achieve this is by passing the argument's address to the callee. This passing mechanism is traditionally called pass by address.

In the literature, this often called pass by reference too, although it's is a misnomer -- C++ uses this term to denote a radically different passing mechanism. For example,

void negate(int * pn)
Similarly, the caller must also be adjusted:

void func()
int m=10;
negate(&m);//pass m's address<
std::cout<<m<<std::endl; //display: -10
Pass by Reference
This is all well and good. The problem with this technique is that it's tedious and error-prone. My impression is statistically, most C/C++ function calls don't use pass by value so forcing programmers to override the default passing mechanism using the &, * and -> operators is an example of a bad language design choice. C++ creators were aware of this. They introduced a new type of argument passing, namely pass by reference. The addition of reference variables and arguments to C++ was only a means of fixing an historical accident made in C about a decade earlier rather than a genuine innovation. However, the introduction of references did affect fundamental programming idioms in C++.

Most textbooks will tell you that a reference is "an alias for an existing object." For example,

int m=0;
int &ref=m;
The reference ref serves as an alias for the variable m. Thus, any change applied to m is reflected in ref and vice versa:

std::cout<<ref<<std::endl;// output 1
++ref; //increment m
std::cout<<m<<std::endl;// output 2
In other words, ref and m behave as distinct names of the same object. In fact, you may define an infinite number of references to the same object:

int & ref2=ref;
int & ref3=m;
//..and so on
Here ref2 and ref3 are aliases of m, too. Notice that there's no such thing as a "reference to a reference;" the variable ref2 is an alias of m, not ref.

In most cases, references are used as a means of passing arguments to a function by reference. The nice thing about references is that they function as pointers from a compiler's point of view, although syntactically they behave like ordinary variables. They enable a callee to alter its arguments without forcing programmers to use the unwieldy *, & and -> notation:

void negate(int & n)
>n=-n;//modifies caller's argument
void func()
int m=10;
negate(m);//pass by reference
std::cout<<m<<std::endl; //diplay: -10
Advantages of Pass by Reference
Passing by reference combines the benefits of passing by address and passing by value. It's efficient, just like passing by address because the callee doesn't get a copy of the original value but rather an alias thereof (under the hood, all compilers substitute reference arguments with ordinary pointers). In addition, it offers a more intuitive syntax and requires less keystrokes from the programmer. Finally, references are usually safer than ordinary pointers because they are always bound to a valid object -- C++ doesn't have null references so you don't need to check whether a reference argument is null before examining its value or assigning to it.

Passing objects by reference is usually more efficient than passing them by value because no large chunks of memory are being copied and constructor and destructor calls are performed in this case. However, this argument passing mechanism enables a function to modify its argument even if it's not supposed to. To avert this, declare all read-only parameters as const and pass them by reference. This way, the callee will not be able to modify them:

void display(const Shape & s)
The introduction of references to C++ initially caused a bit of confusion, especially among ex-C programmers who weren't sure which passing mechanism to use when (and in those days, virtually all C++ programmers were former C programmers). Even illustrious gurus offered to use the following dichotomy: when a function modifies its arguments, pass them by address and when it doesn't, pass them as references to const.

Today, using bare pointers is a thing of the past. In most cases, C++ offers superior alternatives that are both safer and cleaner. Similarly, when you decide how to pass arguments to a function, use references by default (except when you truly need to pass them by value) and avoid passing by address, unless there's a compelling reason to do so. If the function in question shouldn't modify its arguments, they should be declared const and passed by reference; the lack of the const qualifier indicates that the function is allowed to modify an argument. When should you pass arguments by address? Only when the function deals with real pointers. For instance, a function that allocates raw storage, or when a null pointer is a valid option. Otherwise, use references.

Saturday, 29 November 2008

HOWTO: stop imsetting-daemon im-info-daemon

I really don't know how many people will switch between more than 2 input methods, while imsettings, as a project, just provide such a function.
This is useless to me, and costing almost 7m memory when booting up fedora.

This is the solution to stop it, and still keeping scim in your system.

Put 'DISABLE_IMSETTINGS=true' in the first line of '/etc/X11/xinit/xinitrc.d/50-xinput.sh'.


IMSettings is a framework that delivers Input Method
settings and applies the changes immediately. so it will
takes an effect without restarting applications and the

Input Method is used to input some dozens of characters that
can't be represented with ASCII characters, with some
framework such as XIM and SCIM via GTK+/Qt
immodule. particularly which to handle languages that is a
bit complex to do the same thing with the keyboard layout
such as XKB. In the past, those frameworks has been applied
through the environment variables, such as XMODIFIERS and
GTK_IM_MODULE. and can't be influenced immediately and can't
be without restarting the desktop because of its nature -
it's being inherited from the parent process unless it's
being brought up with the obvious thing from the terminal
say. Also, there are no such framework to bring up the
necessary process at the run time - of course anyone could
runs it manually though, it's totally out of focus on this

* Provide the information of Input Method through IMSettings
* Provide the DBus service to start/stop process of Input
* Provide the way to apply Input Method to applications

IMSettings may helps when:

* you may want to disable Input Method entirely to use
features on any applications, which actually can't use
with Input Method because of the key conflicting.
* you may try another Input Method without closing current
desktop session.
* someone may wants to borrow your desktop temporarily,
which uses different Input Method.
* the appropriate Input Methods needs to be installed by
default regardless of you use, such as Live image.

Supported Toolkits
* GTK+ (with GConf backend)
* Xfce (with GConf backend and a plugin for xfce-mcs-manager)
* X (with IMSettings XIM server; require libgxim)

Information files for Input Method
To make Input Methods available from IMSettings, every Input
Methods that hopes so has to have the information file to
let IMSettings know. those files is usually put under a
directory where you can change the default value with
--with-xinputdir. the filename has to contain .conf or
something that you can also change the default value with
--with-xinput-suffix to avoid listing every Input Methods
that might not work for some languages. Input Methods
doesn't support multiple languages such as XIM doesn't have
to have .conf suffix or so. xim.conf can deals with such
configuration files properly for appropriate languages
according to current locale.

Available parameters

The following parameters can be described as the shell
environment variables like FOO=BAR in the information file.


An optional program that may want to bring up for Input
Method, such as the panel and the toolbar and so on.


A list of command line options for AUXILIARY_PROGRAM.


GTK+ immodule name that want to use.


An icon file to use in GUI.


A parameter to hide Input Method from the inventory. you
however can still take an action against such Input Method
via IMSettings.


An optional long description to explain what this Input
Method is.


An optional program that set up Input Method. IMSettings
itself do nothing on this parameter. but other tools, such
as im-chooser will take an action for that.


A list of command line options for PREFERENCE_PROGRAM.


Qt immodule name that want to use.


An optional short description to explain what this Input
Method is. this variable is also sued for the key to do
something on IMSettings. e.g. to start/stop Input Method
and get the information and so on. so this parameter has
to be unique.

* XIM=

This variable is used for XIM. actually it looks like


A XIM server be brought up to communicate through XIM


A list of command line options for XIM_PROGRAM.

Other variables used in xinput.sh


If you want to disable imsettings feature entirely, set true. you'll
miss the feature able to change IM on demand but just need to reboot
or restart the desktop after changing something.


If your desktop has XSETTINGS manager support and you're sure it also
supports imsettings, please file a bug to imsettings. and set true
temporarily to ignore checking the desktop.


* im-settings-daemon

A DBus service that provide a facility to start/stop IM processes.

* im-info-daemon

A DBus service that provide Input Method information.

* gconf-im-settings-daemon

A DBus service that provide a bridge to communicate GTK+ through GConf.

* imsettings-xim

A XIM bridge between client applications and real XIM server.

* imsettings-applet

An applet that provides a facility of changing IM temporarily. this also
supports XIM bridge. if imsettings-xim is running, this applet will sends
a signal to be terminated.

Friday, 28 November 2008


BUGS: Samba shares

there are two type of share,
1) traditional way, GUI: system-config-samba.
2) nautilus-share, right click the folder you want to share, which is default in ubuntu. this need a line 'usershare owner only = False' to put into the global section in smb.conf, sometimes, 'usershare allow guests = yes' is also needed. This is working on the command of 'net usershare'.

1) system-config-samba will modify smb.conf; while 2) nautilus-share, using 'net usershare' will not change smb.conf. So these are different ways for sharing.

In Ubuntu, no matter what method you use, both works fine. But fedora, so far, only 1) works, while 2) always saying "'net usershare' returned error 255: net usershare: usershares are currently disabled".

Thursday, 27 November 2008

HOWTO: jython(java) calling c program in console

import java.lang

proc=java.lang.Runtime.getRuntime().exec("c:\\app.exe") // this app.exe is compiled from c
print br.readLine()
java.lang.System.out.println("last line")

Why not using os.popen() from python, is because there is a bug about calling popen. :)

happy thanksgiving

HOWTO: codecs from myplayer_win32

if the downloaded codecs file, all-20071007.tar.bz2, is extracted in /usr/lib/codecs

Then, to make these codecs visible to mplayer, do:


ln -sf /usr/local/lib/codecs /usr/lib/codecs && ln -sf
/usr/local/lib/codecs /usr/local/lib/win32 && ln -sf
/usr/local/lib/codecs /usr/lib/win32

Wednesday, 26 November 2008

efficiency of python calling c exetuable

python 可以用popen调用一个c语言的可执行程序。但是效率如何呢?

1)一个c程序: 调用一个循环求和从1到1000的function 10000次。
* File: newmain.c
* Author: cross
* Created on 26 November 2008, 16:08

#include <stdio.h>
#include <stdlib.h>

struct timeb {
time_t time;
unsigned short millitm;
short timezone;
short dstflag;
//ftime returns a struct with above structure.

int internal_loop(){
int ii=0,ss=0;
while (ii<1000)
return ss;

int main(int argc, char** argv) {

struct timeb t1,t2;
double i=0,s=0;


int repeat = 10000;


printf("time = %ld.%d\n",t1.time,t1.millitm);
printf("time = %ld.%d\n",t2.time,t2.millitm);

return (EXIT_SUCCESS);


2)以上的internal_loop function被单独生成一个c的可执行文件b.o,供python调用。以下是python代码。

import datetime
import os

t1= datetime.datetime.now()

for i in range(1,k):

print # to print a new line

t2= datetime.datetime.now()

tstr=[(t2-t1).seconds,(t2-t1).microseconds] # the attributes of timedelta class: senconds and microseconds, from http://docs.python.org/lib/datetime-timedelta.html#l2h-602
print 'Repeated sum of 1-1000 ',k,' times : '
print tstr


3) 只用python单独完成和1)一样的过程,python代码如下:
import datetime

t1= datetime.datetime.now()

for i in range(1,k):
    for ii in range(1,1000):
    print j

print # to print a new line

t2= datetime.datetime.now()

tstr=[(t2-t1).seconds,(t2-t1).microseconds] # the attributes of timedelta class: senconds and microseconds, from http://docs.python.org/lib/datetime-timedelta.html#l2h-602
print 'Repeated sum of 1-1000 ',k,' times : '
print tstr




HOWTO: Calling c (or other programs) from python

Calling c (or other programs) from python

1. swig (to generate a python extention from c)
2. dl, python object (to call c shared library)
3. os.popen() (to call other exetuable programs)

In this example, I will use the 3rd method.

1) c program.
This is an example from netbeans, it can print all the arguments, argv[0] is the program name.
# args.c ###################################
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(int argc, char**argv) {
int i;
// Prints arguments
for (i = 0; i < argc; i++) {
printf("%i: %s\n", i, argv[i]);

return 0;
compile it:
gcc args.c -o a.out

2) python script

# in python script ################
import os
printed = os.popen('./a.o hello world')
>>> printed.readline()
>>> printed.readline()
'0: ./a.o\n'
>>> printed.readline()
'1: hello\n'
>>> printed.readline()
'2: world\n'
>>> printed.readline()
Here printed is an python array object, all the methods for array are available.

Friday, 21 November 2008

C语言-指针; 2008温习

int i, *ip=&i;
注意, 这里是用&i 对ip初始化, 而不是对*ip初始化。和一般变量一样,对于外部或静态指针变量在定义中若不带初始化项, 指针变量被初始化为NULL, 它的值为0。 Turbo C中规定, 当指针值为零时, 指针不指向任何有效数据, 有时也称指针为空指针。
int i=200, x;
int *ip;

char *cp;
cp=a string;
使cp指向字符串常量中的第0号字符a, 如图所示。
CP----- | a | | s | t | r | i | n | g | \0|

以后我们可通过cp来访问这一存贮区域, 如*cp或cp[0]就是字符a,而cp[i]或*(cp+i)就相当于字符串的第i号字符,但企图通过指针来修改字符串常量的行为是没有意义的。
而char *Names[]表示指向字符的指针数组。

Turbo C中,数组名是数组的第0号元素的地址,因此下面两个语句是等价的
(1). p+i和a+i均表示a[i]的地址, 或者讲,它们均指向数组第i号元素, 即指向a[i]。
(2). *(p+i)和*(a+i)都表示p+i和a+i所指对象的内容,即为a[i]。
(3). 指向数组元素的指针, 也可以表示成数组的形式,也就是说,它允许指针变量带下标, 如p[i]与*(p+i)等价。
我们把a[0],a[1],a[2]看成是一维数组名,可以认为它们分别代表它们所对应的数组的首地址,也就是讲,a[0]代表第 0 行中第 0 列元素的地址,即&a[0][0], a[1]是第1行中第0列元素的地址,即&a[1][0],根据地址运算规则,a[0]+1即代表第0 行第1列元素的地址,即&a[0][1],一般而言,a[i]+j即代表第i行第j列元素的地址, 即&a[i][j]。

在Turbo C中, 可定义如下的指针变量:
int (*p)[3];
指针p为指向一个由3个元素所组成的整型数组指针。在定义中,圆括号是不能少的, 否则它是指针数组, 这将在后面介绍。

int *a[10];
定义了一个指针数组,数组中的每个元素都是指向整型量的指针,该数组由10个元素组成,即 a[0],a[1],a[2], ..., a[9],它们均为指针变量。a为该指针数组名,和数组一样,a是常量,不能对它进行增量运算。a为指针数组元素a[0]的地址,a+i为a[i]的地址,*a就是a[0],*(a+i)就是a[i]。

类型说明符 * 函数名(参数)
例如:int *GetDate();

类型说明符 (*函数名)(参数)
void (*fptr)();

char ** cp;
char c='A';
char *p=&c;
char **cp=&p;

void FindCredit(int **);

int vals[]={7,6,5,-4,3,2,1,0};
int *fp=vals;

void FindCredit(int ** fpp)
char *Names[]=

char **nm=Names; /* nm是一个2维字符数组 */
while(*nm!=0) printf("%s\n",*nm++); /* *nm是指针,以确定指针指向非null */
/* 对于字符数组,数组名虽然是指针,但是也可以表示整个数组指向的字符串。反而“*数组名“却返回错误Segmentation fault。*/


Wednesday, 19 November 2008

Terminology: West and East

Also, is it just me, or do Japan and New Zealand look suspiciously similar?  Has anyone seen them at a party together?

Assigning in C

int main ( int argc, char **argv ){}
int main ( int argc, char *argv ) {}

An array of char pointers can be represented as a function parameter one of two ways: char *name[] or char **name. I have chosen to use the latter, you can use either one, it is a matter of style, which I refuse to dictate
In the code you quoted, the former is correct, the latter is wrong. (But since this is C, both main functions should return 0.)

Under certain circumstances, an array decays to a pointer to its first element. In that way, char **argv and char *argv[] are equivalent.
char *argv .. u r sending a pointer to a char as an argument..this can be a normal pointer or point to a array of chars...

char **argv .. u r sending a pointer to an array of pointers as an argument . which means, each element of this array can itself point to a char array..

Tuesday, 18 November 2008

HOWTO: free up memory

Free Memory by dropping caches | Timesys Embedded Linux

From: http://linux-mm.org/Drop_Caches
To use /proc/sys/vm/drop_caches, just echo a number to it.

To free pagecache:

# echo 1 > /proc/sys/vm/drop_caches

To free dentries and inodes:

# echo 2 > /proc/sys/vm/drop_caches

To free pagecache, dentries and inodes:

# echo 3 > /proc/sys/vm/drop_caches

As this is a non-destructive operation and dirty objects are not freeable, run sync first!

Here are the before and after results from my desktop:

# free
total used free shared buffers cached
Mem: 2074840 1656052 418788 0 140108 907920
-/+ buffers/cache: 608024 1466816
Swap: 3911816 76436 3835380

# sync ; echo 3 > /proc/sys/vm/drop_caches ; free
total used free shared buffers cached
Mem: 2074840 698472 1376368 0 268 126488
-/+ buffers/cache: 571716 1503124
Swap: 3911816 76436 3835380


MySQL LEFT JOIN Explanation

(blogged from: http://www.tizag.com/mysqlTutorial/mysqlleftjoin.php )

How is a LEFT JOIN different from a normal join? First of all, the syntax is quite different and somewhat more complex. Besides looking different, the LEFT JOIN gives extra consideration to the table that is on the left.

Being "on the left" simply refers to the table that appears before the LEFT JOIN in our SQL statement. Nothing tricky about that.

This extra consideration to the left table can be thought of as special kind of preservation. Each item in the left table will show up in a MySQL result, even if there isn't a match with the other table that it is being joined to.

MySQL Join and LEFT JOIN Differences

Here are the tables we used in the previous Mysql Joins lesson.

MySQL family and food Tables:

Spinach Soup

We executed a simple query that selected all meals that were liked by a family member with this simple join query:

Simplified MySQL Query:

SELECT food.Meal, family.Position
FROM family, food
WHERE food.Position = family.Position


Dad - Steak
Mom - Salad
Dad - Tacos

When we decide to use a LEFT JOIN in the query instead, all the family members be listed, even if they do not have a favorite dish in our food table.

This is because a left join will preserve the records of the "left" table.


The code below is the exact same as the code in the previous lesson, except the LEFT JOIN has now been added to the query. Let's see if the results are what we expected.

PHP and MySQL Code:

// Make a MySQL Connection
// Construct our join query
$query = "SELECT family.Position, food.Meal ".
"FROM family LEFT JOIN food ".
"ON family.Position = food.Position";

$result = mysql_query($query) or die(mysql_error());

// Print out the contents of each row into a table
while($row = mysql_fetch_array($result)){
echo $row['Position']. " - ". $row['Meal'];
echo "



Dad - Steak
Dad - Tacos
Mom - Salad
Daughter -
Dog -

Success! The LEFT JOIN preserved every family member, including those who don't yet have a favorite meal in the food table! Please feel free to play around with LEFT JOIN until you feel like you have a solid grasp of it. This stuff isn't easy!

Another example for 'JOIN', 'LEFT JOIN' and 'RIGHT JOIN' is here:


mysql, simple commands 2008

Selecting a database:

mysql> USE database;

Listing databases:


Listing tables in a db:


Describing the format of a table:

mysql> DESCRIBE table;

Creating a database:

mysql> CREATE DATABASE db_name;

Creating a table:

mysql> CREATE TABLE table_name (field1_name TYPE(SIZE), field2_name TYPE(SIZE));
Ex: mysql> CREATE TABLE pet (name VARCHAR(20), sex CHAR(1), birth DATE);

Load tab-delimited data into a table:

mysql> LOAD DATA LOCAL INFILE "infile.txt" INTO TABLE table_name;
(Use \n for NULL)

Inserting one row at a time:

mysql> INSERT INTO table_name VALUES ('MyName', 'MyOwner', '2002-08-31');
(Use NULL for NULL)

Retrieving information (general):

mysql> SELECT from_columns FROM table WHERE conditions;
All values: SELECT * FROM table;
Some values: SELECT * FROM table WHERE rec_name = "value";
Multiple critera: SELECT * FROM TABLE WHERE rec1 = "value1" AND rec2 = "value2";

Reloading a new data set into existing table:

mysql> SET AUTOCOMMIT=1; # used for quick recreation of table
mysql> DELETE FROM pet;
mysql> LOAD DATA LOCAL INFILE "infile.txt" INTO TABLE table;

Fixing all records with a certain value:

mysql> UPDATE table SET column_name = "new_value" WHERE record_name = "value";

Selecting specific columns:

mysql> SELECT column_name FROM table;

Retrieving unique output records:

mysql> SELECT DISTINCT column_name FROM table;


mysql> SELECT col1, col2 FROM table ORDER BY col2;
Backwards: SELECT col1, col2 FROM table ORDER BY col2 DESC;

Date calculations:

mysql> SELECT CURRENT_DATE, (YEAR(CURRENT_DATE)-YEAR(date_col)) AS time_diff [FROM table];
MONTH(some_date) extracts the month value and DAYOFMONTH() extracts day.

Pattern Matching:

mysql> SELECT * FROM table WHERE rec LIKE "blah%";
(% is wildcard - arbitrary # of chars)
Find 5-char values: SELECT * FROM table WHERE rec like "_____";
(_ is any single character)

Extended Regular Expression Matching:

mysql> SELECT * FROM table WHERE rec RLIKE "^b$";
(. for char, [...] for char class, * for 0 or more instances
^ for beginning, {n} for repeat n times, and $ for end)
To force case-sensitivity, use "REGEXP BINARY"

Counting Rows:

mysql> SELECT COUNT(*) FROM table;

Grouping with Counting:

mysql> SELECT owner, COUNT(*) FROM table GROUP BY owner;
(GROUP BY groups together all records for each 'owner')

Selecting from multiple tables:

mysql> SELECT pet.name, comment FROM pet, event WHERE pet.name = event.name;
(You can join a table to itself to compare by using 'AS')

Currently selected database:


Maximum value:

mysql> SELECT MAX(col_name) AS label FROM table;

Auto-incrementing rows:

mysql> INSERT INTO table (name) VALUES ("tom"),("dick"),("harry");

Adding a column to an already-created table:

mysql> ALTER TABLE tbl ADD COLUMN [column_create syntax] AFTER col_name;

Removing a column:

(Full ALTER TABLE syntax available at mysql.com.)

Batch mode (feeding in a script):

# mysql -u user -p <> source batch_file;

Backing up a database with mysqldump:

# mysqldump --opt -u username -p database > database_backup.sql
(Use 'mysqldump --opt --all-databases > all_backup.sql' to backup everything.)
(More info at MySQL's docs.)

Join tables:
# SELECT * FROM cars JOIN colors ON colors.car_ID=cars.id
# SELECT * FROM cars AS cr JOIN colors AS cl ON cl.car_ID=cr.id
After the ON, we state on wich columns the tables should join. Every color has a reference to a car by the "car_ID" column. Every car has an
ID, and these two columns are the link between the two tables.

Saturday, 15 November 2008

HOWTO: [Lyx] replace the name of bibliography with reference

in lyx, to replace the name of bibliography with reference, using report as document class

marked as TeX

\newcommand \renewcommand

\providecommand{cmd}[args][opt]{def} -- LaTeX2e

These commands define (or redefine) a command.

* cmd The name of the new or redefined command. A \ followed by a string of lower and/or uppercase letters or a \ followed by a single nonletter. For \newcommand the name must not be already defined and must not begin with \end; for \renewcommand it must already be defined. The \providecommand command is identical to the \newcommand command if a command with this name does not exist; if it does already exist, the \providecommand does nothing and the old definition remains in effect.

* args An integer from 1 to 9 denoting the number of arguments of the command being defined. The default is for the command to have no arguments.

* opt (LaTeX2e only) If present, then the first of the number of arguments specified by args is optional with a default value of opt; if absent, then all of the arguments are required.

* def The text to be substituted for every occurrence of cmd; a parameter of the form #n in cmd is replaced by the text of the nth argument when this substitution takes place.


This would allow one to write, e.g.,

The formula for water is \water.


\water\ is the formula for water.

Note, in the second case, the trailing \ followed by a blank is required to ensure a blank space after the H2O; LaTeX ignores the blank following a command, so the space has to be specifically inserted with the \.

As a second example consider


Note that this will produce the desired formula in text (paragraph) mode because of the $...$ in the definition. In math mode, however, the first $ in the definition will cause LaTeX to leave math mode, causing problems.

In LaTeX 2.09 a standard trick for getting around this is to put the math-mode expression in an \mbox, viz.,


In LaTeX2e the \ensuremath command has been provided to alleviate this problem. The argument of the \ensuremath command is always processed in math mode, regardless of the current mode. Using this mechanism the above could be written as


Kobe dunk in the air

Thursday, 6 November 2008

HOWTO: find

From man:
-exec command ;
Execute command; true if 0 status is returned. All following arguments to find are taken to be arguments to the command until an argument consisting of `;' is encountered. The string `{}' is replaced by the current file name being processed everywhere it occurs in the arguments to the command, not just in arguments where it is alone, as in some versions of find. Both of these constructions might need to be escaped (with a `\') or quoted to protect them from expansion by the shell. The command is executed in the starting directory.

find . -type f -exec file '{}' \; # '{}' or {}, and there is a space before '\';

Runs ‘file’ on every file in or below the current directory. Notice
that the braces are enclosed in single quote marks to protect them from
interpretation as shell script punctuation. The semicolon is similarly
protected by the use of a backslash, though single quotes could have
been used in that case also.


`{}' is replaced by the current file name being processed;
\ is used for the iteration of found files.
; is to tell -exec that the job is done.

Example: find . -exec grep 'title="Phoca Gallery"' {} \; -ls
Normally above example suits our search jobs.

Monday, 3 November 2008

Confusing terminology in Fedora and Ubuntu

What is called 'orphan', and what is 'obsolete'? Fedora and Ubuntu give us contradictive and confusing definition.

Let's have a look here.


List installed packages which are not available from currenly configured repositories.
List leaf nodes in the local RPM database. Leaf nodes are RPMs that are not relied upon by any other RPM.


--'synaptic-status-installed(local or obsolete)'
Display only packages that are not (for longer) included in one of the specified repositories.

deborphan finds "orphaned" packages on your system. It determines which packages have no other packages depending on their installation and shows you a list of these packages.


Accordingly, orphans(fedora)=obsolete(ubuntu), leaves(fedora)=orphan(ubuntu).

Thursday, 30 October 2008

Repositories for Ubuntu 9.04

# deb cdrom:[Ubuntu 9.04 _Jaunty Jackalope_ - Release i386 (20090420.1)]/ jaunty main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.

deb http://gb.archive.ubuntu.com/ubuntu/ jaunty main restricted
deb-src http://gb.archive.ubuntu.com/ubuntu/ jaunty main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://gb.archive.ubuntu.com/ubuntu/ jaunty-updates main restricted
# deb-src http://gb.archive.ubuntu.com/ubuntu/ jaunty-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://gb.archive.ubuntu.com/ubuntu/ jaunty universe
# deb-src http://gb.archive.ubuntu.com/ubuntu/ jaunty universe
deb http://gb.archive.ubuntu.com/ubuntu/ jaunty-updates universe
# deb-src http://gb.archive.ubuntu.com/ubuntu/ jaunty-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://gb.archive.ubuntu.com/ubuntu/ jaunty multiverse
# deb-src http://gb.archive.ubuntu.com/ubuntu/ jaunty multiverse
deb http://gb.archive.ubuntu.com/ubuntu/ jaunty-updates multiverse
# deb-src http://gb.archive.ubuntu.com/ubuntu/ jaunty-updates multiverse

## Uncomment the following two lines to add software from the 'backports'
## repository.
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://gb.archive.ubuntu.com/ubuntu/ jaunty-backports main restricted universe multiverse
# deb-src http://gb.archive.ubuntu.com/ubuntu/ jaunty-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
deb http://archive.canonical.com/ubuntu jaunty partner
# deb-src http://archive.canonical.com/ubuntu jaunty partner

deb http://security.ubuntu.com/ubuntu jaunty-security main restricted
# deb-src http://security.ubuntu.com/ubuntu jaunty-security main restricted
deb http://security.ubuntu.com/ubuntu jaunty-security universe
# deb-src http://security.ubuntu.com/ubuntu jaunty-security universe
deb http://security.ubuntu.com/ubuntu jaunty-security multiverse
# deb-src http://security.ubuntu.com/ubuntu jaunty-security multiverse
# ============================================================================
# latest (beta versions) versions:
# deb http://ppa.launchpad.net/fta/ubuntu intrepid main

# http://medibuntu.org/
# sudo wget http://www.medibuntu.org/sources.list.d/intrepid.list --output-document=/etc/apt/sources.list.d/medibuntu.list
# the public key:
# sudo apt-get update && sudo apt-get install medibuntu-keyring

# ==========================================
# Google
deb http://dl.google.com/linux/deb/ stable non-free
# wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
# Or goto http://www.google.com/linuxrepositories/apt.html to download the key, then install by using synaptic

# Wine
#sudo wget http://wine.budgetdedicated.com/apt/sources.list.d/hardy.list -O /etc/apt/sources.list.d/winehq.list
# wget -q http://wine.budgetdedicated.com/apt/387EE263.gpg -O- | sudo apt-key add -

# Miro
deb http://ftp.osuosl.org/pub/pculture.org/miro/linux/repositories/ubuntu jaunty/

# =========================
# Firefox
deb http://ppa.launchpad.net/ubuntu-mozilla-daily/ppa/ubuntu jaunty main
# key: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 247510BE

# Banshee
deb http://ppa.launchpad.net/banshee-team/ppa/ubuntu jaunty main
# key: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6E80C6B7

# Openoffice
deb http://ppa.launchpad.net/openoffice-pkgs/ppa/ubuntu jaunty main
# key: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 247D1CFF

# Ubuntu-netbook-remix
deb http://ppa.launchpad.net/ubuntu-mobile/ppa/ubuntu jaunty main
# key: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C6598A30

# Ubuntu-tweak
deb http://ppa.launchpad.net/tualatrix/ppa/ubuntu jaunty main
deb-src http://ppa.launchpad.net/tualatrix/ppa/ubuntu jaunty main
# key: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E260F5B0

# for Mac users
deb http://ppa.launchpad.net/mactel-support/ppa/ubuntu jaunty main# key: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 2B97B7B8

# chromium
deb http://ppa.launchpad.net/chromium-daily/ppa/ubuntu jaunty main
#key: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4E5E17B5

Wednesday, 29 October 2008

[funny]Pres. Bush endorses McCain and Palin


Friday, 24 October 2008

中文podcast(beta): 介绍podcast


original audio

HOWTO: convert amr ringtones or voice recording to mp3/ogg/wav

First you should decode the file to the raw format:
$ amrnb-decoder Sound1.amr Sound2.raw
which should produce something like this:
================================================== =================
TS 26.104
REL-5 V5.4.0 2004-03
REL-6 V6.1.0 2004-03
3GPP AMR Floating-point Speech Decoder
================================================== =================

Secondly, you can convert the resulting .raw file to other preferred format in Audacity.
In Audacity, using 'File->Import->Raw Data' to open the raw file by selecting 8000 as the sample rate.

Thursday, 23 October 2008

The music players for Ipod in Linux

A little bit jealous of Mac users, because those stupid people have a smart itune.
Compared with clever us, linux users, we have to confront the bloody true world.

Here are my favorite music players. So far, none of them can be called perfect.

1. Rhythmbox 0.11.6
As a 'music' player supporting podcasting, for audio ones, it works very very well, just like itune, the episodes can be marked new or old. super!
And support Chinese characters.
But it can not do the right things of video podcast transferring to ipod, even though it can play video now using visualization.

2. Banshee 1.4
Almost can do everything, including video podcast transfering to ipod, and a sync button.
But 1) not support transferring music or videos with Chinese file name correctly. Yes, you can transfer them, but when you reconnect ipod, most of the songs in ipod can not be recognized. Maybe the database in ipod is destroyed by the Chinese characters; Except everytime you re-sync your music library in ipod.
And 2) Doesn't mark the item is new or listened. (compared with Rhythmbox and amarok)

3. Songbird 1.0
Great products and ideas from mozilla. In the current 0.70 version, the synchronaztion works. (add something to tell ipod the item is video, so ipod nano 3rd gen will not see and hear any video podcasts)
And support Chinese characters.
But it has same shortcoming with firefox 1) too much memory usage, because of internal web engine embeded. 2) Without new/old marks in Ipod. Also, 3) It can not watch folders, but this feature is coming in half of year, feb 2009. 4) Very weak functionality for podcasting.

4. Amarok
Mark new or old, video podcasting and transfering, supporint Chinese characters. Only missing the sync button, but it can add the new podcast episodes to a queue, which collects all the items are waiting for transferring to ipod.
But 1) No sync button, have to manually sync each playlist, transfer episode and delete old episodes. 2) Very odd KDE interface and menu, difficult to find the right place to show what's in ipod libary and how to transfer or sync.

Penguins can fly in Linux

中文podcast(beta): zero


original audio

Bloody correct comments on Mac and Linux(current)

Paul Murphy, noted recently,

MacOS X is the no brainer option…[it] mostly just stays out of the way of knowledgeable users. In fact, for many it meets the IT ideal: it works so well, they don’t know it’s there or doing anything to help them - they just click and expect it to work; because, well, it just does.

When Linux can do that too (and Ubuntu brings us pretty close), it makes it ever harder to justify licensing Windows. Now if the educational software vendors can just become platform agnostic, I’ll be a happy camper.

HOWTO: 使用Mutagen来修改Mp3文件的标签信息


安装Mutagen(ubuntu下终端运行 sudo apt-get install python-mutagen)后,在终端执行:

mid3iconv -e gbk *.mp3

如果想转换当前目录下的所有 mp3 (包括子目录):

find . -iname "*.mp3" -execdir mid3iconv -e gbk {} ;


Wednesday, 22 October 2008

Ubuntu AD Rocks, Come on baby


HOWTO: NFS server

Install NFS Server Support
at the terminal type
sudo apt-get install nfs-kernel-server nfs-common portmap
(Optional: sudo dpkg-reconfigure portmap)
sudo /etc/init.d/portmap restart

Editing /etc/exports
the /etc/exports file is used for creating a share on the NFS server

invoke your favorite text editor or
sudo vi /etc/exports

Here are some quick examples of what you could add to your /etc/exports

For Full Read Write Permissions allowing any computer from through

  • /files,no_root_squash,async)
    Here /24 is netmask, meaning the netmask is 24 bits. Therefore, above line can be equivalent to:
  • /files (rw,no_root_squash,async)
    details can be found in the reference

Or for Read Only from a single machine
  • /files (ro,async)
save this file and then in a terminal type
sudo /etc/init.d/nfs-kernel-server restart

Also aftter making changes to /etc/exports in a terminal you must type
sudo exportfs -a

Install NFS client support
sudo apt-get install portmap nfs-common

Mounting manually
Example to mount server.mydomain.com:/files to /files. In this example server.mydomain.com is the name of the server containing the nfs share, and files is the name of the share on the nfs server

The mount point /files must first exist on the client machine.
cd /
sudo mkdir files

to mount the share from a terminal type

sudo mount server.mydomain.com:/files /files

Note you may need to restart above services:
sudo /etc/init.d/portmap restart
sudo /etc/init.d/nfs-common restart

Mounting at boot using /etc/fstab
Invoke the text editor using your favorite editor, or
gksudo gedit /etc/fstab

In this example my /etc/fstab was like this:
  • server.mydomain.com:/files /files nfs rsize=8192,wsize=8192,timeo=14,intr
You could copy and paste my line, and change “servername.mydomain.com:/files”, and “/files” to match your server name:share name, and the name of the mount point you created.
It is a good idea to test this before a reboot in case a mistake was made.
mount /files
in a terminal, and the mount point /files will be mounted from the server.

http://www.cyberciti.biz/tips/ubuntu...nfs-share.html (for client configuration)
http://www.redhat.com/docs/manuals/l...nfs-mount.html (for mounting using fstab)
http://czarism.com/easy-peasy-ubuntu...s-file-sharing (for server configuration)
http://www.freebsd.org/doc/en_US.ISO...twork-nfs.html (contains more info about NFS)
http://www.freebsd.org/cgi/man.cgi?query=exports&sektion=5 (man for exports)
http://www.computerhope.com/jargon/n/netmask.htm (netmask /24 things)

a nice try of ubuntu linux for education in China

Tuesday, 21 October 2008

We're winning!


Blogged from: http://mwcnews.net/content/view/9256/166/

Disappointed Ubuntu upgrade to 8.10 compared with Fedora 10

New features in Ubuntu 8.10:

  • Linux kernel 2.6.27
  • GNOME 2.24
  • Encrypted private directory
  • X.Org 7.4 (offering better support for keyboards, mice, and tablets)
  • Network Manager 0.7 (improved network management)
  • Dell’s DKMS (Dynamic Kernel Module Support)
  • PAM authentication
  • BBC plugin for Totem (grab free shows from the BBC)
  • Guest session support.

New features in Fedora 10:
  • AMQP Infrastructure: A technology that makes it easy to build scalable, interoperable, high-performance enterprise application
  • Appliance Tools: Tools and meta-data that make it easier for anyone (ISVs, developers, OEMS, etc) to create and deploy virtual appliances
  • Artistic 1.0 License Removal: Remove all packages licensed under only the Artistic 1.0 license before Fedora 10
  • Better Printing
  • Better Remote Support
  • Better Start-up
  • Better Webcam Support
  • Connection Sharing: Enable adhoc network sharing
  • Echo Icon Theme
  • Eclipse 3.4: Rebase Eclipse to version 3.4
  • EFI
  • Evdev Input Driver
  • Faster Startup
  • First Aid Kit: First Aid Kit is an automated recovery tool that brings together common recovery processes and applies them to a system
  • Glitch Free Audio: Rewrite the PulseAudio sound server to use timer-based audio scheduling
  • Gnome 2.24: Re-base Fedora to Gnome 2.24
  • GStreamer RPM dependencies: dependencies Assist automated installation of GStreamer codecs provided by third-party repositories
  • Kernel Modes Setting for Graphics: Move graphic mode initialization from the X server's DDX drivers to the kernel
  • NetBeans IDE: Add the NetBeans IDE to Fedora
  • Online Accounts Service: Provides applications with credentials for user's online accounts listed on online.gnome.org or stored in GConf
  • Python NSS Bindings
  • Remote Virtual Install
  • RPM 4.6
  • Save to Bugzilla: Auto create bugzilla entry with anaconda tracebacks
  • Sbin Sanity: Add /usr/local/sbin:/usr/sbin:/sbin to the PATH
  • for normal users to simplify command-line administration tasks
  • Security Audit: A new security audit system and intrusion detection system
  • Sugar Desktop: Include the Sugar Desktop (used in OLPC) in Fedora
  • Virtual Storage: Make storage provisioning over libvirt connections (local and remote) virtual machines as simple as possible.

Compared with these two major distro of linux, ubuntu is more like a service pack to me than a new release (from:http://blogs.zdnet.com/hardware/?p=2788) . While Fedora pushes it's milestone release, which will be the shipped to next version of Red Hat Enterprise Linux 6, to a new level, even though some features have existed in ubuntu or other distros, fedora got a huge improvement.

Monday, 20 October 2008

HOWTO: 昂达989+ 白屏






HOWTO: Remove Input Method(SCIM) from Right Click Menu

Type "ALT+F2" and start the "gconf-editor". Then:

desktop --> gnome --> interface

and disable


Sunday, 19 October 2008


yum install bash-completion
Now you will get the ability to use TAB to autocomplete your command and COMMAND OPTIONS.

Friday, 17 October 2008

Queen on Google

这个Royal Channel on YouTube 公布了 54个皇室的视频,已经被浏览160万次,如果女王自己也做一个blog的话,这个浏览量应该能给皇室带了更多的广告效益。2006年女王的演讲还被受准作为podcast发行。可见女王作为一个internet的使用者,已经走在了我们绝大多数人的前面,google以之作为logo,不足为怪。

但是在这个视频中,个人发现一点比较有趣的现象,主要负责接待的google高官,无一带领带,都是敞开西服上衣,里面衬衫领子,随意凌乱的自由状态。相比其他员工在女王来临之前的毕恭毕敬的联系打招呼,可以形成一个较为鲜明的对比。也许,这就是google的dressing code,或许,google在释放什么信息。哈。纯属个人理解。但是我还是比较喜欢这种风格,即便是面女女王这样的人物。

Google, well done.

Thursday, 16 October 2008

HOWTO: equivalent yum option to apt-get autoremove

To remove packages that has been installed as dependencies for the package you are removing if they are only needed for that particular package.

a yum plugin must be installed. Otherwise, yum doesn't provide the capability.

yum install yum-remove-with-leaves
Now yum will automatically have the same function as apt-get autoremove.

yum-changelog is a Yum plugin for viewing package changelogs before/after updating.

Install yum-changelog via:
# yum install yum-changelog

How to use yum-changelog:
# yum update ktechlab --changelog
Loading "changelog" plugin
Loading "installonlyn" plugin
Setting up Update Process
Setting up repositories
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Package ktechlab.i386 0:0.3-6.fc6 set to be updated
--> Running transaction check

Changes in packages about to be updated:

ktechlab - 0.3-6.fc6.i386
* Wed Nov 22 23:00:00 2006 Chitlesh Goorah - 0.3-6
- Rebuilt due to new gpsim-devel release

By default, this plugin will show the changelogs before the updates. However if you want to make it echo those changelogs after the updates, replace when=pre by when=post in the file /etc/yum/pluginconf.d/changelog.conf

HOWTO: yum equivalent function with apt-get

1. Find and review "lost" packages

You can find orphaned packages (ie packages not in the repositories anymore) with the tool package-cleanup from the yum-utils package: yum install yum-utils; package-cleanup --orphans.
Old packages with a failing "%postun" script will remain partly
installed. Remove them with rpm -e package-name-and-version. It's often
helpful to run this command after the update, too.

But here what 'package-cleanup --orphans' found out is the 'obsolete' ones in ubuntu words. Namely installed not from repositories.

2. Find yum install or update history


3. Find orphan packages
sudo package-cleanup --orphans

Note: Here 'package-cleanup' must run with sudo or su, otherwise lots of packages will be considered as orphans because of normal users don't know the relationship between packages and repositories.

Monday, 13 October 2008

HOWTO: wine fonts

Wine中对话框默认的字体是Tahoma,在我们的LINUX上,Tahoma字体是无法正常显示中文的。比如Wine configuration中的"确定""取消"等就变成了"<<"">>"的字样。



\HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\FontSubstitutes

方法1. 直接地将这个键设为空,问题就解决了。

方法2. 将MS Shell Dlg设置为一种自己字库中已有的中文字体即可,如果已经将windows中宋体取来使用了,字库中SimSun对应宋体(这是Windows的,LINUX下默认是没有的),在这里设置为 SimSun即可。

HOWTO: find WINE menu stored in Gnome

Everything about the wine menu is stored here in a text mode, while not separately for each item.

  • .config/menus
Especially the file, 'applications.menu', a xml file, which describes the Gnome menu structure.
Every menu-edit operation on wine menu will reflected in this file.

  • .config/menus/applications-merged
The 'wine-program-*' files, xml files, are the short-cuts appears in the 'application-wine-Programs'. The rest, not appear here, will listed in the other menu.

  • ~/.local/share/applications/wine/Programs

Where the 'application-other' menu retrieve short-cuts directly from

Sunday, 12 October 2008

HOWTO: codecs for fedora


download "all-20071007.tar.bz2" to your desktop, then right click and
extract it now rename the folder to codecs, then open a terminal and

cd ~/Desktop


mv codecs /opt/
ln -sf /opt/codecs /usr/lib/win32
ln -sf /opt/codecs /usr/lib/codecs
ln -sf /opt/codecs /usr/local/lib/win32
ln -sf /opt/codecs /usr/local/lib/codecs

For Totem (gstreamer)
gstreamer-ffmpeg and ffmpeg is essential.
other plugins for gstreamer will be helpful.

Friday, 10 October 2008



•    网络管理员( Network administration (LAN, WAN)): 70%

•    Wiondows管理员(Windows administration): 69%

•    桌面支持(Desktop support): 69%

•    数据库管理( Database management): 58%

•    无线网络管理( Wireless network management): 47%

•    通讯支持(Telecommunications support): 44%

•    Web开发/网站设计(Web development/Website design): 42%

•    商业情报/报告服务(Business intelligence/reporting services): 33%

•    虚拟化(Virtualization): 32%

•    .NET开发(.NET development): 22%

•    CRM 实施(CRM implementation): 22%

•    ERP 实施(ERP implementation): 20%

•    Linux/Unix 管理员(Linux/Unix administration): 20%

•    Java开发(Java development): 17%

•    开源开发(Open source development): 17%

•    XML 开发(XML development): 17%

Bill Gates on The Daily Show With Jon Stewart

HOWTO: Gnome下节省系统资源的输入中文方式

最简单的方式输入中文就是在System-Administration-Language Support里选中'enable support to enter complex characters'.但是这样会使得scim的进程一直在后台占用一定的内存,不太‘干净’。

1。每次都是在gnome的popup menu里选择input methods-scim又太过麻烦

2。在~/.profile最后加上(出自man scim)


3。在~/.bashrc最后加上(出自man scim)

# If not running interactively, don't do anything
[ -z "$PS1" ] && return


Wednesday, 8 October 2008

hp m2000 拆解图


Monday, 6 October 2008

HOWTO: podcast a audio in blog

here we explore some new Flash MP3 players from Google and Yahoo!
that are again light-weight, easy to implement and extremely efficient.

1. Google Reader MP3 Player

Google Reader has an inbuilt MP3 player that is pretty much the same
as Gmail player but it also works on non-Google websites. This player
has volume controls, no Google branding and it auto-detects the
duration of the music file so your readers know how long the song will
last. Here’s a live example followed by the HTML embed code:

To use this MP3 player on your website or blog, copy-paste the
following code and replace the MP3_FILE_URL with the link to your MP3

<embed type="application/x-shockwave-flash" src="http://www.google.com/reader/ui/3247397568-audio-player.swf?audioUrl=MP3_FILE_URL"
width="400" height="27" allowscriptaccess="never" quality="best"
bgcolor="#ffffff" wmode="window" flashvars="playerMode=embedded" />

2. Yahoo! MP3 Player

If you think normal is boring, check this out. Yahoo! offer a code generator (Easy Listener) to help you create a Flash based MP3 player that matches your website color theme and layout. See example:

Though this Easy Listener MP3 player requires you to pass the
address of the web page that contains the MP3 file(s), you can directly
pass the MP3 link and it will work just fine. Supports auto play and
you can decide where the meta data associated with the MP3 file should
be displayed.

<embed src="http://webjay.org/flash/dark_player" width="400" height="40" wmode="transparent" flashVars="playlist_url=MP3_FILE_URL&skin_color_1=-145,-89,-4,5&skin_color_2=-141,20,0,0" type="application/x-shockwave-flash" />

3. Yahoo! Media Player

If you maintain an MP3 blog or run a podcast and regularly link to
MP3 files, it makes little sense to embed a separate Flash player with
every MP3 file. I would therefore recommend using the Yahoo! Media Player that auto-detects links to MP3 files in your web pages and creates an embedded player for each link.

All you have to do is insert the following link in your blog
template and all MP3 hyperlinks will be converted into inline MP3
players. This also has the shuffle feature and visitors can easily skip
to any song in the playlist. Excellent stuff.

<script type="text/javascript" src="http://mediaplayer.yahoo.com/js"></script>

4. Odeo MP3 Player

Odeo offers a pretty impressive MP3 player (see example)
that works perfect in web pages as well as RSS readers but a small
issue is that Odeo Player requires you to type the exact duration of
the song in the embed code. You can skip this step but then the
progress bar won’t reflect the true status when you play the
song. And there are no volume controls.

To use Odeo MP3 player in your website, add the following code replacing MP3_FILE_URL and DURATION with relevant values.

<embed src= "http://www.odeo.com/flash/audio_player_standard_gray.swf" quality="high" width="300" height="52" allowScriptAccess="always" wmode="transparent"  type="application/x-shockwave-flash" flashvars= "valid_sample_rate=true&external_url=[MP3 file address]" pluginspage="http://www.macromedia.com/go/getflashplayer"> </embed>

Summary: With so many choices, how do you pick the right MP3 player for your website ?

My photo
London, United Kingdom

Facebook & Twitter