<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
>

<channel>
	<title>A mind less ordinary &#187; Utilities</title>
	<atom:link href="http://www.dmi.me.uk/blog/category/coding/utils/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dmi.me.uk/blog</link>
	<description></description>
	<lastBuildDate>Wed, 23 Nov 2011 16:01:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
<creativeCommons:license>http://creativecommons.org/licenses/by-nc-nd/3.0/</creativeCommons:license>
		<item>
		<title>FolderCheck Thunderbird Extension</title>
		<link>http://www.dmi.me.uk/blog/2007/05/08/foldercheck-thunderbird-extension/</link>
		<comments>http://www.dmi.me.uk/blog/2007/05/08/foldercheck-thunderbird-extension/#comments</comments>
		<pubDate>Tue, 08 May 2007 09:09:00 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Utilities]]></category>

		<guid isPermaLink="false">http://www.dmi.me.uk/blog/2007/05/08/foldercheck-thunderbird-extension/</guid>
		<description><![CDATA[This is something I've been meaning to write for a while, and finally got round to doing. Basically, it's a simple Thunderbird extension that makes it easier for you to check other folders for new messages. I've named it FolderCheck* (rather unimaginatively), and it's available from the Mozilla Add-ons site sandbox. The problem is that, [...]]]></description>
			<content:encoded><![CDATA[<p>This is something I've been meaning to write for a while, and finally got round to doing. Basically, it's a simple Thunderbird extension that makes it easier for you to check other folders for new messages. I've named it <a href="https://addons.mozilla.org/en-US/thunderbird/addon/4936" target="_blank">FolderCheck</a>* (rather unimaginatively), and it's available from the Mozilla Add-ons site sandbox.</p>
<p>The problem is that, at the moment, Thunderbird will only check either the inbox or every folder for messages (for all accounts). This is pretty useless for me, as I only get new email in my inbox for some accounts, and get my email server-sorted into different folders for other accounts. This means that if I want to tell Thunderbird to check a specific folder for messages, I have to right-click the folder, choose "<u>P</u>roperties", check "<u>C</u>heck this folder for new messages", then click OK. And do it all over again for the next folder. And the next. This quickly gets irritating!</p>
<p>My extension adds a new "C<u>h</u>eck for new items" item to the context menu for each folder (except Inbox and some other special folders) that allows you to quickly see whether a folder is checked for new messages, and to quickly and easily toggle that setting. Now I just have to right-click each folder and hit "h" to toggle the setting.</p>
<p>Coming soon (when I get round to it): a dedicated window to make multiple folder selection easy. My current thought is a list of folders with a filter box and "(De)Select All Visible Folders" buttons.</p>
<p>* Note: currently requires a free Mozilla Developer account, as it's not yet a public extension.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dmi.me.uk/blog/2007/05/08/foldercheck-thunderbird-extension/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-nd/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Coolermaster CoolDrive 6</title>
		<link>http://www.dmi.me.uk/blog/2007/04/07/coolermaster-cooldrive-6/</link>
		<comments>http://www.dmi.me.uk/blog/2007/04/07/coolermaster-cooldrive-6/#comments</comments>
		<pubDate>Sat, 07 Apr 2007 23:51:37 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Utilities]]></category>

		<guid isPermaLink="false">http://www.dmi.me.uk/blog/2007/04/07/coolermaster-cooldrive-6/</guid>
		<description><![CDATA[Well this has been a bit of a saga so far. I've been working on Linux support for the CoolerMaster CoolDrive 6 (CD6 henceforth) which I currently have in my computer. It has a USB connection, and an inbuilt Prolific PL2303X USB-Serial converter. Sadly, I've been struggling with uncooperative C code that I'd found which [...]]]></description>
			<content:encoded><![CDATA[<p>Well this has been a bit of a saga so far. I've been working on Linux support for the CoolerMaster CoolDrive 6 (CD6 henceforth) which I currently have in my computer. It has a USB connection, and an inbuilt Prolific PL2303X USB-Serial converter. Sadly, I've been struggling with uncooperative C code that I'd found which <em>supposedly</em> allows me to control a serial port. Yeah, right.</p>
<p><span id="more-17"></span><br />
I've got the source from the CoolerMaster-provided programs that deal with the device, so all I need to do is get serial communication working (9600 baud, 8 data bits, 1 stop bit, no parity or handshaking) and I should be good to go. This will have the following advantages:</p>
<ol>
<li>My processor fan is connected to the <strong>FAN1</strong> output of the CD6. It would be quite nice to software-control (and -read) its speed depending on whether I want cool operation or silence.</li>
<li>The internal HDD fan is hardwired to the <strong>FAN3</strong> output of the CD6. It would be quite nice to software-control (and -read) its speed etc... especially as I don't really currently use it.</li>
<li>My other case fans are currently controlled by a switch I've modded into a bay bevel. It would be great to take away the hardware from this too so that all fans in my computer are software-controlled. To do this, I can simply attach a couple of transistors to some cables going to <strong>FAN2</strong>, and then they will switch the fans on and off depending on whether <strong>FAN2</strong> is on or off.</li>
</ol>
<p>The end result? I want to be able to press a button on my keyboard (the backlight button, in fact), and turn off the backlight on my keyboard, the case fans, case glow and HDD fan, and to slow my CPU fan down to about 1700 RPM. Another press of the button will activate the backlight, case fans, case glow and HDD fan and speed the CPU fan up to 2300 RPM or so. That way, I can watch films/videos or sleep in near-silence with a simple keystroke, and go back to intense operation just as quickly. I could even decide that I wanted to do some compiling while I was away from my machine, and turn the fans on via SSH.</p>
<p>The possibilities are (obviously) endless.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dmi.me.uk/blog/2007/04/07/coolermaster-cooldrive-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-nd/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Automatic email forwarding</title>
		<link>http://www.dmi.me.uk/blog/2007/03/08/automatic-email-forwarding/</link>
		<comments>http://www.dmi.me.uk/blog/2007/03/08/automatic-email-forwarding/#comments</comments>
		<pubDate>Thu, 08 Mar 2007 09:19:09 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[University]]></category>
		<category><![CDATA[Utilities]]></category>

		<guid isPermaLink="false">http://www.dmi.me.uk/2007/03/08/automatic-email-forwarding/</guid>
		<description><![CDATA[Well I got fed up with email filter rules last week, and this is the rather bizarre result: autoforward, a Perl script and configuration file that will automatically generate Exim filter files (.forward files), mainly to be used on my University account. My email processing rules have become pretty complex and messy, making them difficult [...]]]></description>
			<content:encoded><![CDATA[<p>Well I got fed up with email filter rules last week, and this is the rather bizarre result: <em>autoforward</em>, a Perl script and configuration file that will automatically generate Exim filter files (.forward files), mainly to be used on my University account. My email processing rules have become pretty complex and messy, making them difficult to control, and there's a lack of uniformity about them. I decided there had to be a better way, so set about writing a configuration format and parser... and I think I succeeded.</p>
<p><span id="more-6"></span></p>
<p>The configuration file format is pretty simple. There are some global options that must be set, and then sections named after the directory to which they filter mail.  These sections then contain some (optional) meta-actions (e.g. automatic archiving by date or automatic reply), one or more matching rules (i.e. how to decide if an email message should be processed by this rule) and then zero or more actions to be taken (the default being "save to the given folder and stop processing"). Let's take a look at a (very simple) example:</p>
<pre>[!GLOBAL!]
mail-root = "IMAP"
errors-to = "errors"

vacation-level = 0
vacation-alias = my.user@my.university.ac.uk myabbr@my.university.ac.uk
vacation-msg = $home/vacation/message
vacation-log = $home/vacation/log
vacation-once = $home/vacation/once
vacation-repeat = 2d

archive-path = "IMAP/archive/$1/"

[spam]
group
  header X-Spam-Flag  == "YES"
  header Subject      =~ "^((my|new)s)?PH[a-z]*A?[a-z]*R[a-z]*MA"
  header Subject      =~ "^ME[a-z]*DS"
endgroup
and
!anydomain             "my\.university\.ac\.uk"

[!UNDELIVERED!]
@ARCHIVE INBOX
@VACATION 4

saveto .email</pre>
<p>Wow. What the hell does that all mean? Allow me to explain.</p>
<p>The first part deals with global settings, including:</p>
<ul>
<li>The root directory that mail should be stored in</li>
<li>The directory that error messages should be stored in</li>
<li>The current "vacation level" and other settings related to it (see later)</li>
<li>The directory that automatic archive copies should be stored in (see later)</li>
</ul>
<p>After that follows a filter rule for email to be put into /spam. I first create a nested rule that checks if the X-Spam-Flag header is set to "YES" or the subject matches one of two patterns that came up very frequently for a while. It then also checks against bizarre false positives by ensuring that the "from" domain does not match my university's domain (or any of its subdomains, like lecturer@dept.my.university.ac.uk). Sadly, Exim is very strange about its quoting rules, and that is the reason for the multiple backslashes. Maybe that will be tidied in a future release <img src='http://www.dmi.me.uk/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' title="icon smile photo" /> </p>
<p>The final rule deals with any email that hasn't been delivered yet, and is a special rule (as evidenced by the exclamation marks and capital letters). This rule contains two meta-actions. The first tells it to automatically archive email by date to IMAP/archive/yyyy-mm/INBOX. The next meta-action says that if the "vacation-level" variable is 4 or higher and the email was sent directly to me, automatically reply to the sender. Finally, there's an actual action that causes the email to be saved to my .email file.</p>
<p>For the curious, this turns out to be something like the following, when run through <em>autoforward</em>:</p>
<pre># Exim filter  &lt;&lt;== do not edit or remove this line!if error_message then

  save IMAP/errors

  finish
endif

add 0 to n0

############################################################
## Dir: spam
############################################################

if (
  $h_X-Spam-Flag: is "YES"
  or $h_Subject: matches "^((my|new)\s)?PH[a-z]*A?[a-z]*R[a-z]*MA"
  or $h_Subject: matches "^ME[a-z]*DS"
)
and foranyaddress $h_From:,$h_Reply-To:
  ($thisaddress does not match "@([^@]+.)?my\\.university\\.ac\\.uk")
then

  save IMAP/spam

  finish
endif

###########
## INBOX ##
###########

if not delivered
then
  if $tod_log matches "^(....-..)" then
    save IMAP/archive/$1/INBOX
  endif

  if personal alias my.user@my.university.ac.uk alias myabbr@my.university.ac.uk
  and $n0 is above 3 then
    mail
      to $reply_address
      subject "Re: $h_subject:"
      expand file $home/vacation/message
      log  $home/vacation/log
      once $home/vacation/once
      once_repeat 2d
  endif

  save .email

  finish
endif</pre>
<p>So, if you want to try it, see the attached script and example files, as there's much more you can do with it!</p>
<ul>
<li><a href="http://www.dmi.me.uk/blog/wp-content/uploads/2007/03/autoforward.pl">autoforward.pl</a></li>
<li><a href="http://www.dmi.me.uk/blog/wp-content/uploads/2007/03/autoforwardsample.conf">autoforward.sample.conf</a></li>
</ul>
<p>To run the script, you should type something like:</p>
<p>autoforward.pl &lt; ~/autoforward.conf &gt; ~/.forward</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dmi.me.uk/blog/2007/03/08/automatic-email-forwarding/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-nd/3.0/</creativeCommons:license>
	</item>
	</channel>
</rss>

