I’m working through Zed Shaw’s Learn Python The Hard Way, and I’m up to exercise 5. Doing the extra credit 3 involved searching online for Python format strings, and I found that there is the old way, which is presumably what Shaw wanted me to find, and also the new way in which a new scheme for string formatting is provided.
Category Archives: Programming
WordPress – Page Links To
Was helping Teejay with his Cock n Bull web-site the other night, and we needed to setup a ‘page’ link in the top main navigation as a ‘link’ to the blog feed. Anyway, we found a WordPress plugin that does that: Page Links To. Pretty handy!
MediaWiki templates, revisited
After spending the afternoon investigating MediaWiki templates, I’ve decided that for the most part they are more trouble than they’re worth for any of my applications. I tried to create a ‘done’ template, that took username, user initials, date and ‘done note’ parameters, but really the code to call the template was just as long as not using the template, and the template broke when the ‘done note’ included a link that included an equals sign, which is just too shoddy. I’m giving up on templates until I find I actually have a use for them where the technology solves a problem that I actually have. At the moment that’s nothing.
MediaWiki templates
Today, after a long time, I am finally ready to learn about MediaWiki templates. After having put that off for weeks since I’d first heard of them, I found that it only took about five minutes to learn just about everything there is to know about them from the MediaWiki templates documentation. I think there are a few areas of the ProgClub wiki that could do with the use of templates, might go and see to that now.
Advice From An Old Programmer
Just recently I read Zed Shaw’s Advice From An Old Programmer, and in it he says:
I’ve been programming for a very long time. So long that it’s incredibly boring to me.
That’s been in the back of my mind for a few days, and something I’ve been thinking about as I hope for people to join ProgClub. It seems to me that the longer you program the less you are interested in programming. But, it takes time to be a good programmer, so the better you get, the less interested you become. ProgClub wants first and foremost people who are *interested* in programming, and secondly it wants people who are *good* at programming. Though it doesn’t seem like there are going to be that many good programmers out there who are going to have the time or the interest for ProgClub. Which means that ProgClub’s best bet is probably to encourage participation from enthusiastic beginners.
WordPress hooks
I wanted to configure the “From” email address that WordPress uses when emailing password resets. The way to do this is with a WordPress hook, specifically a filter hook in this case. So, in wp-config.php I added the following code:
add_filter( 'wp_mail_from', 'pcblog_mail_from' );
add_filter( 'wp_mail_from_name', 'pcblog_mail_from_name' );
function pcblog_mail_from() {
return 'pcblog@progclub.org';
}
function pcblog_mail_from_name() {
return 'ProgClub blog';
}
Pccipher released
I released pccipher today. This is my most significant open-source contribution, ever. I’m pretty proud of myself today.
Announcing jj5-bin
MediaWiki/Wikipedia content distribution
Involved in some design discussion on the wikitech mailing list.
Subversion release script
I wrote a script to manage project releases for ProgClub. Basically you pass the project name to the script, and it will create a release tag in tags/release/year/month/day/serial and update tags/latest with the latest release.
#!/bin/bash
if [ "$1" = "" ]; then
echo "Expected project parameter.";
exit 1;
fi
if [ "$2" = "" ]; then
echo "Expected comment parameter.";
exit 2;
fi
pcrepo="https://www.progclub.org/svn/pcrepo";
project="$1";
comment="$2";
echo Releasing $project;
svn info $pcrepo/$project 2> /dev/null > /dev/null
if [ "$?" -ne "0" ]; then
echo $project does not exist.
exit 3;
fi
year="`date --utc +%Y`";
month="`date --utc +%m`";
day="`date --utc +%d`";
serial="0";
serial_formatted="0";
svn_status="0";
while [ "$svn_status" = "0" ]; do
serial="`echo \"$serial + 1\"|bc`";
if [ "$serial" = "100" ]; then
echo "Out of serial numbers. You can't do any more releases today. Take a break!";
exit 4;
fi
less_than_ten="`echo \"$serial < 10\"|bc`";
serial_formatted=$serial;
if [ "$less_than_ten" = "1" ]; then
serial_formatted="0$serial";
fi
url="$pcrepo/$project/tags/release/$year/$month/$day/$serial_formatted";
echo Checking availability of release: $url
svn info $url 2> /dev/null > /dev/null
svn_status="$?";
done
trunk_url="$pcrepo/$project/trunk";
svn copy $trunk_url $url -m "Releasing $project: $year-$month-$day-$serial_formatted. $comment" --parents
latest_url="$pcrepo/$project/tags/latest";
svn delete $latest_url -m "Updating $project/tags/latest...";
svn copy $url $latest_url -m "Updating $project/tags/latest. $comment";