Tuesday, November 03, 2009

Boost Spirit 2.1

I'm very impressed by what Joel, Hartmut and the rest of the folks have done with the 2.1 release of Spirit.  The syntax has been improved, the code is much neater and more powerful – bravo guys! 

If you use C++ and have a need for a parser do yourself a favour and check out Spirit.

Spirit 2.1 will be in Boost 1.41.0, which is due for release any time now (it's currently in beta).  Until then you can read the pre-release documentation.

Wednesday, July 08, 2009

CppDepend

Geektastic!  The company that develops NDepend, the sensational source code analysis tool for .NET, has just released a C++ counterpart.  I intend to spend a great deal of time analysing our code with CppDepend.  Available for free as a beta. 

[Via Kate Gregory.]

Saturday, May 23, 2009

VMWare Server 2 Remote Console and Synergy

I've got VMWare Server 2 install on one of my machines here and I was trying to use the Remote Console (which installs as a Firefox extension) to connect to a Windows XP VM I was creating.  But no dice.  The keyboard and mouse inputs were not being redirected to the VM.

After trying a bunch of things I stumbled on turning Synergy off.  Voila, the mouse and keyboard works as expected.

[Incidentally my recommendation is to use the Synergy+ client; the original Synergy client appears to be pretty much abandonware and the Synergy+ folks are doing a great job at fixing bugs.]

So there's my tip of the day:  If you find your keyboard and mouse not working as expected with VMWare Server 2's Remote Client take a took in your system tray.  If Synergy is running turn it off and see if Remote Client responds.  Worked for me!

Monday, April 13, 2009

Code Snippets for C++ in VS2005

Visual Studio 2005 introduced the concepts of code snippets. Handy little chunks of commonly-used code that are easily inserted to your own with some Intellisense magic. Hit a keypress, choose the snippet, fill in any fields and voila.

C# and VB users were spoilt; MS supplied a bunch of snippets to do many common tasks. Iterating over containers, creating regions, defining classes…many common tasks were snippetified. Further, there were many more online.

Alas, C++ users were left in the dark with no snippet support at all.

Thankfully the release of the "Microsoft Visual Studio 2005 IDE Enhancements" addressed that issue (also known as the VS2005 "Powertoys"). After installation you get – among a few other questionably useful tools - C++ snippet support in VS2005. There are only two problems. 1) If you're using Vista you get a bizarre error 1 when you try to run the installer. 2) You don't get any C++ snippets installed. Instead Microsoft makes the C# snippets available in C++. Thanks guys. Anyway, let's address those problems.

1) The issue here is that Vista requires administrator privileges to install this package. Had the install package been an exe we'd have been fine; shift-right click and select "Run as Administrator". Alas it's an MSI so we'll have to find another way. The simplest, as described by the MS UK Dev Team, is to fire up a command shell, running it as admin (open the start menu, type 'cmd' then shift + right-click the cmd.exe icon), change to the directory where you downloaded the PowerToy installer then execute the command:

msiexec /i "VSSDK_PowerToys.msi"

Then follow the GUI installer as normal. Oh, you'll need to exit from all VS2005 instances.

[You may notice – well, I did – that Visual Studio will have a bit of a conniption fit when you restart. It appears that it's setting itself up for the first time again. Not sure why. Thankfully all my keybindings etc remained intact and there were no noticeable problems but YMMV.]

2) Once everything is installed correctly you should find that the "Tools->Code Snippets Manager" should now have "Visual C++" listed as a language. Good sign. However by looking through the supplied list of snippets you'll find they're all actually C# snippets. You'll want to write your own C++ snippets. To do that you'll need a snippet editor since writing the XML by hand is tedious (far from impossible but annoying).

Of the bunch of tools I found that edited snippets only Snippy supported C++ snippets. Snippy works fine but doesn't seem to have a binary distribution so you'll need to download and build it (a VS2005 solution file is supplied). After you run it create your own snippets and save them somewhere (like "Users\YourName\Documents\Visual Studio 2005\Code Snippets\Visual C++\YourSnippets"). You can then add those snippets to VS2005 using the Snippet Manager.

