WordPress login attempts

I wrote a simple WordPress plugin that logs all login attempts, failed and successful ones, to a simple text file. Example log entry:

07.04.11 03:56 GMT+0200 IP:91.224.160.12    Failed login attempt - wrong password. User name: 'administrator' / Password: '123654'

It is very scary to see how many login attempts there are on a day. Most of them seem to be coming from bots that try often used username/password combinations in series of 10 to 20 attempts (or maybe ‘attacks’ is a better word).

There is one important lesson here: choose a strong password for you WordPress admin section, and change it often!
Even an insignificant and small blog will be subject to attacks.

Sometimes, a simple manual method is hard to beat for for sheer simplicity and reliability, even with advanced technology. I think flight progress strips are an excellent example of this.

Image credit: isafmedia (Flickr)

A flight progress strip is a small strip of paper used to track a flight in air traffic control (ATC). The strip is mounted in a plastic boot  and placed with other strips in a ‘strip board’. Each Flightstrip carries all the information a controller needs to know about a flight, and as instructions and information is given to the pilot. Also, the position of the strip in the board is a significant part of the information of the strip board. For example, approach and area controllers often keep their strips in level (altitude).

So why not use this system (or something that is based on it) for daily todo/task lists? Ok, if your not working in an ATC tower, your colleagues may look down at the flight strips at your desk and shake their heads in disbelief. But they will jealous once they discover that before lunch time, you’ve not only guided 12 airplanes safely to the ground, but also completed all your tasks efficiently and flawlessly!

But seriously, of course the ATC version of fps need some tweaking for office use, but I think the idea of using a physical system (for example wooden blocks) for prioritizing and ordering tasks is great.

I was disappointed to find out that there aren’t any existing products on the market that resemble the fps system (although at some people someone has had this idea before me. like this guy and this guy) .

Maybe an idea for David Allen‘s next edition of Getting Things Done? :).

A simple ActionResult class that serializes an object to binary JSON format, with the help the Json.NET library.

    public class BsonResult : ActionResult
    {
        private object _data;

        public BsonResult(object data)
        {
            this._data = data;
        }

        public override void ExecuteResult(ControllerContext context)
        {
            HttpContextBase httpContextBase = context.HttpContext;
            httpContextBase.Response.Buffer = true;
            httpContextBase.Response.Clear();

            httpContextBase.Response.ContentType = "application/bson";
           
            JsonSerializer serializer = new JsonSerializer();
            // serialize to BSON
            BsonWriter writer = new BsonWriter(httpContextBase.Response.OutputStream);
            serializer.Serialize(writer, _data);
            httpContextBase.Response.Write(writer);
        }
    }

Simple parsing with C#

It has been a long time since my computer science classes on parsing at the university, were I learned to build a basic parser in Haskell using parser combinators based on Parsec. I always found this an interesting subject, but writing your own parser is not something most programmers, including me, do in daily development. Especially if you’re a web developer.

But this week there were two instances where I thought “having a parser for this would be quit handy”: converting WikiText to HTML and building a markup tree from BBcode. Instead of undusting my Haskell college was notes, I set out to look for some examples in C#.

For WikiText I found this example: Parsing WikiText using a stack (dotnetperls). I adjusted the code to be able to parse MediaWiki text, which has a different syntax than the one used in the example.

For BBCode I wanted to try another technique: recursive descent parsing. I based my parser on
Eric White’s nice blog post series on the subject of writing a recursive descent parser with C# + LINQ. The result is a parse tree, which can be used for example to convert BBCode to HTML.

I wrote the BBCode parser just for fun. There is an existing stable .NET open source parser available: Codekicker.BBCode. I could not find a similar project for WikiText parsing in .NET.

DeviantART notifier

Because I wanted a simple usecase, in order to play with Benjamin Hollis’ nice .NET PopupNotify Control, I wrote a simple DeviantART notifier. The notifier is a stand-alone desktop application (Windows) that checks for new messages in a DeviantART account. If new message arrivess, a tray popup is shown.

Features

  • Desktop notifications. Via build in popups or via Growl for Windows.
  • Runs in system tray

Current project stage is alpha. Which means the notifier has not been fully developed and tested yet. Missing functionality (amongst other things):

  • Some messages types are not yet supported, such as Support messages (I haven’t asked for any support yet, so no examples in my in inbox;) )
  • This is kind of a test project for writing custom Windows forms controls in C# .NET. So the user interface is experimental.

The notifier uses the undocumented Difi API to retrieve messages from the inbox.

Screenshots

Source code

Source code of current alpha version is available here: DeviantNotifier on Google Code

See also

alternatives:

Just out of curiosity, I wondered how often visitors of my blog copy text (especially code fragments) to their clipboard. Detecting copy/paste/cut events in jQuery turns out to be easy And thanks to Google Analytics event tracking API, tracking these events with GA is also easy. This resulted in the following mini jQuery plugin:

/*
 * jQuery Clipboard tracking plugin
 *
 */

(function($) {    
  $.fn.ga_track_clipboard = function() {    
      return this.each(function() {
          var text = $(this).text().substr(0, 10) + "...";
          jQuery(this).bind('cut copy paste', function(e) {  
          // The specification for the _trackEvent() method is:
          //_trackEvent(category, action, opt_label, opt_value)
          _gaq.push(['_trackEvent', 'Clipboard', e.type, text]);
        });
      });
  };  
})(jQuery);

(I will notice it if you copy the code above) 😉

Usage example:

jQuery(document).ready(function() {
  jQuery("p").ga_track_clipboard();
});

Note that this code uses the first 10 characters of copied text as the event label. I don’t think that this an ideal value for the label, but I haven’t come up with a better and generic idea yet.

See also: