Jud Dagnall Photography Blog

Photography, technology and occasional rants!

Using unsharp mask in ImageMagick

Posted on September 19th, 2005 in , , , by jud || No Comment

ImageMagick is an open source, free, cross-platform set of image processing command-line tools. I use IM to process some of my images for presenation on the web. The sharpening functionality (unsharp mask) is not very well documented, and I found a pretty thorough explanation of
how to use unsharp mask in ImageMagick.

Quick Reference Cards for geeks

Posted on September 6th, 2005 in , by jud || No Comment

Mike just sent me a link to some free reference cards for geeks. Subjects include perl, apache, emacs, xml and xpath. I’m using the one for the perl template toolkit, and perl regular expressions.

one-step self-signed SSL certificate

Posted on May 31st, 2005 in , by jud || No Comment

Create self-signed certificates is useful when managing apache and dovecot imap servers. I have always found it to be a pain to create the certificates. Here’s simple instructions for creating one.


In a nutshell,

openssl req -new -newkey rsa:1024 -days 365 -nodes -x509 -keyout www.example.com.pem -out www.example.com.pem

You can then use the file above in apache with the following two lines

SSLEngine On
SSLCertificateFile www.example.com.pem

In my case, I created a separate cert and private key:

openssl req -new -newkey rsa:1024 -days 365 -nodes -x509 -keyout private/www.example.com.pem -out cert/www.example.com.pem

and installed them so that dovecot (and thunderbird) would use them. I added the year in the cert UO field.

Site facelift

Posted on March 14th, 2005 in , by jud || No Comment

Inspired by the new wordpress templates, I’ve given the whole site a facelift. There’s now a relatively uniform look for all of the site, although it is still best when viewed with firefox. Major tweaks to the header and navigation, minor tweaks to the image gallery. CSS makes all of this so much easier. I deleted a few lines of PHP, and add 2 div tags in my html, and everything else was done via CSS. CSS ROCKS!

Fedora Core 3 and MySQL4.1

Posted on February 9th, 2005 in , by jud || No Comment

I wanted to install MySQL4.1 on my laptop runninng Fedora Core 3. Unfortunately, only the 3.23 versions are currently available through Fedora, evidently because of some license issues. However, there are some
good instructions for setting up MySQL4.1 under fedora here.

Everything seemed to work as specified with the following exceptions:

1. I installed the latest (4.1.9) version of MySQL. This hasn’t caused any problems.

2. I couldn’t find the version of MySQL 3.23.58-9 that they mentioned when created the
new MySQL-shared-compat rpm. Instead, I simply copied
the latest version from my yum cache, which was mysql-3.23.58-14.rpm, and modified the “define release3” line so that it was 14 instead of 9. Then the rpmbuild command worked fine. Still haven’t
tested it with php, etc… but I’ll get to that. Here’s the diff of my MySQL-shared-compat.spec file:

- %define release3 9
+ %define release3 14

IPython: Interactive Python

Posted on February 8th, 2005 in , by jud || No Comment

There’s a great article on oreilly.com about IPython, an interactive python shell. Although not suitable as
a full shell replacement, it provides powerful enhancements to the standard interactive interpreter. The
interactive interpreter is one of the most useful features of python when working with small snippets of code, allowing you to try out things easily.

redirecting sudo output

Posted on January 25th, 2005 in , by jud || No Comment

Sometimes I need to use the linux sudo command to run another command as another user, but also write the output of that command as another user. I always forget the proper syntax for this sort of thing, since simple quoting and escaping don’t work. Ryan pointed out a straightforward way to accomplish it.

For example, if I wanted to run a command as *apache* when running as user *me*,

(me@home) $ sudo -u apache command 

However, trying to redirect the output of the command will cause the output to be written as user *me*, not *apache*, causing
an error when writing to a directory or file not writable by *me*.

(me@home) $ sudo -u apache command > /home/apache/out
bash: /home/apache/out: Permission denied

Ryan’s solution is as follows: use sudo to call an shell with the quoted command as a parameter:

(me@home) $ sudo -u apache /bin/bash -c "command > /home/apache/out"

Simple forums with FUDforum and mailman

Posted on January 23rd, 2005 in , , by jud || No Comment

I set up an online forum and mailing list for a class I’m taking. I used FUDforum, which was easy to install and
configure (it’s php). One of the other things I wanted to do was to set up a mailing list that would serve as an alternate entry point for users: mailing list posts would be copied to the forum, and forum posts would be copied to the mailing list. Using mailman and procmail, this was relatively simple. After downloading and installing fudforum, I installed mailman from RPM using the yum package manager. Following the instructions in the docs, I created a mailing list and added some test names.

After setting up the mailing list, I configured FUDForum to post to the mailing list (using the mailing list options), and got it to remove the title of the mailing list when copying to forums. This was slightly tricky, since the regulur expression should be [ListName], not [ListName].

Then I added procmail entry that pipes any list mail into the FUDforum mailinst list script (scripts/maillinglist.php). I had to fiddle with the permissions a bit since the web owner wasn’t receiving the mail, but a set of directories with a special group, and group write/set permissions did the trick. I did have much more trouble with the procmail recipeit since it wasn’t clear when mail should be copied to the forum. Because mailling list mails are sent via BCC, the recipient doesn’t show up in the header all the time (I tried using a special mailing list email address). In the end, I had to for mail with the mailing list name as the recipient, which seems to work most of the time,. However, I just discovered that if someone BCCs the list, the mailing list doesn’t even show up in the To: field.