I haven't discussed the format of a snippet, it's pretty easy to figure it out from Microsoft's documentation. But here's one to get you started. If people ask nicely I'll try and post more.

And that's it! Now you should be ready to create your own wicked-cool C++ snippets. Let me know if you have any rippers!


1: The error is something like: "Error 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor." I love how the error makes it so clear that administrator privileges are required.

Wednesday, April 23, 2008

Code Camp '08

Once again I'm going to miss Code Camp.  Too many other things going on (holiday to book, birthday party x 2, BBQ Friday, gathering to go to Sunday) to justify heading away for three days to geek out.  In other words my girlfriend will be über cheesed if I go.  ;)

Have fun if you're going!  Wish I was there too.

PS I've got a plan for next time.  I'll present on some topic - that'll be way easier to sell to my SO than if I'm just tagging along...

Friday, April 11, 2008

Building Boost 1.35

I'm a big fan of the boost library for C++ development.  They're incredibly well designed and implemented, generally cross-platform, and quite well documented.  In short, they're awesome.

However, I regularly have issues building them (on Windows with the VS2005 compiler).  Thankfully I'm not alone.  Kevin Heifner ran into the same problems I did when trying to build the recently released 1.35 and documented a work-around.  Thanks Kevin!  It worked a treat.

The summary is that the Boost Consulting group, who usually put together a nice installer, haven't yet published one for 1.35.  Further, following the instructions on the Getting Started page that describe how to build boost led me astray.  With hindsight I think the major problem was that the "stage" directory mentioned in the example needs to be created before the build commences.  Anyway, Kevin provides an alternative set of command line options for bjam:

cd "C:\Program Files\boost\boost_1_35_0"

bjam --toolset=msvc --build-type=complete --prefix="c:\program files\boost\boost_1_35_0" install

Then just configure your projects Additional Library Directories to include "C:\Program Files\boost\boost_1_35_0\lib".

Friday, April 04, 2008

Wireshark matures; v1 is released

Wireshark, formerly called Ethereal, has made it to the 1.0 milestone. Congrats to Gerald Combs and the team. Wireshark is an amazingly useful application that helps analyse network traffic.


As a software engineer it's an invaluable part of my toolkit and I'm very grateful for the many folks who work on this wonderful open-source (GPL) application.



Internet Sharing: Mac to Windows

Sharing an Internet connection from your Mac is trivially easy:

  • Open System Preferences
  • Choose Sharing
  • Tick the Internet Sharing checkbox

Typically I share out my wired Ethernet connection over wireless (Airport in Mac parlance).

InternetSharingMac.png

You'll need to configure the Network Name (the SSID) and the encryption settings. Unfortunately WPA is not yet supported so your best bet is 128 bit WEP. You'll also need to choose a 13-character password if you want Windows computers to share your network (if you're network only has Mac's then feel free to choose any length password).

InternetSharingMacDetails.png

Connecting any Mac to this network is trivial. Simply turn on AirPort, browse to the network and enter the password.

Unfortunately, from a Windows PC it isn't quite so obvious - you can't just auto-detect the network and enter the password. You'll need to perform the following steps:

  • Open Control Panel, Network Connections and click on Wireless Connections
  • Add a new wifi network
  • Enter the Network Name that you created on the Mac - it must match exactly
  • Set the Network Authentication to Shared
  • Set the Data Encryption to WEP
  • Uncheck "The Key is Provided Automatically" and enter the 13-character password that you chose earlier

You should now find that the Windows PC can connect to the network.

If you're using a wifi manager other than the standard Windows functionality then you may need to experiment on the various settings. One manager I had to configure wouldn't work until I chose Enterprise as a network type.

I'll try and get some Windows screenshots soon (my VM doesn't have a wireless connection).

Hope that helps someone!

Tuesday, April 01, 2008

Google Docs goes offline

Google Docs has just gained the ability to go offline. This makes the simply office suite significantly more useful as you no longer need to be tethered to an Internet connection while editing your documents. Naturally they've used Google Gears to implement this. Mental note: Get up to speed on Gears!

