June 2011

I started my blog back in December 2010 and it's still going strong. I've posted at least once post a month since then, so feel free to browse through the archives.

Fix for Italic Fonts in Windows Command Prompt

I kept getting a problem where the Consolas font was in italics on when using either CMD or PowerShell on Windows 7.

After messing around with lots of options, I actually ran a repair on the Office 2010 installation I had. It worked. I’m not exactly sure why this is the case, but if you’ve got this problem – you might want to try this too.

I know Consolas ships with Office 2010, so maybe the repair just makes sure the font files are installed correctly. If anyone knows the real reason, please feel free to leave me a comment!

Sharpie Pen & Liquid Pencil

We all know and love the original Sharpie marker. It’s an absolute modern classic, but what’s more interesting is the addition of the Sharpie Pen, and the Liquid Pencil…

Sharpie Pen

I only recently got the Sharpie Pen Retractable, but already I like it. True, the barrel is a little fat which tends to make the very fine tip look a bit funny, but overall the experience is good. The ink seems to be very nice and does not bleed through my Post-It notes. Though I do worry that the ink will dry out, and I’ll have to wait and see if this is the case…

I have noticed that there is a slightly updated version of this pen on the Sharpie website, I think I may prefer the newer barrel design, but I don’t think there’s going to be enough in it for me to get one just yet.

Sharpie Liquid Pencil

The Sharpie Liquid Pencil (which I believe may now be discontinued) uses a liquid graphite ‘ink’, which writes like a pen, but is erasable like a pencil. The idea is that you’ll no longer have any broken leads, or something. I think the idea is just to reinvent a classic in a whole new way. A bit like technology… for the sake of technology.

I’m so glad I have this pencil – the idea is very cool, even though the execution is a little off. Unfortunately the lines come out blotchy and not very consistent… but bonus points are given because of the cool technology inside. Though the truth is that I always gravitate back to my real mechanical pencil after using the Sharpie Liquid Pencil a short amount of time.

Above all, Stanford has shown us that Sharpie is capable of being much more than just a marker. They have probably played a slightly safer move by adding these risky and experimental products to a brand that is seen as cool by the younger generations anyway, and as far as I’m concerned they can keep doing this – even if the product doesn’t turn out as well as hoped. I think this is especially important for an American brand, as the Japanese seem to excel at this naturally.

Update…

While the Sharpie Pen started out well, the more I’ve used it the less I’ve liked the barrel. It’s too fat and and the rubber grip is too solid to be worth having. The ink is still very good though!

Outlook Tasks in PowerShell and Vim

Getting Outlook Tasks in PowerShell is actually pretty easy. All you need to do is use the Office Interop to get access to the default tasks folder, then iterate through the items that are returned.

Create a file called Get-OutlookTask.ps1 in your scripts folder, and paste the following code:

Add-Type -AssemblyName Microsoft.Office.Interop.Outlook
$folders = "Microsoft.Office.Interop.Outlook.OlDefaultFolders" -as [type]
$outlook = New-Object -ComObject outlook.application
$mapi = $outlook.GetNameSpace("mapi")
$tasks = $mapi.getDefaultFolder($folders::olFolderTasks)

foreach($task in $tasks.Items)
{
  if(!$task.complete)
  { 
    $task.subject 
  }
}

Naturally, you could customize this script to work any way you like – for example, you could sort by priorty or date, or you could show an extra column for category information. I have actually set up an alias to this script, so all I have to do is type tasks to see all my current tasks.

If you have set Vim to work with PowerShell, you can import your Outlook Tasks directly into the open document by using the Vim command:

:r! tasks

Pretty cool huh? If you’re looking to add Outlook Tasks in a similar way, you can check out this script by Lee Holmes. I use this one with the alias of nt to save on all that extra typing.

If you want to be able to add Outlook Tasks from Vim, I suggest you add the following function to your vimrc file:

function! Task(args)
  system("nt \\\"" . a:args . "\\\"")
endfunction

command! -nargs=1 Task :call Task('')

Now you just need to call :Task buy milk and it’ll get added – without switching to the shell itself.

Writing and Running F# Scripts with Vim

When I’m writing software for the .NET Framework I tend to have a copy of F# Interactive open. This lets me run commands directly like so…

This is fine for simple stuff, but if you’re writing something a little more complex it’s better to write a script. In the past I’ve done this by having another copy of Visual Studio open and running the script that way. This works really well, and includes colour coding, intellisense and all the other good stuff you expect.

However there are times that having yet another copy of Visual Studio is a little heavy for just keeping track of a script. Enter Vim, the de facto command line editor for Unix and other operating systems.

  1. Set up Vim to work with PowerShell
  2. Grab yourself a copy of the F# Syntax file
  3. Save it into your Vim plugins directory
  4. Add the following lines to your vimrc file…
au BufRead,BufNewFile *.fs set filetype=fs
au BufRead,BufNewFile *.fsx set filetype=fs

Now when you create a .fsx file, you can run it directly from F# Interactive by using Vim’s shell execution feature.

:!fsi %

This will run your script in F# Interactive and present you with the results. The :! Vim command is for running the external program, and the % represents the filename of the currently open document.

