Archive for Linux

Enter Chinese and do msn chat on Ubuntu

Version: Ubuntu 7.10, the Gutsy Gibbon released in Oct. 2007. I run it on VMWare Player.

Assumption: Ubuntu is connected to the web.

Do msn (Windows Live) chat on Ubuntu:

1. Application -> Add/Remove…

2. Click Internet tab on the left pane, then pick aMSN for install. As this writing, it has 4 stars under Popularity column.

3. Launch and enjoy.

By the way, so far I almost never do msn chat, but that can change if/when necessary. Once in a while, I do Skype chat.

Install and set up Chinese entry on Ubuntu, with a hat off to Nathan Sivin for his instruction. I followed his steps and just rehashed them here:

1. System -> Administration -> Language Support. Enter password as needed;

2. In Language scroll window, pick Chinese;

3. Click Apply button;

4. Check “Enable support to enter complex characters”;

5. Click Apply button. When done, close the window;

6. Open a shell, type:

locale | grep LANG=

Record the result because you will need it later. For US based Ubuntu, most likely it will be en_US.UTF-8;

7. Type:

sudo apt-get install scim-qtimm im-switch scim-pinyin

Enter password as necessary;

8. When done, type:

im-switch -z en_US.UTF-8 -s scim

Replace en_US.UTF-8 with whatever you get from step 6;

9. Reboot. For Chinese entry, press

Ctrl and Space bar

You should see a language bar in the lower right-hand corner. On the language bar, click the button immediately to the right of SCIM icon, and pick your Chinese entry methods. Press

Shift

to toggle between English (or whatever your default language) and Chinese. Press

Ctrl and Space bar

again to get rid of the language bar.

Hope this helps you. 希望这可以帮助你。

Comments (2)

My best investment so far

I’ve been using Jon’s excellent tools, ViEmu for Visual Studio, Outlook, Word, and Sql Server Management Studio for close to a year now. They make the default editor in those tools behaves like VI, with regular expression support. I bought the Enterprise Pack. Highly, highly recommended. Of course you need to know VI first.

I had some issues with ViEmu for Sql Server Management Studio on Sql Server 2008 CTP 6. So I wrote Jon. He got back to me very quickly. It turned out that the version I installed was an older one. I downloaded the newer one and it worked out of the box.

So I am a VI / Vim aficionado. In fact, I consider learning VI to be the second best investment I ever made so far in my life. The best ever happened about 5 years ago, when I finally taught myself touch typing. (I didn’t see or touch a computer and typewriter until my early twenties.) I tried to teach myself touch typing maybe ten years ago, using a high school typing book I borrowed from the local library here. That didn’t work out very well. Five years ago, I purchased a touch typing software off the web, maybe 25 dollars or so, and finally became a decent touch typist. Now I kick myself for not learning touch typing earlier.

After that, typing is not a hindrance anymore. Using Vim actually makes it enjoyable. It has made a huge difference in my life.

There is so much to learn in Vim. So far these are my most-used commands:

