Archive for the ‘code’ Category

A PowerShell command you should avoid

Tuesday, October 23rd, 2007

While I was writing my presentation on PowerShell, I did one spectacularly dumb thing which I thought might be fun to share.

I was doing some screen-captures for use in slides, to show how you can stop a process.

What I meant to type was:

Get-Process notepad | Stop-Process

Get me all of the notepad processes, and pipe them to Stop-Process which will stop them.

But stuck deep in PowerPoint slide-producing-hell, my fingers ran quicker than my brain and what I actually typed was:

Get-Process | Stop-Process

Crap.

Fancy taking a guess what that did?

(more…)

An introduction to mobile development on Windows Mobile

Tuesday, October 23rd, 2007

Another day, another HackDay presentation. This one is a little more lightweight than yesterday (a breakneck crash course through learning how to use and extend PowerShell).

It’s basically a beginner’s guide to mobile development – some scene-setting and a few walkthroughs how to do “Hello World”-type stuff with the key Windows Mobile libraries.

Hopefullly will be interesting to someone!

I guess I’ll know in about an hour 🙂

An introduction to Windows PowerShell

Monday, October 22nd, 2007

Later today, I’m giving a presentation on Windows PowerShell as a part of the lead-up to this year’s internal IBM HackDay.

It’ll be good to address some of the misunderstandings I had about PowerShell when I wrote about it before. In the presentation, I will be giving an introduction to Windows PowerShell – what is it, and how it works.

I’ll also be talking about how you can extend it to provide support for administering your own product or project (which is where the HackDay element comes in – hopefully to encourage some PowerShell projects!).

Impatient people can get a sneak peek at my slides here…

(more…)

Getting the currently selected text from Pocket Internet Explorer

Saturday, October 6th, 2007

As part of my hack for mobileCampLondon, I wanted to get the current selection from the web browser on my Windows Mobile phone.

The plan was to add a new menu item to Pocket Internet Explorer that lets you search for the text you’ve selected in Google. So I needed to get the currently selected text in order to include it in a Google search page URL. I thought it’d be simple, but it turned out to be more of a hassle than I expected.

My final approach is more of a hack than I’d have liked, so in this post, I’ll outline my unsuccessful approaches before showing what I finally ended up doing.

(more…)

Process your emails – an Outlook plugin

Thursday, September 13th, 2007

I got a nice email last week from someone asking why I never made the “triage” Outlook plugin I mentioned last year available as I have with other bits of code. The short answer was obviously because I never got round to finishing it! 🙂

However, the idea feels a bit more topical at the moment so I think it is worth revisiting.

The aim was to create something that would let me process my emails in Outlook Mobile (the cut-down version of Outlook you get on Windows Mobile PDAs and smartphones).

“Processing”, rather than doing emails is an idea that I hear people mention more often since Merlin Mann’s brilliant Inbox Zero talk started doing the rounds as a Google video. I’m even hearing other people use it as a phrase from time to time! I used to call it “triaging” my email, but I think “processing” is actually a better term. Either way, the idea is that I want to be able to go through my inbox as quickly as possible – doing something with each one so that I can finish up with an empty inbox.

Inbox ZeroIt doesn’t mean doing everything right away – just putting the information in it’s right place. If it’s an email asking me to do something, the right place for the email is in my Task List, not my Inbox. If it’s an email telling me about a meeting or appointment, then the right place for the email is in my Calendar. If it’s an email containing information that I need to keep for future reference, then the right place for it is in my wiki.

Mobile phones seem like an ideal tool for processing email, as it’s something that you can do when you have a few spare minutes and without having to do a lot of text entry or other input. Rather rely on manual (and slow!) copy-and-pasting, I wanted Outlook Mobile to be able to move my emails around like this for me. This was the idea of the plugin…

If you are interested in the pain of writing MAPI plugins in C++, read on. If you are… erm… normal – then the short version is that I tidied up the code and made it available.