Note that you’ll need to have set up F# Interactive by either adding it to the path or setting an alias in PowerShell. If you haven’t done this already, you can do it by adding the following lines to your PowerShell profile:

$FSIPATH     = "C:\Program Files (x86)\Microsoft F#\v4.0\Fsi.exe"

Set-Alias fsi  $FSIPATH

Setting up Vim to work with PowerShell

As an avid console user, I like being able to edit text without opening an interface that requires a mouse. For me this text editor is Vim – the extremely well regarded editor that ships with a very large number of operating systems.

My command line of choice is PowerShell, and I set up any extra commands to live in a Scripts directory inside my Windows user directory. If you’d like to do this you need to download Vim to the Scripts directory, then edit your PowerShell profile to include an alias so you can access Vim from any directory you might be in, as well as a couple of commands to make editing common files even simpler.

# There's usually much more than this in my profile!
$SCRIPTPATH = "C:\Users\Julian\Scripts"
$VIMPATH    = $SCRIPTPATH + "\vim73\vim.exe"

Set-Alias vi   $VIMPATH
Set-Alias vim  $VIMPATH

# for editing your PowerShell profile
Function Edit-Profile
{
    vim $profile
}

# for editing your Vim settings
Function Edit-Vimrc
{
    vim $home\_vimrc
}

Then you need to set Vim up in the way you like it, there are lots of sites with suggestions for how to set your vimrc file, but for now I’m just going to suggest you add a link back to PowerShell by adding the following lines:

set shell=powershell
set shellcmdflag=-command

This means that when you run the :shell command in Vim, you will actually use PowerShell itself to run commands, including all the aliases you set in your profile. I find this especially handy for writing and running F# scripts, as well as task management with Outlook – both of which I’ll write about in posts this week, but you can test this out now by running :sh or :!get-childitem | more and seeing what happens!

Storing my Pens and Pencils

I really like pens, pencils, and pretty much all the cool stationery, but I also like to keep things organized – so I have one bag which is dedicated to my artwork and stationery collection which has built up over the last 10 years or so.

The bag itself is a Toshiba laptop bag, with lots of little organization pockets on both the inside and on the front, a section for papers and other things, and of course the main laptop compartment.

Inside the bag I keep a number of pencil cases, some tear-out paper books, a folder of drawings, a couple of Moleskines and a Toshiba R400 Tablet PC.

The Tablet PC lets me draw directly on the screen, which I mainly use for producing cartoon-like graphics (I should totally post some!) and any other photo retouching work. I’m actually really fond of the ink support in Windows 7 and I love using the Wacom ‘penabled’ digitizer to produce pressure sensitive lines.

The black pencil case on the far left contains mostly pencils. There is a set of Watercolor pencils, a set of various grades of lead pencil, and some brushes for when I fancy mixing the colours. Pretty much everything in this pencil case is from WHSmiths.

The two denim Edwin pencil cases contain a wide selection of pens, too many to go through in this post, but I’ll write a follow up on some of my favourites in the future. The larger of the two also contains some spares I’ve purchased – for example I have a couple of Sailor Ink Bar pens which are unfortunately no longer being produced. These pens are sourced from a number of places including Cult Pens and JetPens and random shops I’ve found in the UK.

The two red Nomadic pencil cases are home to my favourite art pens, the supplies I usually need when doing any arts and crafts, and all the spare leads for the various pencils I use for drawing. I’ll definitely write a post about these two soon.

But that’s not even everything… you can also check out the contents of my favourite pen collection, and I’ll be sure to write some more posts in the future which will detail some of the most intersting pens, including why I like the Kuru Toga and Jetstream ranges so much.

I know I have a bit of a pen addiction, but I’m not the only one. Brad Dowdy from The Pen Addict has set up an IRC channel on irc.freenode.net #penaddict. Feel free to drop by to our ‘help group’ with your IRC client of choice, or via your web browser.

New Moon in June 2011

I took this photo the new moon the other night, rather pretty looking I must say.

And again, the same photo just a little bit closer so you can see the detail.

Oh and while I was at it I thought I’d take a cheeky photo of Saturn! Does make me wish I had a telescope… one day I will!

Until then I’ll just have to make do with my Canon 7D.

Update…

Check out the full version of this photo on Flickr.

Windows 8 must have a .NET story for the new UI

On one side, I’m excited about the prospects of HTML5-based applications coming to the new Windows 8 user interface which was revealed yesterday. But this has to be only part of the story. Would Microsoft alienate all their existing developers just to go for the next big thing?

The issue comes to play when you think about the current platforms. Many Microsoft developers have spent a long time learning in the WPF and Silverlight user interface frameworks. On this side of the fence things look rather bleak if, especially if you’re currently investing time and money on Windows Phone 7 application development.

But what’s the actual deal? Why are people so worried?

Julie Larson-Green: Today, we also talked a bit about how developers will build apps for the new system. Windows 8 apps use the power of HTML5, tapping into the native capabilities of Windows using standard JavaScript and HTML to deliver new kinds of experiences.

This sounds like it’s the only option for making apps for the new system. Yes I know this is a limited snippet, but there doesn’t seem more information than what is provided here.

We’ll find out for sure at the BUILD conference in September… but from my view they must have a .NET story for the new UI – they’ve invested far too much into the whole .NET ecosystem to not have it running on future tablets.