w
b
)
(
G
gg
cw and cNumberw
cfSomeAlphaNumericCharacter
ctSomeAlphaNumericCharacter
dw and dNumberw
C
cG
dd
.
yy
p
P
fSomeAlphaNumericCharacter
;
*
i
I
a
A
o
O
/
%
:g/^$/d to remove blank lines
Macros (q, then a letter, followed by actions that you want repeated later. For example, suppose I have a list of tables that need to be truncated, I will go to the first line, start macro recording, press I truncate table, Esc, j, then q to stop recording. For the rest of the lines, I just do Number@MacroName)

That’s all I can think of now. According to Vim Tips Wiki site, this collection of tips is the best. I found that most of the tips need to be followed consciously for a while before they become part of you. What are yours you can share with me?

Comments

Drawing Swedish flag with Logo

After our last experiment, we drew a Swedish flag with Logo. Major code improvement:

1. Introduction of variable for flag size;
2. Using the direction keyword instead of turnright and turnleft to make it less ambiguous to the code reader.

Here is the final product:

Swedish flag

Here is the code for it.

# Begin logo code

reset
x=400
canvassize 1.6*x,x
canvascolor 65,105,225
penwidth 0.2*x
pencolor 255,255,0
go 0,0.5*x
direction 90
forward 1.6*x
go 0.6*x,0
direction 180
forward x

# End logo code

Chinese flag is next. This will be a bit challenging. We will need to figure out how to draw the stars, and tilt them in the right direction. That should also give us ideas on how to draw the US flag.

2 things are of interest:

1. The code above works for KTurtle 0.6 on Ubuntu 7.1 with KDE 3.5.8, but the same code does not work on Sabayon Professional 1.1, with KTurtle 0.6, KDE 3.5.7;
2. After the Swedish flag, I thought drawing other Nordic flags is just a matter of changing colors. Turns out that is not the case, because there are subtle design and dimension differences, especially for Norwegian and Icelandic flags.

Comments

HP dv6253cl laptop fixed

It took me a while to fix the wireless problem on my HP dv6253cl.

As documented here, I tried various ways to make the wireless card work on this laptop, to no avail. I tried 3 different distros: Sabayon 3.4, Ubuntu 7.1, and Kubuntu 7.1, with different Broadcomm driver combinations I found at ndiswrapper’s wiki site. I even downloaded and compiled different ndiswrapper packages.

HP had asked me to send it back for repair in December last year. It sent me a box for packing with a prepaid FedEx label, since the laptop is still under warranty. I held on to it until late February. I got the box back 2 days ago. In all, I was pretty impressed with HP’s speed, considering the horror stories I’ve read on the web.

So I wiped everything out earlier, and installed Sabayon x86-64-3.4 MiniEdition (a flavor of Gentoo distro) on it. I am happy to report that I got wireless working on this Linux machine.

Here are the steps:

1. The first startup after Linux installation, the wireless indicator is blue;

2. I logged in as root and fired up WPA_Supplicant Administration GUI to see if I could scan and detect my wireless network. It didn’t work;

3. lspci command has this to say about the Broadcomm wireless card

03:00.0 Network controller: Broadcom Corporation BCM94311MCG wlan mini-PCI (rev 01)

4. I pretty much followed documentation here. First I removed the existing Broadcom driver (as root). After this command, the indicator turned orange:

# rmmod bcm43xx

5. Google for dv6253cl, follow the HP link to download wireless driver. Run sp36684.exe to expand the installtion file on a Windows machine. By default, the expanded files are in C:\SWSetup\SP36684A

6. Grad bcmwl5.inf and BCMWL564.SYS and transfer them to your Linux. Make sure they are in the same directory. If you have 32-bit Linux, get bcmwl5.sys instead

7. Run the following:

# ndiswrapper -i /path/to/bcmwl5.inf

8. Verify the installation:
localhost haidong # ndiswrapper -l
bcmwl5 : driver installed
device (14E4:4311) present (alternate driver: bcm43xx)

9. Run this and the indicator turned blue:

# modprobe ndiswrapper

10. Set the WEP key:

# iwconfig wlan0 key restricted 123456789A

11. Set the SSID:

# iwconfig wlan0 essid MySsidName

12. Bring up the interface:

# dhclient wlan0

Update: This morning I installed Sabayon Professional 1.1. I got wireless working again, but the strange thing is that the indicator is orange.

The wireless scanning function is absolutely necessary. Anybody out there knows which program works to scan available wireless networks?

Comments

Migrating from one RDBMS to another

Here is some of my thoughts on migrating MySQL to Sql Server. It came out of an email discussion. I’d love to hear your thoughts on migrating to a different database platform, not just MySQL to Sql Server.

I actually thought about writing a white paper or even a course on migrating from MySQL to Sql Server, but never got the time to do it. Sometimes a project doing similar things can serve as a launchpad for this endeavour, but that never came along, at least not yet. I am very interested in database interoperability field though. I’ve done MySQL and Oracle admin in the past and have published some MySQL and Oracle stuff in blogs. I have much better technical skills on Sql Server than any other RDBMS platforms, primarily because I’ve worked on it longer.

Here are some of my thoughts. I think most of it applies equally on migration from Oracle, DB2, Sybase, Postgresql, etc., to Sql Server, or the other way around. It might be slightly easier to migrate from Sybase to Sql Server, considering their common root.

1. It is not easy to migrate existing app, unless the app is a simple one. Even for that, there are enough quirks that can throw people off and cause enough frustration to derail the whole projects. I’ve seen that happening twice, having engaged in moving 2 apps from Sql Server to Oracle;

2. Therefore, the best way to migrating to a new database RDBMS, in my opinion, is to start from a new initiative, probably not big initially. When you start things from a clean slate, you don’t have the historical garbage to worry about. Furthermore, you will give the team enough time to learn the new platform, and prepare the team for future migration, if you choose to do so;

3. Having open-minded team members is crucial to a migration project’s success. Too often people have emotional attachments to the platform they are familiar with, possibly out of job security concerns and lack of general curiosity toward new things.

I generally adopt a platform agnostic attitude, and don’t get religious and too carried away on the platform I work on. Having said that, I think these are points that marketing people can spin for persuasion purposes:

1. MySQL has too many storage platforms: MyISAM, InnoDB, MaxDb, and the newly introduced Maria. This can be viewed as a plus, as it provides choice. The downside of it is that it causes confusion for end users;

2. MySQL’s support for relational model is fairly recent. For example, for a long time, MySQL didn’t support Stored Procedures, Views, Triggers, Foreign Keys, etc. One could argue that MySQL is not mature in this area since it is new for them, but I think it is difficult to find evidence to substantiate that claim. Also, running the risk of offending some people, I think the importance of relational model got overblown a bit;

3. Sql Server offers the CLR integration. This can be a great selling point;

4. Sql Server offers tight integration with Visual Studio, Windows network, and all other things Microsoft. This is a huge advantage.

5. Too many people find *nix environment intimidating. Although MySQL works on Windows, but the perception in the marketplace is MySQL works better on *nix.

As far as migrating MySQL to Sql Server in a hosting web environment, my honest opinion is Sql Server will be fighting an uphill battle, because MySQL excels in this arena, especially for small and medium-sized, or departmental organizations, with the proliferation of such LAMP app like blogs, wikies, discussion boards, etc. I believe Microsoft’s weapon of choice in this arena should be SharePoint. Given Microsoft’s clout, it is certainly a battle worth fighting.

Comments (5)

Logo programming fun

My son had the idea, and I just implemented it in Logo. It’s been really fun. We learned typing, math, geometry, and all that together without even knowing it. We did it on Ubuntu with KTurtle. By the way, it looks KTurtle’s Logo implementation is not consistent with documentations found in other sites. The next version of KTurtle may fix that.

The idea he came up with was to divide a canvas into 3 equal parts and paint them in different colors: white, black, and red. Below is what I came up with. I drew my implementation on a piece of paper and explained what I was going to do. It’s actually not as easy as we first thought. The things we learned: difference between GO versus FORWARD or BACKWARD, TURN commands and the fact that GO does not change the turtle’s direction (in other words, the direction is maintained unless you change it). In fact, DIRECTION is actually a better keyword for me to use here for this purpose, I should remember to tell him tomorrow morning. I should also introduce variables later, at least to define the canvas size.

We will do a Swedish flag together, then Chinese flag, followed by American flag, probably in the order of difficulty. This site was pretty helpful in figuring out different colors and their corresponding RGB codes.

This is what we got:

KTurtle

# Begin LOGO code

reset
canvassize 300, 300
canvascolor 255, 0, 0
penwidth 100
pencolor 255, 250, 250
go 0, 50
turnright 90
forward 300
go 0, 150
pencolor 0, 0, 0

# turnright 90
forward 300
pencolor 255, 0, 0
go 0, 250

# turnright 90
forward 300
center

# End LOGO code

Comments (1)

VMWare Converter and VMWare Server fun

I am playing with VMWare Converter and VMWare Server. Both are available for free. You do need to register to get the download link and serial numbers. Fake name, address, and email will do.

VMWare Converter is pretty neat. It can suck the gut out of a physical machine, while it is running, and create a virtual machine based on it. I’ve done that and was reasonably pleased with the result. You can also supply it with a virtual machine generated using Microsoft Virtual PC (7 and higher) or Microsoft Virtual Server, and it will convert that into a VMWare virtual machine, although I didn’t try that myself. I may do that in the future.

Note, Converter can only convert Windows boxes, no Linux, no BSD, and such, as far as I can tell.

Here is a note for myself and whoever finds it useful.

1. Downloaded Converter;
2. Upon install, Converter told me that I could use VMWare Converter boot CD, if I want to convert the machine I was installing Converter on, to a virtual machine. Some reading gave me the impression that the image converted using the Converter boot CD only works under VMWare Server Enterprise, so I didn’t take that route. I could be wrong on it though. Plus, VMWare didn’t make it very easy to get the Converter CD;
3. Installation was easy enough. When it was done, I fired it up, and clicked Import Machine button. I then picked the local machine as the source machine. The program then asked for destination, I picked a folder on the local machine. I said yes to the question below.

—————————
VMware Converter Import Wizard
—————————
The selected destination is the same as the source machine. Are you sure you want to clone the machine onto itself?
—————————
Yes No
—————————
4. Somewhere along the way, I was asked if I want to give the virtual machine a name and supply sysprep files. I intended to run this virtual machine on the host on which it was based, so I gave it a different name. I think it also asked for organization name and such. Anything will do here;
5. Locating the deploy.cab files for sysprep created a little hassle. The converter wizard provided some hint via a message box, telling me to search for “sysprep Windows XP SP2″ and the like in Microsoft’s site. In my case, I searched for “sysprep Windows 2003 Enterprise R2 SP2″, which led me to this site. I downloaded and installed it, but it didn’t seem to do anything, and didn’t provide deploy.cab that I needed;
6. After checking around for a while, I decided to download the SP2 ISO image from Microsoft, and used 7zip to get deploy.cab out of the image. I then expanded deploy.cab into a folder;
7. Clicking through the wizard, it proposed 3 NIC cards for the machine. I took that, and they were all bridged Ethernet cards. Finally it started importing. On my machine of Windows 2003 Server Enterprise R2 SP2 with Sql Server 2005 and Visual Studio 2005 installed, the process took 29 minutes;
8. Afterwards, I clicked the Configure Machine button. It seemed that this process gave the virtual machine its name, and somehow hooked up with sysprep files, or not. It took less than 30 seconds to finish;
9. Downloaded and installed VMWare Server. Part of it was the web management interface, or something like that. It needs IIS, the host didn’t have it and I didn’t intend to install it, at least for now. So I skipped that component;
10. Double clicked the vmx file to open it. Click the Run button to run the machine. The virtual machine booted up, but then rebooted, at this stage I saw the sysprep thing running. A few reboots later, it became stable and was functional. It was a bit sluggish, especially inside the virtual machine, but it worked;
11. I then downloaded a LAMP virtual appliance from here. It is light, and it runs pretty well. To use the words of International Man of Mystery: Groovy, baby!

Comments (3)

MySQL replication notes 2:replicating only certain databases

Here is my notes on setting up replication on MySQL. In a lot of cases, that is not good enough, because it replicates EVERYTHING from the master to slave(s), whereas you may just want one or two databases replicated.

At first I thought I could just add this to /etc/my.cnf on the slave:
[mysqld]
replicate-do-db=MyDb

That didn’t work very well for statements like this, assuming you are in a database other than MyDb:

insert into MyDb.TableInMyDb values (SomeValue)

Fine, I thought, let me add this to slave’s my.cnf:

replicate-wild-do-table=MyDb.%

It’s not enough. For the Sql statement above, it still couldn’t catch and execute that statement.

After some searching and testing, I found what I was looking for. As far as I can tell, it works beautifully. All you need to do is to modify my.cnf on slave. Just add the databases to ignore in the list. Below is a sample:

replicate-ignore-db = mysql
replicate-ignore-db = test
replicate-ignore-db = testdb
replicate-wild-do-table=MyDb.%

Comments

MySQL replication notes 1: replicating all databases

A couple of weeks ago, a friend asked about replication on MySQL 4.1.7. I’ve worked with replication in the past, just a quick and dirty job on MySQL 5, and soon forgot about it. This time, I wanted to do it on MySQL 4, and make sure I take good notes for my own benefit. If it can help somebody else, all the better. The official documentation is here. It took a little time to wade through it.

The process below is used to replicate all databases on the master to the slave(s). I will talk about replicating only certain selected databases in a future post.

1. At the master server, check if binary logging is on. Use show variables like ‘%bin%’ to check if binary logging is on or not. If it is not on, turn it on by adding log-bin under [mysqld] section in /etc/my.cnf. Also remember to add server-id=Number, where the number is a unique number for all MySQL servers within the network. It looks something like this:

[mysqld]
log-bin=mysql-bin
server-id=1

If mysql restart is needed, do:
shell> mysqladmin -u root shutdown
shell> mysqld_safe &

2. Set up an account on the master server that the slave server can use to connect. This account must be given the REPLICATION SLAVE privilege. If the account is used only for replication (which is recommended), you don’t need to grant any additional privileges.

mysql> GRANT REPLICATION SLAVE ON *.*
-> TO ‘repl’@'%’ IDENTIFIED BY ’slavepass’;

3. Issue ‘flush tables with read lock’. While the read lock placed by FLUSH TABLES WITH READ LOCK is in effect, read the value of the current binary log name and position on the master. Take note of those 2 values, ’cause they will be used later:

mysql > SHOW MASTER STATUS;
+—————+———-+————–+——————+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+—————+———-+————–+——————+
| mysql-bin.003 | 73 | test | manual,mysql |
+—————+———-+————–+——————+

4. I used mysqldump, documented here, to dump out the database I am interested in. Then do ;

mysql> UNLOCK TABLES;

5. Stop the slave server, add the following lines to its my.cnf file:

[mysqld]
server-id=slave_id

The slave_id value, like the master_id value, must be a positive integer value from 1 to 232 – 1. In addition, it is necessary that the ID of the slave be different from the ID of the master. For example:

[mysqld]
server-id=2

When setting up multiple slaves, each one must have a unique server-id value that differs from that of the master and from each of the other slaves. Think of server-id values as something similar to IP addresses: These IDs uniquely identify each server instance in the community of replication partners.

Now start MySQL on the slave;

6. Create the database with the same name of the database where the dump was taken,

shell> mysql -u root -p -D MyDbNameHere < dump_file.sql

7. Execute the following statement on the slave, replacing the option values with the actual values relevant to your system:

mysql> CHANGE MASTER TO
-> MASTER_HOST=’master_host_name’,
-> MASTER_USER=’replication_user_name’,
-> MASTER_PASSWORD=’replication_password’,
-> MASTER_LOG_FILE=’recorded_log_file_name’,
-> MASTER_LOG_POS=recorded_log_position;

8. Start the slave threads:

mysql> START SLAVE;

It should work. One thing that got me during my process was that I had firewall enabled on both the master and slave, therefore I had to open those ports up for MySQL communications. From this point on, EVERYTHING will be replicated. Notes on replicating only selected databases to follow…

Comments (2)

Oracle 10g Express Install Part 2

After my last failed Oracle 10g Express install due to insufficient memory, I purchased some memory from eBay, and started it over.

This time, the first thing the installer noticed was that the swap file is not big enough. I fixed that by doing a total re-install of Fedora Core 2. Yeah, I know that was kind of lame, but I got a few machines with me, so I didn’t waste time waiting for it.

Started again, this time the install went through, but I got some error messages at the end. The message was “groupadd: unable to lock group file”. The problem was that there were passwd.lock and gshadow.lock files under /etc. I then removed those files.

I tried to reinstall the RPM package. The message I got back was that it was already setup. I then ran:

rpm -e oracle-xe-10.2.0.1-1.0.i386.rpm

to remove it.

Finally, I was able to install it correctly.

It was a good exercise. I’ve done some Oracle database administration stuff, but never installation and setup stuff. I would like to bring my Oracle skill to the next level, so this is a good way to get started. 11g will come out within a week or so, but hopefully the skills I learned here can be transferred. I will give 11g a run when it comes out.

A few things learned:

1. yum is worth looking into. It is probably a better way to install or update dependencies than compiling binary or doing manual rpm install;
2. Got to be careful when typing. During profile setup, when I tried to put . /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh into /etc/profile, I missed the blank between the dot and forward slash. This shell script sets up $ORACLE_HOME and $ORACLE_SID for you;
3. Here is a good site for 10g Express setup on Linux.

Comments

« Previous entries