Saturday, May 31, 2008

Replacing deprecated HTML tags

HTML has changed since I learned it. For example, <style> tags weren't useful, and CSS was just starting out.

Ew, I'm old.

So I used to write an image tag as <img src="General_Lew_Wallace.jpg" width="108" height="144" align="left" border="1">.

But, an alt text is now required, and the border has been deprecated. So after some poking around with CSS, I came up with:

<img src="General_Lew_Wallace.jpg" alt="General Lew Wallace of the U.S. Civil War. I don't look like him." width="108" height="144" align="left" style="border-style: ridge; margin-right: 10px">

It does look better. Thanks to the tutorials at www.w3schools.com

Friday, May 30, 2008

Using Bash aliases to simplify the universe

I update this blog using the curl command to upload to the web server (see my entry back on March 8, 2008, "The Joy of cURL").

The command, curl -v -T TechBlog.html -u website:password ftp://ftp.freeservers.com/me/ lives in my Bash history; each time I want to upload, I simply up-arrow through the history at the command prompt until the list time appears, and then hit -enter-. Presto! Terribly easy.

But sometimes I've done a lot of command line work in the meantime (for example, python programming), so I up-arrow seventy or ninety times before the old curl command reappears.

I'm much too lazy to do that regularly.

So I created an alias in my .bashrc file: alias blog='curl -v -T TechBlog.html -u website:password ftp://ftp.freeservers.com/me/'. Now I can simply type blog instead of looking for the old curl command.

Wednesday, May 28, 2008

Adding python event notifications to the Desktop

Figured out how to get a Python script pop up a notification bubble on the desktop:

It uses the pynotify frontend to libnotify. It's not part of the python 2.5 base, but is included with the Ubuntu default install. Here's a test script for my Ubuntu system. It pops up a little bubble from the system tray

import pygtk
import pynotify

pynotify.init( "Some Application or Title" )
n = pynotify.Notification("Title", "body", "dialog-warning")
n.set_urgency(pynotify.URGENCY_NORMAL)
n.show()

Tip: The .init() call is neccessary, or you'll get a lot of ugly DBUS and GTK errors.

Changing Stuff: Simply replace the elements("Title", "body", "dialog-warning") with your desired title, body, and image path. The image display will take .jpg, .png, .svg, and likely others. For example...


n = pynotify.Notification("Milwaukee Without A Car", "The Python script MWC_Webcrawler has completed a scheduled run. The logfile has been added to your desktop", "/usr/share/icons/Rodent/48x48/apps/gnome-info.png")

Monday, May 19, 2008

Adding RSS Icon to the browser URL bar

Found out how to add an RSS icon to the URL bar:
Add the following to the <head> section of the page: <link rel="alternate" type="application/rss+xml" title="Your News Feed" href="http://somewhere.com/news.xml">

Thursday, May 15, 2008

Xubuntu 8.04 sessions

Had terrible problems with applications autostarting at login that I didn't want. I looked everywhere in /etc and /home/me/.config, but OpenOffice and Thunar just kept appearing.

Then I figured it out. One lousy time I checked the Save session for future logins option on logout. So it restarted that way every time.

So the fix was to shut down all applications, logout (saving the session), log back in. Voila! All fixed.