Tuesday 30 December 2008

大家说说,GDP应该翻多少翻人民才有钱花

这个问题,我要问百度知道知道不知道知道就知道不知道就不知道不要知道说不知道不知道说知道到头来知道变成不知道不知道还是不知道天知道地知道百度知道知道若要问我知道不知道知道不知道也不知道。

晕了吧你!


null - Watch more free videos

Monday 22 December 2008

Php script to resize and add watermark

$xoffset=0;
$yoffset=0;
$opacitypercent = 80;
$scaling = 480;

$Photos=GetFileList();
foreach ($Photos as $original){
$watermark='logo.png';
AddWM($original,$watermark);
echo '*';
}


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

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

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

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

//desired opacity percentage
// THIS IS THE ONE TO SET
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;
if($WvsH>=1){
$resizeresult = MagickScaleImage( $sourceWand, $scaling, $scaling/$WvsH);
}else{
$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
if(!is_dir("PhotosWithWaterMark")){
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;
}
}
closedir($dh);
}
return $PhotosList;
}


?>

Sunday 21 December 2008

HOWTO: using Php to add watermark


makewatermark();

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' );
$originalimage='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
// THIS IS THE ONE TO SET
$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");
//MagickEchoImageBlob($sourceWand);
}
?>

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
properly.
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
website
.
* 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
pages).
* 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).
Example
* Hand submitting to top 10 free major search engines and
directories

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


Hosting

* 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
companies?


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:
http://www.simplywebhosting.com/websitemanagement.shtml

Advertising and Marketing Services
Price
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

在文件某一行(这里是最后一行)加上abc

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

ActiveSheet.Cells.Clear

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.Clear
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
.Apply
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)
wb_1.Sheets(1).Activate

' 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

ws_plot.Activate
ActiveSheet.Shapes.AddChart.Select
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

ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Select
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
Selection.Copy
Set wb = ActiveSheet.Parent
ws_3.Activate
With ws_3
.Cells(R_last, 1).Activate
.Paste
End With
Application.CutCopyMode = False
wb.Close SaveChanges:=False

R_last = R_last + R

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

ws_3.Activate
Range(Cells(R_last - R + R / 2, 1), Cells(R_last - 1, C)).Select
Selection.Copy
ws_plot.Activate
With ActiveSheet
.Cells((R_last - R - 1) / 2 + 1, C + 2).Activate
.Paste
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:


/usr/lib/mozilla/plugins/libflashplayer.so



to



/usr/lib/xulrunner-1.9/plugins


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
/apps/gnome-packagekit/force_

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

stardict主页中文字典
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
金山词霸词库http://reciteword.sourceforge.net/stardict/powerword.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).

5.真人发音如何安装?

下载地址为: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
./weDict
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
可以用putty联上运行,也可以在iphone上安装mobileTerminal运行。

Monday 1 December 2008

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

[global]
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
[printers]
comment = All Printers
browseable = no
path = /var/spool/samba
printable = yes
create mask = 0700
[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
[test]
path = /home/cross/test
writeable = yes
; browseable = yes
guest ok = yes

lyx: insert unnumbered chapter/section to Table of Contents

Just like metioned here:
http://wiki.lyx.org/FAQ/Unsorted1#toc11

To insert unnumbered chapter:
\addcontentsline{toc}{chapter}{THECHAPTERNAME}

To insert unnumbered section:
\addcontentsline{toc}{section}{THESECTIONNAME}

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)
{
*n=-*n;
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:

++m;
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.

Usage
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)
{
s.draw();
}
Summary
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
==============
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
desktop.

Background
==============
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
project.

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

Scope
=========
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.

* AUXILIARY_PROGRAM=

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

* AUXILIARY_ARGS=

A list of command line options for AUXILIARY_PROGRAM.

* GTK_IM_MODULE=

GTK+ immodule name that want to use.

* ICON=

An icon file to use in GUI.

* IMSETTINGS_IGNORE_ME=

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

* LONG_DESC=

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

* PREFERENCE_PROGRAM=

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.

* PREFERENCE_ARGS=

A list of command line options for PREFERENCE_PROGRAM.

* QT_IM_MODULE=

Qt immodule name that want to use.

* SHORT_DESC=

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
XMODIFIERS=@im=$XIM.

* XIM_PROGRAM=

A XIM server be brought up to communicate through XIM
protocol.

* XIM_ARGS=

A list of command line options for XIM_PROGRAM.

Other variables used in xinput.sh
====================================

* DISABLE_IMSETTINGS=

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.

* IMSETTINGS_DISABLE_DESKTOP_CHECK=

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.

Processes
============

* 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
br=java.io.BufferedReader(java.io.InputStreamReader(proc.getInputStream()))
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:

su

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次。
之所以要调用循环求和从1到1000,是因为这个function要声称另外的一个可执行文件供python调用,所以外部框架c和python都差不多,就是要往复调用这个function,以得出python与c的沟通效率。
#######################
/*
* 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)
{
ss+=ii;
ii++;
}
printf("%i\n",ss);
return ss;
}

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

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

ftime(&t1);

int repeat = 10000;
while(i<repeat){
s+=internal_loop();
i++;
}

ftime(&t2);
printf("%.1f\n",s);

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()

j=0
k=1000
for i in range(1,k):
printed=os.popen('/home/cross/NetBeansProjects/Application_2/b.o')
printed.readlines()
printed.close()

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()

k=10000
for i in range(1,k):
    j=0
    for ii in range(1,1000):
        j=j+ii
    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

#####################


总结
如果成功运行以上两个程序,同样是运行10000次,1)耗时274毫秒;2)20秒。
可见python与其他程序通过popen这种字符沟通的效率是比较低的。以上,1)是同一个程序调用一个子函数,速度当然是最理想的。而2)是通过console的字符交换得以沟通,这种效率当然低,甚至这还远不如主程序和子程序的沟通效率。

通过1)和3)的比较,可以很容易看出来python的语法简单,但是python比c慢也是事实,3)用时3.8秒。

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
printf("Arguments:\n");
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()
'Arguments:\n'
>>> 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;
我们定义了两个整型变量i,x,还定义了一个指向整型数的指针变量ip。i,x中可存放整数,而ip中只能存放整型变量的地址。我们可以把i的地址赋给ip:
ip=&i;
此时指针变量ip指向整型变量i.

字符指针
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号元素的地址,因此下面两个语句是等价的
p=&a[0];
p=a;
根据地址运算规则,a+1为a[1]的地址,a+i就为a[i]的地址。
下面我们用指针给出数组元素的地址和内容的几种表示形式:
(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]。
另外,在二维数组中,我们还可用指针的形式来表示各元素的地址。如前所述,a[0]与*(a+0)等价,a[1]与*(a+1)等价,因此a[i]+j就与*(a+i)+j等价,它表示数组元素a[i][j]的地址。
因此,二维数组元素a[i][j]可表示成*(a[i]+j)或*(*(a+i)+j),它们都与a[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。
例如:int *GetDate();

函数指针
指向函数的指针包含了函数的地址,可以通过它来调用函数。声明格式如下:
类型说明符 (*函数名)(参数)
其实这里不能称为函数名,应该叫做指针的变量名。这个特殊的指针指向一个返回整型值的函数。指针的声明笔削和它指向函数的声明保持一致。
指针名和指针运算符外面的括号改变了默认的运算符优先级。如果没有圆括号,就变成了一个返回整型指针的函数的原型声明。
例如:
void (*fptr)();
把函数的地址赋值给函数指针,可以采用下面两种形式:
fptr=&Function;
fptr=Function;
取地址运算符&不是必需的,因为单单一个函数标识符就标号表示了它的地址,如果是函数调用,还必须包含一个圆括号括起来的参数表。
可以采用如下两种方式来通过指针调用函数:
x=(*fptr)();
x=fptr();
第二种格式看上去和函数调用无异。但是有些程序员倾向于使用第一种格式,因为它明确指出是通过指针而非函数名来调用函数的。

指针的指针
指针的指针看上去有些令人费解。它们的声明有两个星号。例如:
char ** cp;
如果有三个星号,那就是指针的指针的指针,四个星号就是指针的指针的指针的指针,依次类推。当你熟悉了简单的例子以后,就可以应付复杂的情况了。当然,实际程序中,一般也只用到二级指针,三个星号不常见,更别说四个星号了。
指针的指针需要用到指针的地址。
char c='A';
char *p=&c;
char **cp=&p;
利用指针的指针可以允许被调用函数修改局部指针变量和处理指针数组。

void FindCredit(int **);

main()
{
int vals[]={7,6,5,-4,3,2,1,0};
int *fp=vals;
FindCredit(&fp);
printf(%d\n,*fp);
}

void FindCredit(int ** fpp)
{
while(**fpp!=0)
if(**fpp<0)>
=====================
char *Names[]=
{
"Bill",
"Sam",
"Jim",
"Paul",
"Charles",
0
};

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

先用字符型指针数组Names的地址来初始化指针nm。每次printf()的调用都首先传递指针nm指向的字符型指针,然后对nm进行自增运算使其指向数组的下一个元素(还是指针)。注意完成上述认为的语法为*nm++,它首先取得指针指向的内容,然后使指针自增。
注意数组中的最后一个元素被初始化为0,while循环以次来判断是否到了数组末尾。具有零值的指针常常被用做循环数组的终止符。程序员称零值指针为空指针(NULL)。

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 ) {}

Quote:
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

HOWTO: Mysql JOIN

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:

PositionAge
Dad41
Mom45
Daughter17
Dog
MealPosition
SteakDad
SaladMom
Spinach Soup
TacosDad

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

Result:

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.

MySQL LEFT JOIN Example

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 "
";

}
?>

Display:

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:

http://www.wellho.net/mouth/158_MySQL-LEFT-JOIN-and-RIGHT-JOIN-INNER-JOIN-and-OUTER-JOIN.html

mysql, simple commands 2008

Selecting a database:

mysql> USE database;

Listing databases:

mysql> SHOW DATABASES;

Listing tables in a db:

mysql> SHOW TABLES;

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;

Sorting:

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)
(RLIKE or REGEXP)
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:

(Example)
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:

mysql> SELECT DATABASE();

Maximum value:

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

Auto-incrementing rows:

mysql> CREATE TABLE table (number INT NOT NULL AUTO_INCREMENT, name CHAR(10) NOT NULL);
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:

mysql> ALTER TABLE tbl DROP COLUMN col;
(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

\renewcommand{\bibname}{References}
marked as TeX

==================================
\newcommand \renewcommand

\newcommand{cmd}[args][opt]{def}
\renewcommand{cmd}[args][opt]{def}
\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.

Examples
\newcommand{\water}{H$_2$O}

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

The formula for water is \water.

or

\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

\newcommand{\hypotenuse}{$a^{2}+b^{2}$}

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.,

\newcommand{\hypotenuse}{\mbox{$a^{2}+b^{2}$}}

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

\newcommand{\hypotenuse}{\ensuremath{a^{2}+y^{2}}}

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.

=========================================
Fedora:

"package-cleanup(1)"
--orphans
List installed packages which are not available from currenly configured repositories.
--leaves
List leaf nodes in the local RPM database. Leaf nodes are RPMs that are not relied upon by any other RPM.

=========================================
Ubuntu:

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

--"deborphan"
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/

# =========================
# PPA
# 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

首次试录,简要介绍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

先放上一段英语学习的mp3来调试。很快就会有这个podcast的介绍。


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文件的标签信息

具体方法如下(只针对GBK/GB18030编码的情况):

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


mid3iconv -e gbk *.mp3

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

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

这里只介绍最常见的情况,更多信息可以查看Nicky的文章,他分析得很详细。

Wednesday 22 October 2008

Ubuntu AD Rocks, Come on baby

http://blog.omega-research.org/uploads/2007/09/ubuntu-linux-very-friendly-circle-of-friends.jpg

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 192.168.1.1 through 192.168.1.255

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

Or for Read Only from a single machine
  • /files 192.168.1.2 (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.
type
mount /files
in a terminal, and the mount point /files will be mounted from the server.

Reference:
==========
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!

Image


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+ 白屏

经过一系列的刷机,烧录和几个论坛的折腾,终于找到一条融会贯通,于其他人不太一样的解决办法。

经验说明,一旦白屏,烧录很难解决。
综合其他人的经验加本人989+白屏解决办法,总结如下:

白屏的原因并非软件,而是‘接触不良’的问题。
1.在一个高级一点的单片机论坛里看到,是因为‘虚焊’,
2.在一昂达论坛看到说有人在一个黑色芯片下垫纸解决。
3.本人则是发现用力按下方向键,反而有开机成功的机会。

综上,应该是接触不良的问题。

当把最新的固件保存到根目录下,然后用力按下屏幕中央,再按住‘向下’方向键,再开机,于是发现,可以升级固件了。于是最新固件(此时是1.25)升级成功,白屏基本没有再出现。

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

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

desktop --> gnome --> interface

and disable

show_input_method_menu
show_unicode_menu

Sunday 19 October 2008

HOWTO: TAB TO AUTOCOMPLETE COMMAND OPTIONS

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




女王第二次与google‘合作’,上次是在youtuble上开设皇家频道。这次是以女王的头像的google的logo。
http://www.timesonline.co.uk/multimedia/archive/00415/google1_415407a.jpg
这个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.

================
more:
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

/var/log/yum.log

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中的"确定""取消"等就变成了"<<"">>"的字样。

解决方法很简单:

在wine的regedit中,找到:

\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

http://www.mplayerhq.hu/MPlayer/releases/codecs/



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
type



cd ~/Desktop

su

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

最需要的IT技能是什么

CIO被问道:在你的IT部门内哪些技术技能最需要?(所有的被提问者(CIO们)均工作在有100名以上员工的公司;可以选择不止一项技能;是在2008年9月做的这项调查)



•    网络管理员( 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)
GTK_IM_MODULE="scim"
export GTK_IM_MODULE
这样开机会自动启动scim但是可以方便的通过右键点击图标去关闭;如果想在输入中文,只要随便打开gnome的程序,scim会自动跟着打开,关闭gnome程序,scim也会跟着自动关闭。如此可以在不需要输入中文的时候,节省些系统资源。

此种方式的输入法是全局的(global),在所有运行的程序中都可以直接输入中文。

3。在~/.bashrc最后加上(出自man scim)
GTK_IM_MODULE="scim"
export GTK_IM_MODULE
每次要输入中文,要通过terminal去启动相应gnome程序,否则通过点击快捷图标,不会启动scim。

但是如果要在fedora下,须在这两条命令前执行以下命令,否则输入法会随着login自动启动(ubuntu的.bashrc已经自带此命令)
# If not running interactively, don't do anything
[ -z "$PS1" ] && return

此种方式的输入法只是针对相应的运行的程序(session),只有在这一个程序内可以直接输入中文。(recommended)

Wednesday 8 October 2008

hp m2000 拆解图

2005年秋季,罗钧同学托人从苏州帮我带到新加坡,3年过去了,我还没毕业,(经抢救无效)它先挂了。









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
file.


<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
twitter.com/zhengxin

Facebook & Twitter