Friday, March 27, 2009

Vim: line number trick

I have 89 line of code and would like to add the line number in it. E.g., change
hashImages.insert("CPE_GRAY_POWERLINE_NORMAL",

into:
hashImages.insert("CPE_GRAY_POWERLINE_NORMAL", mImageList[0]);
till:
hashImages.insert("SUBSTATION_YELLOW_ANY_COLLAPSED", mImageList[88]);

A vim trick to do this is:
g/^/exe ":s/$/mImageList[".line(".")."]);"


I got the idea from here.

Friday, February 06, 2009

Make CVS service available in pserver mode

This process applied on Fedora.

1. Create a CVS repository, suppose the location is /home/cvs and configuration file will be /home/cvs/CVSROOT/config.

2. Edit /etc/services file to allow tcp/udp port 2401.
cvspserver 2401/tcp # CVS client/server operations
cvspserver 2401/udp # CVS client/server operations
cvsup 5999/tcp CVSup # CVSup file transfer/John Polstra/FreeBSD
cvsup 5999/udp CVSup # CVSup file transfer/John Polstra/FreeBSD
ssm-cvs 2477/tcp # SecurSight Certificate Valifation Service
ssm-cvs 2477/udp # SecurSight Certificate Valifation Service
Well, the first 2 lines should be enough.

3. Edit /etc/xinetd.d/cvs file to enable the CVS pserver.
[root@host]# cat /etc/xinetd.d/cvs
service cvspserver
{
disable = no
port = 2401
socket_type = stream
protocol = tcp
wait = no
user = root
passenv = PATH
server = /usr/bin/cvs
env = HOME=/home/cvs
server_args = -f --allow-root=/home/cvs pserver
}
4. Restart xinetd by running "/etc/init.d/xinetd restart".

5. Edit /etc/sysconfig/iptables to allow network packages pass through port 2401. Notice that the order of the rules is important.
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2401 -j ACCEPT
6. If necessary, run "/usr/sbin/setenforce 0" to put SELinux to Permissive mode. See "man setenforce" for details. Or edit the /etc/selinux/config file to persist the change.

7. When necessary, create a /home/cvs/CVSROOT/passwd file to authenticate user logins. Details will be available in CVS document.

That's probably all necessary steps.

References:
[1] http://forums.fedoraforum.org/archive/index.php/t-54342.html
[2] http://kelvinchufei.blogspot.com/2007/03/how-to-setup-cvs-server-on-fedora-core.html
[3] http://www.mail-archive.com/info-cvs@nongnu.org/msg02106.html
[4] http://ximbiot.com/cvs/manual/cvs-1.11.23/cvs_18.html#SEC195

Friday, January 23, 2009

How to iSync Nokia 3500c with iSync Bluetooth?

Well, the tip comes from Apple forum.

Generally speaking, hacking the plugins of iSync works for most phone models. My comment is in the bottom: (It's strange that it thought I'm on a PowerBook running 10.5.6...)

Hi,

Thanks for the helpful tip. I just made iSync work with my Nokia 3500c. Somebody who had tried this model but failed please try this:

1. Keep your phone name identical. If the phone is discovered as 3500 (BlueTooth), then use 3500 in the plist file, and if it's set to 3500c, then use 3500c in plist file.

2. Also replace 6131 with 3500(c) in the Info.plist, which is in the upper level of that folder.

3. If iSync can't connect to your 3500c, just use BlueTooth browser to read the file on device, then try again with iSync. At least it works for me. Good Luck!

Again, thanks for sharing!

Calvin

PowerBook Mac OS X (10.5.6)

Sunday, November 23, 2008

Is my computer 64-bit support?

Well, one thing is when we're talking about 64bits system, actually we are talking about 2 separate things: 64-bit hardware support and 64-bit OS support.

In my understanding, if you can see 4GB or more memory in your system profile, then you have a 64-bit computer. (Whatever OS you use, there should be some system utils can help you to monitor the system status in runtime, e.g., system monitor for mac/u*x/, task manager for Windowz, etc.)

You may not really feel how 64-bit benefits you. But at least it's compatible with most of your current applications so you don't need to pay extra money to get the 64-bit edition for them.

Want to know more about 64-bit? Take a few minutes to read the following links:
- What kind of performance increase can I expect in going from 32-bit to 64-bit Stata?
- First Look: Leopard first looks: 64-bit support
- Is Leopard truly 64-bit?

Saturday, November 22, 2008

JDK 6 for Mac doesn't have Console support?

I just downloaded and installed JDK6 form here (http://support.apple.com/kb/HT1856). But look like there isn't the lib java.io.Console since the code "import java.io.Console;" will cause a compiler error, "cannot find symbol". That's strange.

Tested on a Linux box and it's good. So I suppose this "Java for Mac OS X 10.5 Update 1 adds support for Java SE 6" (This update provides Java SE 6 version 1.6.0_05.) is not a full version. If it's tailored, how could it comply with the license? Maybe I missed something here...

Wednesday, November 05, 2008

HTTP Protocol: Method OPTIONS?

Well, the method OPTIONS defined in HTTP RFC[1] is required to be implemented for all web servers. [2]

But when I test it with my local apache server and the bckids.info server, something looks interesting...

1. Trying http/1.0 shows the methods allowed together with error 501.

calvin:~ cxl$ telnet localhost 80
Trying ::1...
Connected to localhost.
Escape character is '^]'.
options * http/1.0

HTTP/1.1 501 Method Not Implemented
Date: Wed, 05 Nov 2008 22:26:33 GMT
Server: Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
Allow: GET,HEAD,POST,OPTIONS,TRACE
Content-Length: 209
Connection: close
Content-Type: text/html; charset=iso-8859-1


2. Trying http/1.1 shows error 400: Bad Request.

calvin:~ cxl$ telnet localhost 80
Trying ::1...
Connected to localhost.
Escape character is '^]'.
options * http/1.1

HTTP/1.1 400 Bad Request
Date: Wed, 05 Nov 2008 22:26:06 GMT
Server: Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7l DAV/2 PHP/5.2.6
Content-Length: 226
Connection: close
Content-Type: text/html; charset=iso-8859-1


[1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.1
[2] http://en.wikipedia.org/wiki/HTTP

Wednesday, October 15, 2008

VMWare Server upgrading issue

I upgraded my VMWare Server from 1.x to 2.x recently. Something strange happened since then.

At first beginning, everything looks fine. After a few days, the windows service "VMWare Host Agent" couldn't start up automatically when the host machine boots up, although it's set to start "Automatic". I managed to solve the problem by configuring the "Log On" option in windows service manager, select "This account" and put in user name and password of the administrator manually.

It worked for a few days, and then I got an error for any VM when connecting with "VMWare Infrastructure WebAccess" through a browser window. The error message is "Unable to connect to the MKS: Login (username/password) incorrect.".

So after a few days confusing, I reconfigured the windows service to change the "Log On" method back to use system account. But again, the service won't start up automatically.

What's the problem here? Not a clue on vmware support forum, and they don't allow me to login to ask question either! :(

Tuesday, July 22, 2008

How to develop addons for rtl locales

The topic was initiated from url: http://www.babelzilla.org/content/view/316/. But the approach provided below doesn't work at all.

function getDirection() {
var myLocalBundleService = Components.classes ["@mozilla.org/intl/stringbundle;1"].getService(Components.interfaces.nsIStringBundleService);
var myLocalStrings = myLocalBundleService.createBundle("chrome://global/locale/global.dtd");
return myLocalStrings.GetStringFromName("locale.dir");
}



Good thing is that we can still read the direction property from document.dir and preference bidi.direction. The definition of bidi.direction can be found in source code:
// ------------------
964 // Text Direction
965 // ------------------
966 // 1 = directionLTRBidi *
967 // 2 = directionRTLBidi
968 pref("bidi.direction", 1);
Both of them are r/o, but here we just need to read the information.

Friday, July 04, 2008

Logitech QuickCam service blocks Firefox build...

Although it's a known issue in bugzilla I was still really surprised. After reading the log I can see the "rebase" dll caused the problem.

Removing the service and keeping the driver, QuickCam still works and Firefox started building. That's funny...

This is the most helpful:
David Humphrey 2008-02-15 06:49:02 PDT
From the mingw FAQ (http://www.mingw.org/MinGWiki/index.php/FAQ):

Why does make often crash creating a sh.exe.stackdump file when I try to
compile my source code?
If you experience random crashes with make as well as with the msysinfo command
(i.e., repeating the command often allows to compile the source code
successfully), the issue might be caused by the Logitech QuickCam software.
Here is provided a solution to this issue:

* type the command services.msc from a command prompt (you will need
administrator privileges to do this), then find the "Logitech Process Monitor"
service, and change the "Startup type" from "Auto" to "Manual". Do the same
with the "LVSrvLauncher" service.
* type the command regedit from the command prompt (you will need
administrator privileges to do this), then find the key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run. Among the
other REG_SZ keys, there should be three of them related to the Logitech
QuickCam, namely: "LogitechCommunicationsManager", "LogitechQuickCamRibbon",
"LVCOMSX". Make a backup of the registry, then remove them.
* reboot your PC

In this way the Logitech QuickCam daemon won't be available anymore.
Nonetheless, the camera will keep working just ok with 3rd party software
(e.g., Skype). If you want a less drastic solution, just kill the lvprcsrv.exe
process whenever you want to use MSYS by typing at the command prompt: pskill
-t lvprcsrv.exe (you will need PsTools and administrator privileges to do
this). However, as soon as you will plug in the USB cable of your Logitech
QuickCam, the daemon will be restarted, while with the first procedure it
won't.

Friday, April 04, 2008

How come western people to be so rude?

Got a comment from technical support this morning. Someone said:

Additional Comments:
Fuckin' Shit, This Is SO Not Workin', And Besides The Fuckin' Crap It's A Hell Of Annoyin'
Should Make It Better Assholes.
If You Are Gonna Make Something Make It The Right Way.

I always think western people are not as polite as they claim for themselves. This is a sample. How could they export their "civilization" to other country like this?

What a shame!

Friday, March 28, 2008

Leopard AddressBook: new encoding for vCard

I have an application which can export "My Card" in addressbook to a vCard (.vcf) file and then import it to another application. For Leopard, this approach stopped working.

The applescript for exporting looks like:
After digging some details, I realized that the reason is that in Leopard, the output file is no longer a UTF-8 encoding file. It's UTF-16BE! So the file looks like:


Dump it in hex mode, found the magic is the first word:
FE FF

OK, now ignore in the importing application and everything is fine.

Friday, January 11, 2008

Run VNC service on Ubuntu

This command will be able to run a user specific vnc service on a ubuntu machine.

"Xvnc :5 -query localhost -geometry 1024x768 -depth 16 -once -securitytypes none -fp /usr/share/fonts/X11/misc -DisconnectClients=0 -NeverShared -extension XFIXES"

And when choose "Disconnect" from the vnc client, the server will shutdown itself.

Thursday, January 10, 2008

Firefox has lot of issues on Mac.

Recently when developing an addon for firefox 2/3, noticed that the preference window overlay ruins the default preferences window. It grows the height of the window and some times may cut screen elements in the bottom of the dialog.

Just aware the reason today, I missed an attribute "helpURI" for the "prefpane" element. Add this line, and the "help" button will show up in left bottom corner. Then everything is fine.

Since it looks like an irrelevant attribute to me, still think it's a bug of firefox. Filed on bugzilla.
Just set attributes 'class' and 'image' for a menuitem, the menu will become vivid immediately.
















Sample:
var mi=document.createElement('menuitem');
mi.setAttribute('class', 'menuitem-iconic');
mi.setAttribute('image','chrome://

But it may be affected by themes that you applied. See snapshot below.


Tuesday, December 11, 2007

Make a "toaster" in firefox

(Refer to http://developer.mozilla.org/en/docs/nsIAlertsService#Example .)
The nsIAlertsService works great on Mac (firefox 3 only) and Windows.

Sample:

var alertsService = Components.classes["@mozilla.org/alerts-service;1"]
.getService(Components.interfaces.nsIAlertsService);
alertsService.showAlertNotification(
"chrome://mozapps/skin/downloads/downloadIcon.png",
"Alert title", "Alert text goes here.",
false, "", null);


But in firefox 2, we have to use showPopup() and hidePopup() as workaround:

popBox.showPopup(pop, xPos, yPos, 'popup', 'bottompright');
setTimeout(function(popBox){
popBox.hidePopup(pop);
}, 2000, popBox);

Wednesday, November 21, 2007

Javascript : tricky thing for setTimeout

I have this:

function callme() {
alert('can you hear me?');
}

What's the difference among these calls?
1) setTimeout(alert('can you hear me?'), 1000);
2) setTimeout(callme(), 1000);
3) setTimeout(function () { callme(); }, 1000);

1) and 2) are the same, callme() will be executed when setTimeout processing its parameter.
3) will be called after 1000ms, likely asynchronized.

---
Roger says:
"the arguments are evaluated when setTimeout is called, so is that init function, what might work is just passing callme which is an object.

the latter (case 2) preserves the variables so to speak... scope, context"

Firefox3 has a problem.

"xul-overlay-merged observer is notified before script elements within the overlay are processed"

https://bugzilla.mozilla.org/show_bug.cgi?id=392515

Well, I guess this could be a work around.

In the <overlay id=...>, we should have <prefpane id=... onpaneload="myInit();">.
So after something like '<script type="application/x-javascript" src="chrome://..." />, 

we use

    <script type="application/x-javascript">
    <![CDATA[
    // UI-specific code
        setTimeout(function () {/*whatever*/},100);
    ]]>
    </script>

Just the onpaneload has no use here.

Friday, March 30, 2007

Installing Oracle 10g on OpenSolaris

There will be a problem... Oracle 10g claims itself to support Soalris 10 (5.10) only, but not Solaris Nevada (5.11). The trick is that there's a hidden file ".oui" in the "install" folder and the runInstaller script will call it with option "-oneclick".

The workaround is to add "-skipsyscheck" option to "runInstaller", iirc. It'll bypass the "5.10" issue and continue the installation, but ... there's no guarantee that the installation will work...

Choose style for my blog.

It's not easy to choose a style for a blog...
Well, this template let me recall the happy days in the past few years but we have to live in tomorrow, right?