NIEDZIELSKI.COM
 

RSS Email Notifications for WordPress

Introduction
  I share a group blog at waterblogged.net with a couple friends. I wanted to get regular email notifications containing complete content for new entries and comments, even for password protected feeds. Some email clients provide varying support for RSS feeds, but I’m a Gmail user and at present this support is very limited. So, I wrote a couple scripts that run on my web server. This documents makes a couple notes and provides links to the source.
  As a disclaimer, a big goal of this project was experimentation. The other part being that the end product work specifically for my configuration, in particular, a WordPress blog. Areas of my scripts drift between wildly impractical to very hackish. There were many solutions to this problem and I’m certain what I present is not ideal.

mr_wb.mk – master script
  This makefile wraps all operations in one. In retrospect, I think it would be better to have written this in Python, but I also wanted to experiment. Assume spaces are tabs as appropriate when copying snippets or grab the original source.
  This useful snippet from the GNU Make manual provides fast PATH searching:

path_search	=	\
	$(firstword $(wildcard $(addsuffix /$(strip $(1)),$(subst :,$(space),$(PATH)))))

  Here I experiment with makefile error handling which is basically BASH error handling. I force immediate trap on commands returning non-zero status and print some info.

red				:=	'\e[1;31m'
colorless	:=	'\e[0m'
begin_rule	= \
	set -e; \
	set -o pipefail; \
	function err_trap() \
	{ \
		echo "error: $$BASH_COMMAND returned $$1 at time $(exec_date)."; \
	}; \
	trap 'err_trap $$?;' ERR; \
	echo -e $(red)--- rule: $@ ---$(colorless)

end_rule	:= \
	echo --- done ---

format_feed.py – new feed item to HTML email
  This script uses Universal Feed Parser to parse a downloaded comment or entry feed. If new items are found since last execution, they are extracted and converted to a rich text HTML file.

print_missing_modules.py – Python prerequisite checking
  This is one of those wildly impractical parts of the script I mentioned I was experimenting with earlier. I ended up canning this feature since the modulefinder module prints a ton of missing modules but most scripts usually run anyway.

cron – regular script execution
  Nothing special going on here for cron junkies, but this was my first time, actually, so I’ll explain it in brief. Cron provides for regular execution of arbitrary scripts. A tab delimited format describes regularity and command. For further information, Wikipeda has a nice article. In my case, my cron script looks something like:

*/9  *  *  *  *  make -C scripts/mr_wb -f mr_wb.mk -rR --warn-undefined-variables;

  Please imagine the spaces surrounding the asterisks as tabs. This script causes Make to be invoked every 9 minutes of every hour. I launch the Cron service by typing crontab .crontab (this script being named .crontab).

  Download the file archive here.

bananas

I finally got around to experimenting with the last.fm / Audioscrobbler API to generate song recommendations.  It turned out to be fairly simple to write a rudimentary Python script to automate the task.  For example, here’s all the code for retrieving data in XML form from last.fm:

import urllib

def service( str_url ):
sock = urllib.urlopen( str_url )
str_xml = sock.read()
sock.close()
return str_xml

The script is fairly pragmatic / specific / hackish. I just wanted my recommendations. Here’s a breakdown of the automation:

  1. Get my top 50 tracks.
  2. For each track, get the top 50 listeners.
  3. For each listener, get their top 50 tracks.
  4. Count the number of occurrences of each track and dump the results in an ordered list.

In terms of results, here are my top ten recommendations (without tracks already contained in my top 10):

0080: Coldplay – Viva la Vida
0070: The Killers – When You Were Young
0066: Paramore – Misery Business
0050: Metro Station – Shake It
0049: The Postal Service – Such Great Heights
0047: Coldplay – Violet Hill
0046: Muse – Starlight
0046: Death Cab for Cutie – I Will Follow You Into the Dark
0043: Jason Mraz – I’m Yours
0041: Death Cab for Cutie – Soul Meets Body

The numbered column on the left represents the number of listener top 50’s a song was found in during the search. The second column represents song artist. The third represents song title.

So I listened to the recommendations! Out of the above 10, there was one song I enjoy (Starlight, for the record) and the rest didn’t do anything for me. BAH! I think that in order to get better results I would need to make a significantly more sophisticated selection.

At any rate. you may download my hackjob here.

swankmania

  swankmania was a neat one semester project I did in the Fall of 2007. It was a portable gaming device featuring a liquid crystal display (LCD), vector graphics, and a vintage controller. As I needed to demonstrate the capabilities of swankmania, I also designed BLiT, a small game in the vein
of Asteroids.

  The most interesting and challenging aspect of swankmania was designing the vector graphics controller. This component is responsible for receiving model vertices, color, mode, and other information and rasterizing their representations on the LCD using a double buffered frame. As the throughput needed to update the LCD many times a second was great, I developed the mechanism on a field programmable gate array (FPGA) using synchronous and asynchronous elements. Since there was only room for one frame on the FPGA, I also interfaced with external RAM for the second frame. For line drawing, I implemented a variation of the well known Bresenham algorithm in hardware.

  Design on the FPGA incorporated multiple clock domains for the LCD controller, rasterizer, and communications buffer. At completion, the device was capable of updating every pixel on the 240 x 160 screen about 30 times over without missing a frame at 72 frames per second.

  BLiT was a very simple Asteroids-like game that demonstrated some of the neat lossless aspects of vector graphics like scaling and rotation. I wrote BLiT mostly in C on a microcontroller that interfaced with the vector graphics controller and an old input controller from the Nintendo Entertainment System.

  Special thanks goes to Christopher Theriault for designing the LCD printed circuit board (PCB), Mike Anderson for rendering tips and miscellanies, Cesar Carrasco for soldering components to the LCD PCB, and Todd Seiler for miscellanies.

  Here’s some photos of the project: