Database Schema Searching Utility

This is a php script that I wrote a number of years ago. It allows you to search through schema of MySQL databases by table column name. It can connect to multiple servers and it will search the structure of every table in every database.

It is a great tool to find related columns in a complex server situation. You can get the source code here, feel free to download and use it.

I found this in an old email that I sent to myself. I wrote this utility at my first job out of college. They had a software system that had been through a number of reincarnations over the years and they were left with redundant data across numerous servers and databases. I used this script to locate related fields across systems and would then write translation code that would merge data into a consolidated system.

Tools to Check if Your Server is Spamming

This is just a couple of good tools to find out if your server is allowing spammers to route mail through it. The nice thing about these tools is that you don’t have to know how a mail server works to test.

This first one will search a large number of major blacklists to see if your server is listed. Being blacklisted means that a number of sources have identified your server as a source of spam email. If you find yourself on one of these lists, it could be a good indication that your server is sending out spam.

http://www.mxtoolbox.com/blacklists.aspx

You can find out why you are blacklisted by a particular list by checking out their website (which is linked to in the report). Then you can repeal the listing to get your server taken off of the list. If you are listed you should definitely try to get your server off of the list, because being listed could severely reduce the delivery chances of legitimate email generated by your server.

The second tool analyzes your server by trying to connect to it in the same way a spammer would. If it does find an opening, you can have it actually try to send a message through your server, just like a spammer would (this requires you to register to the site). This is a surefire way to know if your server is capable of being abused for spamming. Because if you get the test message in your inbox, that means spammers can do the same thing.

http://www.abuse.net/relay.html

Connecting to an MSSQL Server (and others) with OpenOffice.org

I have wanted to try out OpenOffice.org Base for some time now, but I have never taken the time to figure out how to make it connect to a relational database system. And as it turns out there doesn’t seem to be all that much documentation to help. Anyway I needed to figure out a way to look over the structure of a Microsoft SQL database and I didn’t have access to a Windows machine, let alone Enterprise Manager.

So OpenOffice.org uses JDBC to connect to various databases, but sadly it does not come bundled with any of the libraries required to connect and communicate. So after researching a little I came across jTDS. And with a little messing around I got it to work. Below is what I did.

  • First you have to download jTDS at http://sourceforge.net/project/showfiles.php?group_id=33291.
  • Second, uncompress the file and store it somewhere out of the way on your computer (such that you don’t accidentally move or delete it). You can store the whole folder or just the jtds-x.x.x.jar file.
  • Third, open up OpenOffice.org and go to Tools, Options…, OpenOffice.org (or NeoOffice), Java and then click on Class Path… and then Add Archive…. Choose the jtds-x.x.x.jar file and hit Open. Then keep hitting Ok until all preference windows are closed.
  • Fourth, you need to close and reopen OpenOffice.org for the change to take effect.

  • Fifth, open up Base and when the wizard comes up choose Connect to an existing database, choose JDBC from the dropdown and then hit Next.
  • Sixth, the Datasource URL is of the form below.

    jtds:sqlserver://[host]:[port]/[database]

    Replace [host] with the hostname of the server, replace [port] with the port that the database connects over (the default is usually 1433) and replace [database] with the name of the database.

  • Seventh, for the JDBC driver class put in the below.

    net.sourceforge.jtds.jdbc.Driver

    You can hit Test class if you want to. It should give you a promising message. After all of the fields are filled out hit Next.

  • Eight, on this screen you can fill out the authentication information. This should be pretty straight forward and you can test it to see that it is connecting properly. And then on the last screen you can set some final options and then save the local connected copy somewhere.

After that you should be able to see and browse the tables, build queries and have fun.

- - - - -

You can also use this jTDS driver to connect to Sybase. All you have to change the Datasource URL to this form.

jtds:sybase://[host]:[port]/[database]

- - - - -

