Archive for the 'software' Category

Displaying an HTML table from MySQL data

Wednesday, July 23rd, 2008

Here’s one from the 2003 archives:

Did you know that PHP could interface with a MySQL database? Well it can, and here’s how! The code below illustrates just how easy it is to produce a nice table with headers populated with data culled from a database. One little trick I like to use (and have used for a very long time) when displaying table data is to alternate the background color. This makes it a bit easier to read the data (at least it does for me) Notice that when the table is initialized (<table><tr bgcolor=\”#afafaf\”>), I define the background color. Later as the code iterates through the lines of data, I test to see what the current backgound color is, and then reverse it. Not rocket science, but it spruces things up just a bit. I have been using a heavily modified version of this code in several places, whether it is for displaying log files or pulling intrusion reports from a Snort database and it has worked quite well. Any comments or improvements are always welcome!

<?php
$link = mysql_connect("database_host", "user", "password");

mysql_select_db("database_name", $link);

$qry = mysql_query("SELECT * FROM table_name", $link);
echo <table><tr bgcolor=\"#afafaf\">;
if (mysql_num_rows($qry) > 0) {

for ($i = 0; $i<mysql_num_fields($qry); $i++) {

echo "<td><b>" . mysql_field_name($qry, $i) . "</b></td>";

}

}else{

echo "<td>No entries found in the database</td>";

}
echo "</tr>\n";
if (mysql_num_rows($qry) > 0) {

for ($j = 0; $j<mysql_num_rows($qry); $j++) {

if ($bgcolor == "#ffffff"){

$bgcolor="#cccccc";

}else{

$bgcolor="#ffffff";

}

echo "<tr bgcolor=\"$bgcolor\">";

for ($k = 0; $k<mysql_num_fields($qry); $k++) {

echo "<td>" . mysql_result($qry,$j, $k) . "</td>";

}

echo "</tr>\n";

}

echo "</table>";

}
?>

Gmail IMAP missing

Wednesday, April 16th, 2008

UPDATE:  Looks like it’s been re-enabled.  Hopefully for good.  Maybe they were upgrading the service.

Looks like Google may be having some issues w/their IMAP services.  I noticed earlier that my palm pilot couldn’t access my gmail account via IMAP, producing a connection error.  When I log into my gmail settings, the IMAP section from the ‘Forwarding and Pop’ tab is now missing:

No IMAP settings in gmail


# emerge osx-epic-fail

Thursday, April 3rd, 2008

Gentoo Prefix Bootstrap Process for Mac OS X has a lengthy walkthrough on getting Gentoo’s emerge package management system installed onto a Mac OSX system.  Naturally I had to give it a shot!  I’ve never worked with Gentoo before so I really had no idea what to expect from emerge.

From a few conversations with a collegue I learned that I could very easily tailor the build process to my specific environment by customizing the make.conf file for emerge.  Unlike some package management systems that either grab a generic binary for your platform, emerge will pull down the latest source code and compile it directly for your specific machine.  If I recall correctly, the FreeBSD ports collection also works this way, as does Debian’s apt (although I’m not sure of the ability to modify machine-specific compile time flags with either system)

The install detailed in the walkthrough (see link above) is a bit sparse on background information such as why call emerge with the oneshot option. (still not sure about that myself, from the emerge man page: “Emerge as normal, but do not add the packages to the world profile for later updating”)  Each of the build steps took a rather long time on the aging Mac G4 box and I unfortunately kept running into compile errors about 3/4ths of the way through the process.  The process failed trying to compile Autom4te (an M4 replacement for autoconf) due to various reasons (one of which might be a missing perl library)

After stepping through the various stages of the install a couple of times and only getting marginal success, I decided the easiest route would be to script the install process so that I could re-run it at my leisure.  I just grabbed the commands listed in the walkthrough and stuck them in a shell script (no error-checking or anything fancy) which would allow me to set a couple of variables and then re-run the script as often as needed.   The script (and the author’s walkthrough) relies on another script called ‘bootstrap-prefix.sh’ (also available from the walkthrough site) so I created a directory called ‘emerge’ and therein placed both the ‘bootstrap-prefix.sh’ script and my own ’setup_gentoo_bootstrap_env.sh’ script.

I set my ‘EPREFIX’ variable to /usr/local/gentoo, so everytime the process would fail, I could just ‘rm -rf /usr/local/gentoo’ and start over.   Since part of the process includes pulling down all the latest sources I figured that if I just waited a week, maybe someone would have found the issue and fixed it.  But alas, as of this morning the process still fails in the same spot.  So I’ll send a note to the maintainer and see what happens.  Until that time I have to conclude that emerge on OSX constitutes the ‘epic-fail’ tag.

After all of this, I finally just grabbed the latest macports and within minutes I installed several standard software packages.  Both macports and fink provide very easy access for OSX to most readily available linux software.  However it does appear at the moment that macports has been getting more attention and is more supported (at least by comparing the verbage on each of their websites) and even though I’ve been a big fan of fink in the past, I went with macports if for no better reason other than its the one that I haven’t utilized before.

Code for setup_gentoo_bootstrap_env.sh located after the cut.

(more…)

Updated to Wordpress 2.5

Thursday, April 3rd, 2008

Well I didn’t exactly update the site per se.  I moved Intuition & Elbow Grease to a new server and in the process upgraded to the latest version of Wordpress.   I created a new database and installed the code fresh (i.e. I performed a ‘new’ install) and then restored my posts from an exported xml file from the old site.  The theme and plugins I simply tarred up from the contents of a  full backup I made from the old site and then uploaded to the new server.  So far the only code I’ve needed to regenerate was the adsense code that I use.  If you notice any weirdness with the site, please let me know!

10 Free Computer Products I Use Everyday

Wednesday, May 3rd, 2006

From Frugal for Life

1. Linux. Specifically Ubuntu. Hands down its the best distro for the desktop. (and it’s Debian-based, w00t!)

2. OpenOffice Free word processor, speadsheet, etc. Excellent compatability with Microsoft Office with the added benefit of additional features (like saving documents as a pdf directly)

3. Firefox. Web browsing done right.

4. Gaim An open source multi-protocol instant messaging client.

5. Thunderbird Email Application.

5. OpenSSH For secure connectivity and file transfers. Don’t connect without it!

6. Nmap Invaluable network recon tool.

7. J-pilot A Palm compatable desktop for linux.

8. XMMS A minimal audio player in the spirit of WinAmp.

9. The Gimp Digital image manipulation ala’ Photoshop.

10. Palm Bible+ A great free bible reader on my Sony Clie’

So, that’s my quick list. What great free software do you use?