Rss

Archives for : March2014

ICS Cards – Export Statements

As part of my banking with ABN Amro I get a credit card managed by ICS Cards.

The single most annoying thing about ICS Cards is that they don’t provide any means of exporting my statements. The next most annoying thing is that they haven’t responded to any of my emails request that feature.

Time to help myself then, in true developer fashion, I’ll write my own.

I’ve used loads of languages over the years and different languages suit different tasks. Python turns out to be my go-to language for scraping web-pages and pulling out information from them. Mostly because it’s really easy to knock up a script and because there are loads of great libraries already available to do most of the grunt work.

So here it is. A quick and dirty script to log into my account, parse the monthly statement page, fix the formatting and write it out as CSV.

This is by no means a finished script (have you seen how messy it is!!) and it’s kinda hard-coded what it will download.

Here’s an example output once the script is done with it:

Fixing my %PATH%

After a while working with a computer it’s not unusual for my %PATH% environment variable to become messy.

It tends to contain wrongly formatted paths, or paths that no longer exist from programs that have been uninstalled.

This was causing me problems when I ran a tool that relied on the path and was having trouble with it. Turns out this tool was pretty primitive and a touch too over-sensitive.

I had no idea which path it was choking on, and there are a lot of entries in my %PATH%, and many of them use environment variables, the I thought I’d quickly write a powershell script to fix what’s in there.

There are a couple of simple rules for %PATH%

  • It’s a semi-colon separated list
  • Don’t use quotes (“) in paths
  • Spaces are permitted
  • Environment variables of the form %NAME% are permitted.

The script simply checks each path isn’t surrounded by quotes, ensures the path exists (it has to resolve the environment variables first) and then returns a new string in the correct format for the %PATH% environment.

It returns the script to give you a chance to verify it yourself. But if you just want to update the %PATH% without that step, you can do this:

Where “Fix-Path.ps1” is just a saved copy of the script above.

UML Diagrams the Simple Way

There is a great engineering aphorism to “Keep It Simple Stupid!”, the KISS principle.

Many developers often confuse easy and simple; I’ve done it in the past, and will probably again in the future. Where you stand can a big difference to your perspective.

Take UML Diagrams and particularly drawing and collaborating with them. There are dozens of editors out there that allow you to easily drag/drop/link etc. all your different diagrams and classes. They’ll remember relationships and properties and other funky things. This can make it very easy to draw a diagram, or many diagrams. Unfortunately it can also make life everything other than simple for those you need to collaborate with, updating the diagrams when you lose the tool (e.g. out of business, or license expired) or you don’t have the tool, or it doesn’t run on your computer.

One reason I’m a big fan of the TodoTxt format (and even have my own TodoTxtJs tool) is that it makes life very simple. It’s not the easiest tool to work with, it’s not always easy to do every task, but it is an extremely simple format, and the big advantage of that is compatibility and portability. I don’t need anything more than Notepad to read and manage my Todos, and there’s no way I’ll ever not be able to edit or read them. Tools can make me more productive, but I don’t need them.

Wouldn’t it be great if the same applied to UML diagrams? Interestingly it does. Enter plantUML.

Take this example definition:

Even if you’d never seen the diagram and never seen the syntax before, using a bit of effort, and some knowledge of UML, you’d be able to figure out what it’s describing. That is one aspect of what makes this simple.

In case you’re curious, this is the actual sequence diagram, and that’s just one of the many formats it understands:

UML Sequence Diagram

 

It also makes it a really elegant solution for collaborating with people. You don’t need to send huge binary files around in proprietary formats, just send simple text. You don’t even need the same “compiler” or “renderer”. Just knowing the syntax you could write your own, just as you’re able to understand what it’s showing by reading the text. A more complex diagram might require a paper and pencil 🙂

It also means that if you need to render it in a different way (e.g. colours, shapes, style) just use a different renderer. You have, coincidentally, gone a long way to separate content from presentation, and that’s almost always a good thing.

As an added bonus, if you’re storing your designs and documentation in a source control system, then you can diff a text file much more easily than complex binary file.

The good news is that plantUML is open-source and free, so there’s no likelihood of it ever going away, although it does have some dependencies (GraphViz and Java) but those are also open-source. There are loads of ways to use it, even from within your IDE. My only disappointment is that there’s no VisualStudio plugin yet.

Of course, it’s much easier to drag & drop stuff with a mouse and have lots of funky tools do things for you auto-magically. Where those “easy” tools fall down is that you need to get the software, make sure it works and runs on your set-up, have it available and understand how to use it and, most importantly, that everyone else does too. What makes this text based syntax simple is that anyone can just open the file and work with it using any text editor.

If you can ensure that everyone you will ever work with, and have to collaborate with, will have the same tools; you have the tools and infrastructure to collaborate easily using that tool and you’re sure you’ll keep access to those tools for the entire life of your project/product, then using the “easy” tools might be your best choice.

If you cannot ensure that, then you’re probably much better off looking for a simpler solution like plantUML.

 

 

 

 

Powershell CmdLet Function by Example

One of the big issues I have when writing Powershell functions is that there’s all these little structures and patterns to do things.

So I thought I’d write myself a quick guide in the form of a heavily commented function that does most of what I need. It has support for Pipelining, CmdLetBinding, ShouldProcess and comment based help.

Continue Reading >>