Software


28
May 08

Microsoft Source Analysis Released

My team at work uses a fantastic Visual Studio add-in called Source Analysis to ensure consistency in our C# code formatting, commenting and organisation.

Microsoft Source Analysis

Source Analysis has now been released for the whole world to use, for free! The free download is available at the MSDN Code Gallery:

Source Analysis at Code Gallery

There’s also a blog here:

Source Analysis Blog


28
May 08

Damien Guard’s Envy Code R Font Updated

Another update to Damien’s great coding font Envy Code R, now at preview 7. This time we get a bunch of hinting improvements (Damien paid big bucks for the software to do this, consider donating!) and improvements when the font is used with larger sizes. Envy Code R also contains all the box drawing characters so makes a good console font – Damien even includes a .reg file to set this up for you.

Here’s what it looks like editing some python code in Programmer’s Notepad 2.0.9 with the Murky theme:

Envy Code R - preview #7

Read more at Damien’s Blog


28
May 08

Programmer’s Notepad 2 0.9.794 Released

It’s time for a second 0.9 unstable release, bringing a number of bug fixes and new features:

  • Automatic Update Check – at launch Programmer’s Notepad checks in the background whether there is an update available and shows you a message if there is one.
  • Vista open and save dialogs are now used throughout when you’re running Vista, previous OS versions should be unaffected
  • Programmer’s Notepad is now marked as Vista-aware, meaning that reads and writes to Program Files and similar locations are no longer redirected to the Virtual Store.
  • Find in Files can now search all open files
  • PyPN update 0.9 fixes a couple of event handlers

The update check is a very commonly requested feature. The system understands the difference between stable and unstable releases so most users will only ever see stable updates.

Currently there’s no UI option to enable unstable update checks (there will be!) but you can enable them for yourself by setting this registry value (assuming you’re using a default PN install):

Key: HKEY_CURRENT_USER\Software\Echo Software\PN2\General Settings
Value (REG_DWORD): CheckForUnstableUpdates = 1

209

What else is new in the 0.9 series?

  1. File browser window
  2. Open files window
  3. New, far better regular expressions support (multiline is coming)
  4. More colour schemes (I’m currently using ZenBurn) and the base styles adapt better with the colour schemes
  5. New PyPN release with more event hooks
  6. More Vista control styling dotted around (when running on Vista!)

Downloads

Installer: http://pnotepad.googlecode.com/files/pn209794.exe
Zip: http://pnotepad.googlecode.com/files/pn209794.zip
Portable Zip: http://pnotepad.googlecode.com/files/portable-pn209794.zip
PyPN for Python 2.4: http://pnotepad.googlecode.com/files/pypn-0.9.794-py24.zip
PyPN for Python 2.5: http://pnotepad.googlecode.com/files/pypn-0.9.794-py25.zip


28
Apr 08

Online Help now using Dokuwiki

The Programmer’s Notepad Online Help was previously run using MoinMoin, a wiki engine developed using Python and one that I was fond of many years ago. As with everything else on the internet, the help website had begun to develop a lot of spam over the last couple of months, and it would seem that MoinMoin just wasn’t up to the job of helping me to fight that.

I had to resort to regularly shelling into the server to rm -rf the page directories manually, as the web UI had nothing useful for removing several days of spam. In addition, managing the user base was a massive pain. Here’s how not to implement user control UI:

  • For every user operation, require the current user to switch into the user they wish to operate on (e.g. admin has to switch to be spammer)
  • Then and only then allow disabling of the spammer account
  • Once disabled, log the current user out rather than return them to their own account

For each bad user, I had to login, switch users, disable account, and log in again. I am fairly sure that the spammers had a much easier job than me!

I stumbled across Dokuwiki while browsing, it looked much better maintained and cared for than MoinMoin, and much more feature-rich – the two features I was particularly looking for were Docbook export (provided via a plugin) and support for Akismet for spam catching. Akismet support was still not available from MoinMoin last I checked. Dokuwiki also has a much better look and feel than MoinMoin alongside including a reasonable web administration interface, and built-in support for syntax highlighting code.

The Online Help site has now been transitioned to Dokuwiki, maybe now would be a good time for you to take a look and maybe contribute!


26
Apr 08

pnotepad.org hacked

Who would want to hack my website?!

It would appear that hacking doesn’t always take the “This site 0WneD by L33t Hax0rs” form, and that WordPress sites in particular are being targetted by Spam Injection hacks.

