2008-12-24

SQLyog on Ubuntu

SQLyog is a popular MySQL GUI client that can be very convenient for certain operations like quickly dumping a database, schema changes. For operations that are awkward via the command line, it is useful.

I've installed SQLyog on my Ubuntu (Hardy Heron) laptop. It was very easy using Wine.

To install SQLyog with Wine

Install Wine on your Ubuntu system using the Synaptic Package Manager. As of this writing, version 1.0.0.1 was current. the exact version of Wine is probably not important.

Download SQLyog from here. I use the community edition. It is not important where you download the installation (Windows EXE) to. Just save the program file someplace convenient that you can easily navigate to via bash in the Terminal.

Open a Terminal window and change to the directory where you stored the EXE installation file. Type:

wine SQLyog714.exe

This is the exact filename that I downloaded. You will probably need to change it to the filename you downloaded.

Follow through the installation process using the standard SQLyog installer. Accept defaults. The program will be installed under a directory in your home directory called .wine.

At the end of the installation, the dialog will allow you to run the program. Go ahead and run it for the thrill of seeing a Windows program run on Linux. Wine is great!

Create a shortcut to run SQLyog in Terminal

I like to run SQLyog from the command line. I could change to the program's directory and start the program with wine SQLyog.exe. Like this:

cd ~/.wine/drive_c/Program\ Files/SQLyog\ Community wine SQLyog.exe

For convenience, I created a script to start SQLyog just by typing sqlyog. I created a text file called sqlyog with the above two lines and made it executable with chmod +x sqlyog. I have a directory in my $PATH for scripts like this, so I can fire SQLyog from anywhere.

Adding SQLyog to the Ubuntu Applications menu

On my installation of SQLyog, an entry was not made in the Applications menu to launch SQLyog. I added it to Applications | Wine by right-clicking on Applications and selecting Edit Menus. I added a new menu item with the New Menu button. The command to run SQLyog is:

env WINEPREFIX="/home/andrew/.wine" wine "C:\Program Files\SQLyog Community\SQLyog.exe"

2008-12-23

Virtual Web Server Sandboxes on Ubuntu

Problem: Multiple virtual web sites are needed on an Ubuntu machine.

Solution: Set-up virtual servers in Apache and modify the /etc/hosts file so URLs of your choosing will resolve to the virtual sites that you create.

This procedure was tested using Ubuntu Hardy Heron.

For Apache's documentation about name based virtual hosting, see:

http://httpd.apache.org/docs/1.3/vhosts/name-based.html

Step One: Modify the hosts File

The /etc/hosts text file is owned by root and allows a simple means to resolve a URL that your type into your web browser to an IP number. In this case we want our example URL of my.example.com to resolve to the IP address of the local machine, just like localhost. This is normally 127.0.0.1. Edit the /etc/hosts file with:

sudo vi /etc/hosts

Find the line that reads:

127.0.0.1 localhost

On the same line, after localhost, add a space and the name of your virtual site:

127.0.0.1 localhost my.example.com

That's it for the hosts file. You do not need to restart anything.

Step Two: Set-up a Virtual Website on Apache

Apache has the handy ability to discern the URL from a browser's address line and serve up the site that has been configured for it. This allows a server with a single IP address (like our 127.0.0.1) to host several sites at once.

For each virtual web site on the server, create a text file in the /etc/apache2/sites-available directory. Use the following template to create the file (called my.example.com in this example):


<VirtualHost *:80>

ServerAdmin username@localhost
ServerName my.example.com
DocumentRoot /home/username/public_html/my.example.com
CustomLog /var/log/apache2/my.example.com.log combined

</VirtualHost>

You will need to create this file as root, so:

sudo vi /etc/apache2/sites-available/my.example.com

Now, you can use a Debian (Ubunto is a Debian variant) utility to easily create a link to this configuration file:

sudo a2ensite my.example.com

The above line simply creates a link to the my.example.com file in the /etc/apache2/sites-available directory. This allows you to enable and disable sites easily. The Debian disable counterpart to a2ensite is a2dissite (which just deletes the link).

Lastly, reload Apache:

sudo /etc/init.d/apache2 reload

After ensuring that you have something to sever in the site's document directory, enter the URL you used in your browser's address field and try it out!

2008-04-22

Reading a File on the Internet with vi

Enter the fully qualified name of the file that you want to open in the current buffer, for example:

http://andrewault.blogspot.com/ Place the cursor over the name somewhere. In Normal Mode (not Insert Mode) type: gf

vi will use the appropriate unix utility (in this case, wget) to download the file and then read it into a new buffer.

2008-04-21

New Blog Design

I grew tired of my blog's previous design. It was a little too green, plain and sort of depressing. I've given it a bit of a makeover. I hope people this is attractive.

vi Cheatsheet Work in Progress


I've been working on a vi cheatsheet. This is still a work in progress. When it is done I want to make some coffee mugs wrapped with this graphic. Any comments or e-mail messages with suggestions are welcome.


New Google Gadget

This is a new Google Gadget I developed for The Curious Dreamer. It is available here.

2008-04-20

Healthcare Systems Compared

I love America! I am American through and through. Do I think the US is perfect? No,it is not. It is important to change and adapt as human capabilities increase and with the global marketplace. As a country we have pursued global competition the best available path for the well being of the United States and her citizens. For all these reasons, we must study the very best systems and product in the world and improve upon the best and adapt it s our own. The US spends over 15 percent of GDP on healthcare, but does not cover every citizen in a systematic and rational fashion. The US is ranked 35th (!) in quality of care and coverage by the World Health Organization. The US is ranked 37th in infant mortality in the world. Can we improve our healthcare? Frontline (on PBS), this week has an excellent comparison of five top ranked healthcare systems from around the world in relation to the US. The show, Sick Around the World, is very well done and interesting. In particular, Switzerland is an interesting case, as it is one of the countries covered that is privately based. It may be beneficial for us to dispassionately study the world marketplace and to adjust to new realities. Can GM compete with competitors that pay much less for healthcare? It is unfortunate that this is a political hot button, because it may very well be that we could improve overall health in the US at a lower cost.