However, the forum is now up and working, and students can post to the list, or the forum, and everyone sees the messages.

autohotkey – open source macros for windows

Posted on December 14th, 2004 in by jud || No Comment

I just discovered a cool new macro/hotkey packages for Windows called [autohotkey](http://www.autohotkey.com). I’m a big fan of keyboard shortcuts, and in fact this was one of the primary factors for my shift to the text-only email client mutt (under linux/unix). However, I’m happy to find
a nice open source package that will work for my other operating system. autohotkeys includes a scripting language, and can use both keyboard and mouse buttons. Best of all, it can handle simple hotkeys, and/or bind any two-key combination (like right-alt + a) or (F1 + F2).

Smart bookmarks with Firefox keywords

Posted on October 28th, 2004 in by jud || 1 Comment

slamm showed me a cool trick with Firefox that I didn’t know. Firefox
allows you to save a bookmark as a shortcut that will accept variable
substitution. It’s more difficult to describe than to do, but here’s the
scoop. If you have a site that you need to enter in some text to get search results, then
there’s a good shot you can create a keyword shorcut.

For example, bugzilla has a user query form /buzilla/edituser.cgi. This
form accepts a single parameter, a userid, and displays information
about users who match. If you are a bugzilla administrator (as I am),
this is a page that gets used frequently. Rather than clicking on my
bookmark, clicking to the form and then hitting submit, I can simply
create a keyword shortcut so that when I type “bzu jdagnall”, I get information about user *jdagnall*.

But since most of you don’t use bugzilla, I’ll give you an example of how we would create a shortcut for the IMDB, the Internet Movie DataBase.

The IMDB has a search engine that can be used to get information about movies. Instead of having to click on my IMDB shortcut and then
go to the search box, type in my search terms and then hit the “search” button, I can simply create a keyword search called “imdb” and type
directly into my browser from ANY page.

In order to make a shortcut, we need to get a URL that is used to generate some results. Typically, we can do this by modifying an existing results
page. So when we’re done, we’ll be able to type “imbd donnie darko” into the browser’s URL bar, and immeditely get a search results from the IMDB about
the movie *Donnie Darko*.

Here’s what you do:

1. Go to the [IMDB](http://www.imdb.org)

2. Type “darko” into the search box, and hit “search”. This gives a search [results page](http://www.imdb.com/find?q=darko;tt=on;nm=on;mx=20) that
we will use to create our special keyword search. It’s typically *much* easier to start with a valid search results URL than to try to figure out the correct
syntax on our own.

3. Create a new bookmark from the page.

4. Right click on the bookmark you just created, and select “Properties”. (You could also use the “Bookmars” sidebar)

5. Edit the URL, replacing “darko” with the string “%s”. This can be a little tricky. Typically, the browser must
encode special characters like the space (which becomes a “+”, or “%20”), so be try to use only a single word as a search term when you’re building your keyword shortcut.
Sections of the URL are typically separated by the & symbol, you’ll want to leave that.

> http://www.imdb.com/find?q=donnie;tt=on;nm=on;mx=20


> http://www.imdb.com/find?q=%s;tt=on;nm=on;mx=20

Firefox will replace “%s” with anything you want, and then run the search and show you the results.

6. Once you have added “%s”, create a name for your keyword search (“imdb” in this case) and use the “keyword” field to record it.

7. Close the bookmark.

8. Now you’re ready for a new search.

9. Click on the Location Bar in firefox (or press CTRL-L) and type **imdb two towers**

This should bring up a search that includes the movie *The two towers*

Add in the “Location Bar” keyboard shortcut (Alt-D or CTRL-L) and you can really fly:
Just type:

> CTRL-L imdb suburbia [enter]

And you’ll find a strange but very cool movie from the early nineties. This is how the various Firefox search shortcuts work, like typing “goog
some special word” and getting a google search for “some special word”. I
just never realized this, or dug around enough to modify any of them on my
own. Very cool!

Google vs. dagnall.net: my site is not indexed

Posted on October 24th, 2004 in by jud || No Comment

When I switched to the new PHP version of my site, I began to see a strange
problem: Google was no longer indexing my site on a regular basis. My site
would go from being #1 in a search for “Jud Dagnall” to somewhere down in the
second page with only a reference to an old guestbook page. However, every few
months it would jump back up. Yahoo was giving the results correctly (at least
for MY version of correct, since all the other Jud Dagnall references were
indeed about me!). So I’ve been a bit puzzled. Finally, just this morning I
came across a page
that describes the problem and suggests a solution.

In a nutshell, he suggests that the problem is that apache wasn’t associating
php with text/html content type requests. Here’s his fix: Add the
following to the apache config file:

    AddHandler php-script php
    AddType text/html php 

However, this does not seem to work for me. When I put it into a .htaccess
file, only part of my page renders. Furthermore, I am not able to
reproduce the bad behavior:

    $ curl -S -H "Accept: text/html" http://www.dagnall.net

This attempts to retrieve the header for a page, only accepting text/html
content types.

However, the page renders correctly, and I get text/html returnethe text of the php page is returnedd. I can request ANY content
type, and it still returns text/html.

I’ll need to investigate further.