A few weeks ago I noticed that the ads on the front page of pnotepad.org were a little odd, lots of drug adverts and nothing programming related. I didn’t really think much about it, however, and moved on to something else.

Yesterday I got a friendly tip-off e-mail (thanks Erik!) telling me that pnotepad.org was serving up adverts and links for various drugs and other unpleasantness. Weirdly, I couldn’t see the problem at all. A little bit of investigation showed that these ads were only showing up if you used Firefox (not Safari or IE), but sure enough they were there.

I spent the rest of yesterday evening undoing the work of the hacker, tying down various parts of the host system, upgrading WordPress and re-doing the customisations used on the pnotepad.org site.

It’ll never happen to me.

I had put off upgrading WordPress for a long time due to thinking I’d need to rework various customisations with the upgraded code, and not really knowing how much effort the upgrade would cost me. I learned a lesson there! The hacker got in via well-known WordPress hacks. In the end, the pnotepad.org site didn’t work properly for a few hours – perhaps 10 at most (some while I slept). I wish I had just upgraded earlier.

If you run a WordPress-based site or blog, make sure you are up-to-date! This means you may have to take some pains and use newer versions that you’re not fully sold on, but the alternative is you may end up with a hacked site. You may not even notice at first!

There are some useful pages on hardening your WordPress install here:


4
Apr 08

Boost::Xpressive and Scintilla

Programmer’s Notepad has long needed an improved Regular Expressions engine. Currently PN uses PCRE for all tasks but searching Scintilla. This is because PCRE doesn’t support searching anything but a memory buffer – i.e. it doesn’t support iterators. We need iterator (or indirect access) support because a regex engine for a text editor can’t expect all text for the editor to be in a single contiguous memory block.

Boost::Regex has been suggested several times, but it still doesn’t support named captures. When allowing users to specify regular expressions for use in parsing, named captures can significantly simply the process. For example, when using a regular expression to parse compiler output we have two alternatives:

  1. \s*(?P<f>.+)(?P<l>[0-9]+)(,(?P<c>[0-9]+))?\s*:

    This uses the standard named capture syntax to name the three capture blocks: “f” for filename, “l” for line and “c” for column. The single expression can be parsed and understood by PN without the user having to understand capture indexing.

  2. \s*(.+)([0-9]+)(,([0-9]+))?\s*:

    This uses basic regular expression capture groups and results in the user having to enter three additional pieces of non-obvious data: the capture index for each capture. In this case these would be 1, 2, and 4 but this would potentially change for each output pattern.

 

I believe that using named captures significantly improves the user experience around this, especially considering that PN uses %f, %l and %c to represent the three named capture groups meaning that users don’t even need to understand regular expression capture syntax to use them.

Boost 1.35 introduces version 2 of Boost.Xpressive, the other boost regular expressions engine. Boost.Xpressive naturally supports iterators. Version 2 supports named captures.

Implementing a Scintilla Iterator

Xpressive requires a bi-directional iterator class (one that can move forwards and backwards over the contents). I’ve currently implemented a very simple, naive iterator to prove that this can work:

/**
 * std::iterator compatible iterator for Scintilla contents
 */
class ScintillaIterator : 
public std::iterator<std::bidirectional_iterator_tag, char> { public: ScintillaIterator() : m_scintilla(0), m_pos(0), m_end(0) { } ScintillaIterator(CScintilla* scintilla, int pos) : m_scintilla(scintilla), m_pos(pos), m_end(scintilla->GetLength()) { } ScintillaIterator(const ScintillaIterator& copy) : m_scintilla(copy.m_scintilla), m_pos(copy.m_pos), m_end(copy.m_end) { } bool operator == (const ScintillaIterator& other) const { return (ended() == other.ended()) && (m_scintilla == other.m_scintilla) && (m_pos == other.m_pos); } bool operator != (const ScintillaIterator& other) const { return !(*this == other); } char operator * () const { return charAt(m_pos); } ScintillaIterator& operator ++ () { m_pos++; return *this; } ScintillaIterator& operator -- () { m_pos--; return *this; } int pos() const { return m_pos; } private: char charAt(int position) const { return m_scintilla->GetCharAt(position); } bool ended() const { return m_pos == m_end; } int m_pos; int m_end; CScintilla* m_scintilla; };

 

This can then be used with Xpressive like this:

typedef boost::xpressive::basic_regex<ScintillaIterator> sciregex;
typedef boost::xpressive::match_results<ScintillaIterator> scimatch;
typedef boost::xpressive::sub_match<ScintillaIterator> scisub_match;

void test()
{
    sciregex regex = sciregex::compile("[0-9]+");
    scimatch match; 
    if (regex_match(m_scintilla, match, regex))
    {
        LOG("Yay!");
    }
}

This code is now available in Programmer’s Notepad subversion, and it seems to work. The iterator needs a bit of improvement to buffer data from Scintilla, or perhaps needs moving so that it doesn’t have to send a windows message for every character access. However, as a proof of concept it’s a good one and it suggests that we should be able to replace the current lacklustre regex searching support with fully featured multi-line support for the next release.


14
Feb 08

ClipX

Occasionally I get a feature request for Programmer’s Notepad asking for clipboard ring support. Personally I’ve never been a big fan of clipboard rings, although it may be implementations like that in Office that puts me off. Jeff Atwood is a big fan of them, however, and pointed to ClipX as an implementation that works regardless of what program you’re using:

clipx-intray

ClipX is freeware, and will from now on be my recommendation for those wanting Clipboard Ring support in Programmer’s Notepad. I’ve even downloaded it and installed it myself to see if I can see what the fuss is about!


14
Feb 08

SvnExplorer

I needed to do a little browsing of the PN subversion repository this evening, and wanted to do so from a GUI without installing my normal favourite TortoiseSVN. I found SvnExplorer after a bit of searching and it did the job just fine. I’d have preferred not to have to use an installer, but it wasn’t too painful and it did the job.

 

SvnExplorer

 

SvnExplorer Web Site


7
Dec 07

Google Chart API

Google has a great Chart API that allows you to request a chart using just a normal URL query string, e.g.

http://chart.apis.google.com/chart?cht=lc&chs=200×125&chd=s:helloWorld

gets you:

The API is remarkably powerful given the minimalistic interface. Here are two internet-favourite charts:

chs=250x125&cht=p&chd=t:78.0,18.0&chl=%50%61%63+%4D%61%6e

the best pie chart ever, and we can also do Venn diagrams:

chs=400x200&cht=v&chd=t:1.0,1.0,0.0&chl=Times+when+I+am+truly+happy|Times+when+I+am+wearing+pants

See the Developer’s Guide for the full details.


25
Oct 07

Google Apps – the new Linux Mail Server

Or how I learned to give up a bit of control, and let Google take over my mail and mailing lists.

For the last 10+ years I have run my own mail server, I’ve used a variety of platforms and servers including Win NT4, Win 2k, Debian and Gentoo using Mailtraq on Windows and Postfix/Qmail/Exim/Courier/Squirrelmail on Linux. Mailtraq was very easy to administer and I would highly recommend it, but I needed to move away from hosting a Windows machine at home and the only reasonably priced VM I could afford was a Linux host.

Administering any of Postfix/Qmail/Exim is fairly hard work. The tools are almost all console based (it’s Linux!) and the configuration often complicated and hard to debug. That said, these systems will run in low memory environments and deliver mail efficiently. The problem is keeping on top of a Linux system running these tools and making sure everything keeps running smoothly takes a fair amount of time – way more than administering Mailtraq ever took.

I was in the middle of advising a friend to use Google Apps the other day when it occurred to me that perhaps I should take my own advice. Managing my gentoo box has been eating up a lot of my time over the last year, I want to rebuild with something more manageable but migrating the full mail setup to a rebuilt box filled me with fear.

So I took the plunge and migrated untidy.net to Google Apps in one night. The sign-up and configuration process was very easy, and the advice on what needed doing externally was clear and concise. Essentially I just needed to change the domain MX records for untidy.net to point to Google mail servers and optionally add a record to give me a nice domain for webmail. For plenty of good information on techniques for migrating your mail to Google Apps see the excellent article by Scott Hanselman

Having done that I’m now in the process of migrating the pnotepad.org mail services to a combination of the same google apps account, and the google groups lists service. The mailing lists have already been moved, this was simply a matter of transferring member lists which was easy to do. The rest of the mail will be moved tonight hopefully.

I’m already familiar with the gmail interface and using it for all my mail now is proving great so far, it’s a huge improvement over squirrelmail. Even if I don’t want to use the web interface, I can access my mail over IMAP or POP3 just like before.

For me, Google Apps is the new Linux Mail Server – why run your own when someone far more competent can run one for you!