(more…)

Writing PowerShell cmdlets

Wednesday, September 5th, 2007

After a conversation with someone at IBM last week about PowerShell, I picked it up again and have been having a play. I’ve been trying to write my own cmdlets, which has been an interesting experience – so I thought I’d jot down a few quick notes about what it’s been like.

First… a quick recap. Windows PowerShell is a command-line shell for system administrators. It has a number of neat features, but perhaps the most obvious is it’s object oriented approach – letting you pass objects (rather than strings) between commands in a pipe. I’ve done some work on writing PowerShell scripts before, but this time I approached it more as a developer – looking at how to extend the shell with new commands.

The .NET nature of PowerShell means you can run any .NET API at the Shell. In fact, this is what I did when I first played with PowerShell using the WebSphere MQ .NET API. It’s a quick way to get started without having to learn much about PowerShell – and I played around writing some simple scripts that were a translation of C# programs into the PowerShell syntax.

But it wasn’t really using PowerShell in the PowerShell way. What I have tried doing over the last couple of evenings is to extend PowerShell to include new commands that support WebSphere MQ administration work. I’ve been writing Cmdlets.

(If you’re not too interested in the detail of the whys or the hows of creating cmdlets but you are interested in WebSphere MQ, you might want to skip to the end of this post to see examples of what I’ve done in action…)

(more…)

TinyURL plugin for Windows Mobile

Tuesday, August 7th, 2007

I was surprised by the reaction to my del.icio.us plugin for Pocket Internet Explorer – between my blog post and the download page, I got something like 70 links and over 1,000 downloads in a couple of weeks. Wow.

If I’d known so many people would read it, I might not have made the blog post quite so moany 🙂

I got emails asking for versions of the plugin for their own favourite web service, but had to leave it for a bit because something else came up. Now I’m back, I thought I’d give one a go.

I’ve started with my next most used web service: TinyURL.

If you’re not familiar with it, TinyURL turns long web addresses into shorter, easy to share ones. It’s particularly useful when you’re trying to cram a link into a 140 character twitter update!

And – similarly to del.icio.us – using it on the Windows Mobile web browser is fiddly and long-winded. So here is a plugin for Pocket Internet Explorer to help.

It adds an entry to the Pocket Internet Explorer menu that gets a TinyURL for the webpage you are looking at, copying it to your clipboard so you can paste it into an SMS, email, tweet, IM message etc.

As always, anyone is welcome to give it a go – and any feedback would be gratefully received. It should run on any Windows Mobile 5/6 device, shouldn’t need any pre-reqs, and you can download it for Pocket PC (touchscreen) or Smartphone.

Read on if you are interested in a bit more ramble about how it works. 🙂

(more…)

Why doesn’t Windows Mobile have a mobile Notepad?

Saturday, August 4th, 2007

I’ve been relying on my PDA quite a bit while I’ve been travelling, and it’s frustrating when you have a file that you can’t open. MS Word on Windows Mobile is an okay text editor, but it’ll only open files with extensions like .doc .rtf .txt and so on.

I don’t want anything fancy – just the ability to view and make minor edits to text files! If I get emailed a file with an obscure extension, want to make a quick tweak to a settings or config file, view the source of something like a webpage, or anything like this, I’m basically stuck. You can’t click on them – you just get an error message that no application is associated with them. You can’t change the file extension to something MS Word will open because the Windows Mobile file explorer hides file extensions (you can rename files but not change their extensions).

My Internet access is a little limited at the moment so I’ve not had a chance to search if this has been done already – I figured it’d be easier to throw together my own version. It’s basically a TextBox control with File-Open and File-Save dialogs bolted on the front. It only took about 20 mins to write, and (as I’ve already got .NET Compact Framework 2) it’s very lightweight.

If anyone else thinks they might find it useful, you’re very welcome to give it a try. If anyone has any recommendations for lightweight Windows Mobile text editors, it’d be interesting to hear what people like.