My Google Docs doesn't yet reflect the feature but I presume it's rolling out through all the Google servers as we speak...

Friday, December 07, 2007

Google Chart API

Google have just announced their Chart API.  This is freakin' awesome!  Anyone can now embed charts into their web pages (yes, even your blogs!) by whacking in a well-constructed url.

Here's a quick chart I whipped up that shows average maximum temperature for each month:

Nice, eh?

Friday, November 16, 2007

Don't share intermediate directories

OK, I've been bitten by this issue twice.

Take care when setting the intermediate directory (Project->Properties->Configuration Properties->General->Intermediate Directory) for Visual C++ projects.

If you have multiple projects that use the same intermediate directory you are likely to run into problems. 

Specifically, if you're using a multi-core machine to build projects that share an intermediate directory and those projects happen to build in parallel the second project will fail when it tries to delete the files in the intermediate directory.

One way to ensure this never happens is to set the intermediate directory to $(ProjectName)_$(ConfigurationName).

This is particularly nasty because if you create two vcproj's in the same directory this will happen with the default parameters.

Monday, August 20, 2007

My code's compiling...

The biggest problems with Moore's law and the power of PC's these days is that compilation time is constantly decreasing.


xkcd knows what I'm talking about...


Thursday, August 09, 2007

Mac Mini upgrade...finally!

Amongst the fanfare of the Apple iMac range overhaul I didn't initially catch that the Mac Mini has also been upgraded! I've been waiting for this for a long time so I can use one as a front end for my MythTV system.


Not only have the processors and RAM been upgraded (Core 2 Duo 1.83 or 2.0 GHz, 1Gig RAM) but the price has come down too.


Now is the right time to buy.

Tuesday, August 07, 2007

Firefly (aka mt-daapd)

Firefly is a wonderful implementation of a DAAP server. What is DAAP I hear you ask? It's an audio streaming protocol introduced by Apple to allow you to stream music from one PC to another over a network. In simpler terms it lets you host all your music on your server and play them through iTunes (or some other apps).

Unfortunately, the version of Firefly in the Ubuntu repositories is a little old and stopped working for me when I recently upgraded my iTunes. Upgrading it wasn't as easy as normal in Ubuntu so I thought I'd list the steps I took:

  • Uninstall the old version
    • sudo apt-get remove mt-daapd
  • Delete configuration files and the database as they appear to be incompatible (YMMV).
    • sudo rm /var/cache/mt-daapd/songs.db
    • sudo rm /etc/mt-daapd.conf
  • Download a recent build
    • wget http://nightlies.mt-daapd.org/dl.php?FILE=mt-daapd_0.9-svn-1586_feisty_i386.deb
  • Install package
    • dpkg -i mt-daapd_0.9-svn-1586_feisty_i386.deb

Now reconfigure Firefly. There's probably a much better workaround than deleting the config files and the database but Firefly is so easy to set up that it's not worth figuring it out!

Thankfully, I can now, once again, play my music through iTunes from my Ubuntu server.

Mac Defect: Samba mounting

I've found a workaround to what appears to be a bug in the OSX Finder. When you mount a network drive (over samba) sometimes the drive appears, then promptly disappears. Attempting to mount the drive again results in the error "Volume already mounted". Dang.

The workaround is to "Go to Folder" (Shift-Apple-G) and enter "/Volumes". You should find your network drive there.

Chicken of the VNC - Slow connecting to Ubuntu

Chicken of the VNC is undoubtably one of the coolest-named apps around. And, in most situations, it's the best VNC client on the Mac. But it has some serious issues when connecting to my Ubuntu (Feisty Fawn) server - it's slow to the point that it's unusable.

Twiddling with the various options doesn't make a difference. No idea what's causing the issue; if anyone can enlighten me I'd appreciate it!

In the meantime I use the venerable VNCViewer. It hasn't been updated in years but it connects to my server just fine (although it does drive CPU usage high).

Monday, July 30, 2007

dm_mirror and LVM's pvmove

To allow LVM's pvmove command to work you need support for dm_mirror in the kernal. Simply enter the following at a terminal:



