Blosxom Plug-in Mods: calendar
I use the calendar plug-in
(v0.6).
This plug-in produces the monthly calendar at the top of on the left hand sidebar
on each page of my blog. Before today, I was using this plug-in pretty
much modification-free. But I found that under certain circumstances,
the plug-in will get stuck in an infinite loop; namely, when the month
extracted from a PATH_INFO request is out of range. So I added some
simple month range checking and now it is much happier.
My modifications can be reviewed and downloaded here:
X10 Home Automation Using a CM11A Deivce on FreeBSD
A little over three years ago, I bought an X10 CM11A Serial Inferface
Controller. Then using some very handy Perl modules I wrote a small
piece of software that completely controls the outdoor lighting for my
home. The lights come on at sunset and are all off by sunrise. It's
a great little system and pretty easy to implement (on FreeBSD).
I chose the X10 CM11A Serial Interface Controller because there is a
Perl module (ControlX10::CM11)
explicitly written for the hardware. Because the CM11A connects to my
computer via the serial port, ControlX10::CM11 is dependent on the
Device::SerialPort
Perl module. Consider the following sample code:
#!/usr/bin/perl
use Device::SerialPort;
$serial_port = Device::SerialPort->new('/dev/cuaa0',1);
die "Can't open serial port $serial_port: $^E\n" unless ($serial_port);
$serial_port->error_msg(1); # use built-in error messages
$serial_port->user_msg(0);
$serial_port->databits(8);
$serial_port->baudrate(4800);
$serial_port->parity("none");
$serial_port->stopbits(1);
$serial_port->dtr_active(1);
$serial_port->handshake("none");
$serial_port->write_settings || die "Could not set up port\n";
use ControlX10::CM11;
receive_cm11($serial_port);
send_cm11($serial_port, 'A1');
send_cm11($serial_port, 'A1');
send_cm11($serial_port, 'AJ'); # J is on; K is off
send_cm11($serial_port, 'OJ'); # J is on; K is off
When executed, this code will send an X10 signal that will turn on any
X10 modules with an address of 'A1'. Not very interesting since there
isn't any code logic to determine when the "on" signal should be sent.
In order to determine when I should send "on" and "off" signals to my
different X10 lighting modules, I use the
Astro::Sunrise
Perl module. It is a handy little module that will quickly determine
the sunrise and sunset time for a latitude and longitude on any
given day. Here is small snippet of code that generates sunrise and
sunset times for my general location:
#!/usr/bin/perl
require Astro::Sunrise;
$long = -122;
$lat = 47.5;
$date = localtime(time);
print "$date\n";
$sunrise = Astro::Sunrise::sun_rise($long, $lat);
print "sunrise at $sunrise\n";
$sunset = Astro::Sunrise::sun_set($long, $lat);
print "sunset at $sunset\n";
Nice and simple and easy.
For my home automation software, I turn on all of the lights
at sunset. Then I have different sets of lights turn off at specific
times as the night progresses. Furthermore, I wanted to add a bit of
randomness to the off events so that it didn't just look like the
lights were going off at the same exact time every night. The lights
that I choose to stay on all night are turned off at sunrise (or more
specifically 1 hour before sunrise).
Here is the code that runs my home lighting; I call it from cron every
minute of the day. Have fun with it!
(Update Thu Aug 10 00:08:53 PDT 2006 // fixed some punctation mistakes)
:: Posted by rus on Mon, 07 Aug 2006 8:23 pm
:: Filed under /contrib/x10
Blosxom Plug-in Mods: comments
I use the comments plug-in
(v0.6)
on my blog. This allows visitors to contribute their snarky thoughts
and feelings about my blog content. I have made considerable
modifications to the original plugin, including:
- trap on reloads after POSTs to prevent duplicate entries
- e-mail comments posted back to a specified address
- obfuscate posted e-mail addresses
- better subject and title support
- require password to post comment
You can download my modifications to the blosxom comments plugin in the full
context of the file itself, or as a patch. My cvs development log for the
comments plugin is also available.
Baby Name Libraries
I scraped a few sites to build my baby name library, including the
Social
Security Administration. Direct downloadable copies of the
"basic" versions of my boy and girl name libraries are available:
Baby Name Regex Search
As I mentioned previously, we are expecting
another
girl. Furthermore, our previous name of choice ("Olivia") is a very
common one (at least going back for the past 5 years). So Kristy and I
hunkered down around the computer and tried to find a good alternative
to "Olivia".
While looking, I decided that the search interface at many of the baby name
sites was just too limiting. For example, we like the nickname "Liv"
but it is pretty hard to search for all names that have "liv" somewhere
in the beginning, middle, or end of the name. Enter perl (see perl, see
perl run, run perl run!).
Using a small script, I scraped a bunch of names off of a few web sites
that seem to have a fairly comprehensive list. Using those names, I
built a small local
library for my own personal use. Then I authored a very simple interface
to search the library using any (well... most any) regular expression.
It makes baby name searching that much more fun! Here's the link:
So if I punch in 'liv' and search (on the extended lib), I get a small set
of alternatives to Olivia. I did a bunch of other regex searches. For
example, the regex "^(a|e|i|o|u)[a-z]{4}(a|e|i|o|u)$" will yield
all six letter names that begin and end with a vowel.
If you aren't familiar with regular
expressions, here are some other examples:
| Regex | Functional Meaning |
| ^z | starts with 'z' |
| a$ | ends with 'a' |
| ^z.*a$ | starts with 'z' and ends with 'a' |
| ^e.*ana$ | starts with 'e' and ends with 'ana' |
| ^[a-z]{3,4}$ | all 3-letter and 4-letter names |
The links provided by the search utility go to a handy little site that
provides the meaning, origin, and relative popularity of the name.
(Update Mon Mar 13 14:34:22 PST 2006 // fixed an html problemo)
Blosxom Plug-in Mods: storytitle
I use the storytitle plug-in
(v0.5)
in order to include a nice page title on
each individual blog entry page.
I made just one minor tweak to the code, but other than that I pretty
much use it out of the box. My mod can be reviewed here:
(Update Fri Mar 17 00:16:47 PST 2006 // added link to original source)
Blosxom Plug-in Mods: categorytree
I use the categorytree plug-in
(v1.7)
to show the nifty by-category display of
my blog entries on the right hand side of every page of my blog. I made
one minor modification to the original code; I added a new class to
differentiate a top-level category from a sub-category.
My mod can be reviewed here:
(Update Fri Mar 17 00:12:01 PST 2006 // added link to original source)
Blosxom Plug-in Mods: flatarchives
I use the flatarchives plug-in
(v1.0)
to show the convenient summary of
blog entries by month on the right hand side of every page of my blog.
Other than just one very minor tweak I made to the code, I pretty much
use it out of the box. My mod can be reviewed here:
(Update Fri Mar 17 00:15:01 PST 2006 // added link to original source)
Blosxom Plug-in: multicat
I love my blogging software - blosxom. It's just so light, compact,
and easy to use. Blosxom is especially nice for someone like myself
that prefers to use a mouse as little as possible while using
a computer. I can use the
command line to author a new blog entry using vi, spell
check the new entry using aspell, modify
the blog entry's publication date using touch, and use
the standard unix file system commands to insert my new blog entry into
my blog file structure (i.e. my blog's category heirarchy). And I can
do all this as fast as I can type the commands at the shell prompt.
There is one limitation of blosxom that I just recently bumped up
against. The limitation is a byproduct of using the blosxom data
directory structure to double as the blog's category heirarchy. Each
blog entry lives in one directory, and thus one category. Sure, a blog
entry can be copied into (or a link made in) another directory to
associate the entry with a secondary category, but then blosxom
will show that entry multiple times. So, that's no good.
I wanted to find a way around this behavior primarily because I
wished to associate the daily journal entries
(located in "/daily_journal/2006")
that I composed about our recent trip to Vancouver
with a new category
(something like "/vacations/2006/vancouver"). That way, I could still
read my daily journal in a linear fashion using a URL like:
http://rus.berrett.org/blog/daily_journal/2006/
yet, at the same time, access just the journal entries that detail our
Vancouver vacation using a URL like:
http://rus.berrett.org/blog/vacations/2006/vancouver/
(Note: the above examples of URLs to access blosxom blog entries
presume that
my
modifications to blosxom with regard to "viewing by date" have been
applied to the blosxom installation).
With that goal in mind (one entry - many categories),
I set to the task of creating a blosxom plug-in that will allow me to
"file" a blosxom entry under one or more different categories while,
at the same time, suppress the display of the multiples. I was able to
create a plug-in (which I've named "multicat") that does exactly that.
The "multicat" plug-in allows me to easily classify a single entry under
many different categories (i.e. different directories) using symbolic
links. The multicat plug-in controls when the symlinks to the entries
are displayed and when they are hidden. Thus, the display of duplicate
entries (which is the normal blosxom behavior when symlinks to files
are encountered) is suppressed.
Support for the comments plug-in and the writeback plug-in is built-in.
Comments (or writebacks) that are added to or appear on a source entry
will show up in the symlinked entry and vice versa.
I think what I have done is very clever and I'm very pleased with the
result. I can now create symlinks to blog entries in other secondary
categories and, in effect,
file a single blog entry under multiple categories. This was something
that was impossible to do before (and I scoured over many different
other blosxom plug-ins) and, ultimately, I think it could be very
useful to the blosxom blogging community at-large (but I could be
wrong about that).
So, using the example above, I can now build a URL to access all of the
entries in my daily journal that are just about our recent trip to
Vancouver. Check it out:
Note that each of those entries has not one, but two, categories that
it is associated with. Mission accomplished.
More information about the multicat plug-in can be gleaned by reviewing
the source code (my perl reads pretty easy), or by reading the man page.
I have provided links to both (as well as my development log) below:
cheers!
(Update Mon Mar 13 00:47:59 PST 2006 // fixed a grammatical error)
My Modifications to Blosxom
I use blosxom
(v2) for my blog
software. It's lightweight, simple to setup and administrate, written in
Perl, and free to use and
alter. Blosxom uses the file system as its organizational structure.
Directory names become category names. Files are blog entries, and
blog entry titles are simply the first line in each file. The file
modification time is used as the blog entry's publication date.
Managing a blosxom blog is nothing more than creating, editing, and
manipulating files.
I've made just one minor modification to blosxom (see
log).
I wanted to be able to use all numeric directory entries, but this
conflicted with blosxom's built-in
"view
by date" capability. The feature allows for the creation of URLs to
isolate blog entries by date. The general form of such a blosxom blogi
URL is:
http://blog_url/[optional_category_path]/[YYYY]/[optional_MM]/[optional_DD]/
This is a great feature of blosxom. Unfortunately, blosxom out of the
box prevents me from
using all-numeric directory names such as a year (e.g. '/daily_journal/2005'
or '/daily_journal/2006'). I think this was simply a small oversight by
the original blosxom developer, and so I've added some code to correct it.
You can download my modifications to blosxom in the full context of the
file itself, or as a patch. My cvs development log for blosxom is also
available.
(Update Fri Mar 10 14:23:17 PST 2006 // updated links and link titles)
(Update Fri Mar 17 00:09:24 PST 2006 // added link to original source)
(Update Fri Apr 7 12:58:43 PDT 2006 // added clarity to description of mods)
|