For connecting to MySQL you can follow these same steps except you need to get the MySQL JDBC driver class from the MySQL website (http://www.mysql.com/products/connector/j).

The Datasource URL is:

mysql://[host]:[port]/[database]

And the JDBC driver class is:

com.mysql.jdbc.Driver

Hidden Fun Inside Popular Software

A fun feature from Lifehacker highlighting some great hidden goodies in popular software. My favorite is the therapist inside of Emacs (open emacs, hit escape and then type ‘xdoctor’ and hit enter).

http://lifehacker.com/371083/top-10-software-easter-eggs

Using rsync to Backup a Home Folder

I have been trying to get more serious about my personal backups lately and I have finally started to figure out a scheme. I have a primary machine that is setup as a RAID 1 with two drives such that it keeps two copies of every file. And then every once in a while I copy the home directory with all of my files from that computer to an external drive.

It takes forever to transfer my home directory full of files over to the drive, so I decide to try and use rsync to synchronize the drives by only copying, moving and deleting the files that have changed.

For those of you who have never heard of rsync, it is an Open Source utility that can be used to copy files from one place to the other while minimizing the amount of transferring by detecting differences between the source and destination and only transferring the differences. So if you are trying to archive or backup a lot of files this can save a lot of time.

rsync is a pretty advanced tool and it took me a while to get the command correct, so I thought I would share it here in hopes that it might save someone else some time.

# rsync -rptDuv -e ssh user@127.0.0.1:/home/user/* /media/backup

Let me explain this in detail. First you have the command itself.

# rsync ...

Then you have the options.

# ... -rptDuv ...

The ‘r’ is for recursive, which means that it will go into folders and copy those files as well. The ‘p’ keeps the file permissions in tact. The ‘t’ is for time, which means that the copied files will keep the same created and modified times as the original. The ‘D’ is to account for special files, I am not sure that this was needed for my purposes. The ‘u’ is for update, which means it is not to copy files that already exist on the destination. The ‘v’ is for verbose, which just means that it will tell you what it is doing as it does it.

The next part is the source folder (i.e. the files you want to backup). Since my source folder was actually on another computer I had to specify some extra stuff to connect to it.

# ... -e ssh user@127.0.0.1:/home/user/* ...

If you were just backing up a folder on the same computer you could just do something like this instead.

# ... /home/user/* ...

One thing to note about the source is that I had to specify the ‘*’ at the end to prevent it from trying to backup hidden files as well. Since most of these files were just random configuration files for the user, I didn’t feel I needed to back them up.

Last is the destination (i.e. where you are keeping your backups). I am transferring mine to an external hard drive so I can take it to another location.

# ... /media/backup

The first time you run the command it will transfer the whole set of folders and files to the backup drive. But after that it will only update the backup drive with the changes you have made.

Thanks to Chad from the Linux Basement for helping me work through this command over IRC.

Relaying Mail to a SMTP Server That Requires Authentication (Ubuntu/Postfix)

I have been playing around with setting up a home server and one thing I learned is that my current ISP does not allow an SMTP server to send out mail. This meant that any of the random web applications or server software I installed was unable to to generate and send an email that would actually be received to an email account in the outside world.

I imagine that my ISP does this to cut down on the amount of SPAM that is generated from their network (through virus infected computers and such). Thankfully my ISP also offered a SMTP server that I could forward mail through, however it requires authentication.

I am using an Ubuntu server and it runs Postfix as the default MTA, so I figured I would just use it to forward the mail from my home server, through my ISP’s server and then out to the world.

Here is what I had to do to get it working.

First I opened up the main.cf file for Postfix.

# sudo vim /etc/postfix/main.cf

Add these lines to the file. The ‘relayhost’ line might already be in the file. Set that line equal to the server you intend to relay through. I saw some examples that didn’t include the brackets (’[]’), but mine wouldn’t work without them.

relayhost = [smtp.my.isp.com]

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
smtp_sasl_security_options =

After you save that file, create a directory to store your password files in.

# sudo mkdir /etc/postfix/sasl

Next you need to create your password file.

# sudo vim /etc/postfix/sasl/sasl_passwd

Inside that file you need to add one line that defines the username and password for the smtp server you want to relay through.

smtp.my.isp.com username:password

Once you create the password file, you need to create a hash of it.

# postmap /etc/postfix/sasl/sasl_passwd

This should create a file called sasl_passwd.db in the same directory. At this point you can either change the permissions on the file ’sasl_passwd’ to protect your login information or I think you can just get rid of it.

After that all you have to do is restart the daemon.

# sudo /etc/init.d/postfix restart

Now your server should be able to send mail out the the real world by relaying it through the other server.

This article below helped me greatly in figuring out how this is done.
http://ben.franske.com/blogs/bensbits.php/2005/09/06/postfix_smtp_auth_support_for_relayhost

Temporary Password Generation

I am working on registration for a system where it generates a password and then emails to the person registering. Here is the method I used to come up with short, unique and somewhat complex passwords.

I did it in php, but you can use the algorithm in any language.

<?php

function generate_password() {
    return substr(md5(time() . rand()), rand(0, 24), 8);
}

?>

It takes a random eight character slice of an MD5 of the time plus a pseudo-random integer, which will give you an alphanumeric string. It is a short but complex enough of a password to give someone until they can change it to whatever they want. I thought this was pretty clever, so I wanted to share it here.

Color Scheme Tool

This is a great tool for generating color scheme ideas from a single color. You can generate complements, split-complements, triads, tetrads, analogous and monochromatic colors from your source color. The thing I really love about it is that has a button that will give you a random color to generate a scheme from, this is really useful for brainstorming color ideas.

I used this tool to come up with the colors on this theme (as of the writing) based on the triad colors of the shade of blue. This is one of the many applications that I enjoy that you can’t find anywhere except on Linux.

Project Homepage
http://home.gna.org/colorscheme

Quick Note Taking Application for Mac (Almost as Good as Tomboy for Linux)

One of the greatest Linux applications I have ever used is Tomboy. It is a simple note taking application that sits in your toolbar and provides quick note creation, searching, basic formatting and linking between notes. It is perfect for the kind of note taking I do on the fly while sitting at my computer.

Long have I searched for a worthy equivalent for Mac OSX without much luck. For a time I used WikityWidget on the Dashboard. The only thing I didn’t like about WikityWidget was that you couldn’t resize the window to allow for more note room.

However on random forum the other day a saw a reference to a OSX application called Sidenote. It hangs out on the side of you desktop and allows you to mouseover and quickly create and jot down notes. It does support some formatting and you can save them externally. It also allows you to drag images and files into the note (I have tried images and pdfs). However it trails Tomboy in that there is no searching or linking between notes.

Overall I really like Sidenote and have been using it like crazy over the past few days. It will definitely be added to my Mac application toolbox. I want to thank Pierre Chantel for taking the time write and then give away such an excellent application.

Sidenote

My Favorite Open Source Projects

One of the things I love the most about Open Source and the Internet in general is that there is always new and amazing stuff to discover. I recently discovered two new software projects that, I think are really awesome.

In the spirit of this I decided to take a moment to put together a list of my (current) five favorite Open Source projects. These are not listed in any order of importance.

DokuWiki

This is a great wiki software package that you can just drop into a web folder and start using. I like because it is so easy to get up and running without dealing with complicated configuration.

http://www.splitbrain.org/projects/dokuwiki

Gparted

This is the best disk partitioning utility I have found. You can just download an ISO and burn it to a CD and then boot from that and manage all kinds of disk maintenance tasks. It has a nice graphical interface and runs completely independent of operating system software (outside of the fact that it is booting a simplified Linux system straight from the CD).

http://gparted.sourceforge.net

OpenOffice.org - NeoOffice

This is one of my old favorites and one the most successful open source projects to date. It is a productivity suite much akin to Microsoft Office. It is better in some ways and not quite as good in others, but on the whole is a great alternative.

NeoOffice is the native version for Mac OSX, however OpenOffice.org is working on a native Mac version (which I think will put NeoOffice out of business).

http://www.openoffice.org
http://www.neooffice.org

Tango Desktop Project

This is a project put sponsored freedesktop.org. It is a project that is trying to take the different distributions of Linux and the different window managers on Linux and get them to use a standard set of look and feel icons so that a person can move between versions of Linux and still get a familiar user experience.

I think this is a very important thing when comes to wider Linux adoption by users. The other part to this is that these icons can be adopted throughout the world and not just on Linux, bringing the whole tech sphere closer together from a user perspective.

http://tango.freedesktop.org

Ubuntu

This is one of my favorite distributions of Linux. It is very well constructed and organized from a geek perspective, but also it seems to install and work very easily for the Linux newbie (on most computers). Although, I have to contribute its geek appeal to the fact that it is Debian based. My user experience with it has just been great; better than I have ever had with any other Linux distributions.

It is also a very progressive and successful in bringing Linux acceptance to a higher level. One of the biggest things it has achieved recently is that it has been picked up by Dell and offered as a cheaper alternative to Windows Vista in the new computers they sell.

http://www.ubuntu.com

...older
{
}