modprobe dm_mirror



The error I received when I didn't have that module loaded was:



mirror: Required device-mapper target(s) not detected in your kernel



If you use LVM regularly you may want to add support for this at startup; there are a few ways you can do this but I choose to add to the modules list at /etc/modules. (Just use vim and add "dm_mirror" to the end of the file.) I'm on Ubuntu (Feisty Fawn) so YMMV.


BTW, for conveniance, there's no difference between "-" and "_" in module names. dm_mirror and dm-mirror are interchangeable.

Sunday, May 13, 2007

Ubuntu and MythTV notes

I've been wanting a particular server PC for a long time now; a PC that I could use to record TV, be the main storage area for all of my data (especially music and photos), remotely trigger downloads and perform backups from. Installation of this PC is well underway but I wanted to post about a couple of stumbling blocks I had in case others were having them (or unless I had to go through it again!).

Background: The two major software choices I've made were to use Ubuntu for the OS and MythTV for the TV recording. I've been very happy with both decisions; highly recommended.

The vast majority of users will find Ubuntu amazingly simple to install. I had a couple of slightly unusual requirements however...

I wanted to use a filesystem called LVM. The main benefit for me with LVM is that you can add extra storage space whenever you want. LVM abstracts the logical mapping of mount points from the physical hard disks and partitions. An example: Today I may have a mountpoint at /var/mydata and it may be mapped to a partition on my current 320 Gig HD. Tomorrow I could drop another 500 Gig HD in and add some (all if liked) of it to /var/mydata.

In the Windows world this would be like having a 320 Gig drive appearing as C:/ then adding another 500 Gig drive to it. [I've been told Vista has some support for this kind of thing - can anyone confirm?]

It's a very useful feature (and Unix OS's have had it since '98) particularly for a server where my storage needs are going to be ever-increasing.

Unfortunately there is a problem with LVM under Feisty Fawn, the latest version of Ubuntu. LVM, as installed when using apt-get, seems to be located in the wrong place. Thankfully John has written up a simple work-around. It may also be related to another defect with the libdevmapper package. Either way it's easy to fix with those two references.

Installing MythTV is remarkably easy under Ubuntu, just follow this guide. Unfortunately my capture card (a Leadtek WinFast 1000 - basically a bog-standard DVB card) didn't work straight-up. It wasn't being properly detected in the MythTVconfiguration. Turns out that for some reason I was missing a couple of required kernal modules. Again, hitting the Internet quickly gave me a pointer in the right direction. dvb_core and cx88_dvb were the culprits; adding them with the following commands:

sudo modprobe dvb_core
sudo modprobe cx88_dvb

solved the issue. Of course, resetting the PC would mean that these modules would be missing next boot so I also had to add them to /etc/modules.

They were the biggest stumbling blocks (though installing shepherd - a wonderful EPG for Aussies - took some trial-and-error!). I've now got a stable system that I can record TV (remotely if I like using MythWeb) easily. I've still yet to shift all of my data to the box nor are backups happening yet, but it's just a matter of time.

Check out Ubuntu and MythTV, I've had a good experience with both of them!

Wednesday, April 18, 2007

Google to release online Powerpoint competitor

Google just announced that presentation software will be added to their online Docs and Spreadsheets package "this summer". So it won't be long before they have all of the major building blocks that defined Microsoft's Office package - available from a web interface.

The really exciting part of this news for me though was that the software was acquired from a company called Tonic Systems. Tonic is "based in San Francisco and Melbourne, Australia"!
As a keen software dev in Melbourne I'm shocked and disappointed that I hadn't even heard about these guys...someone needed to throw me a frickin' bone here... ;)

[Although Tonic's webpage has been replaced by a Google announcement you may still be able to get at the old page - ironically - by using Google Cache.]

I'm really looking forward to using this application!

Thursday, March 01, 2007

Hotspotr - Community WiFi Cafe Hotspots

Hotspotr is a sweet mashup that displays cafe's with wireless using Google Maps.  It's community driven, so go enter more for Melbourne!