Another technology blog...

Connecting to SQL08 on Windows 7 from a remote machine

Monday, December 14, 2009

I’ve got both a desktop and a laptop running SQL08 Developer Edition on top of 64 bit Windows 7 which until today, did not play nicely together. I could not get a remote connection from Visual Studio or SQL Management Studio to the other machine nor could I make an ADO.NET connection. Every attempt to connect resulted in a lengthy delay followed by a message such as the following from SQL Management Studio when trying to register the server:

“Error connection to [machine name]”

“A network-related or instance-specific error occurred while estblishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 1909”

In case you’re wondering why I would want to establish a remote connection to a desktop machine, it’s to run SQL Data Compare against the same project for which work has been alternating between different machines and I want to synchronise the data.

References

First of all, the answers are all out there already, I just had to try a number of them before things began working as expected. Pinal Dave sums up common causes pretty well in this post with lots of illustrated examples of probable causes. Given the Windows 7 / SQL Server combination is probably a pretty common one I thought I’d give a cut down version specific to this configuration here. Both my installations were essentially out of the box configurations (albeit with some components excluded) so my experience should be broadly relevant.

Ensure TCP/IP Connections are enabled

By default, my instance was disallowing TCP/IP connections. Fire up the SQL Server Configuration Manager and make sure the TCP/IP protocol in the SQL Server Network Configuration section is enabled. If it’s not, you’ll need to restart the SQL Service after you turn it on.

 TcpIp

One word of caution on this; I set both the SQL Server service and the SQL Server Browser service to require a manual start on the laptop to conserve resources unless absolutely necessary. However if the browser service is not enabled, the TCP/IP setting is lost on reboot. I ended up enabling the browser service (which has a very small resource footprint) but leaving the SQL Server service on manual. Problem solved.

Configure your firewall

This one is probably obvious and disabling the firewall completely (only for testing purposes, of course) was one of the first things I did but it only works if TCP/IP connections are enabled which mine weren’t to begin with. First up, open the “Windows Firewall with Advanced Security” settings (Windows key, “Firewall”):

Click on “Inbound Rules” in the left column then choose “New Rule…” from the top of the right column which will have just appeared.

firewall1

Choose “Port” as the rule type then continue to the next screen.

image

By default, SQL Server talks over port 1433 so unless you’ve changed this, enter it into the “Specific local ports” field and continue.

image

Obviously we want to allow connections over this port so accept the default and proceed to the next screen.

image

You can choose to lock the rule down to a specific profile but for my purposes I’m happy for it to be accessible across Domain, Private and Public.

image

Finally, give your rule a name and finish up.

image

Summary

Pretty easy once you know where to look! Unfortunately for me, once I finally got the machines talking to each other SQL Data Compare told me it couldn’t do a comparison because version 6 doesn’t know what a SQL08 Date type is! Other than that though, it’s been a successful little exercise.


Share/Save/Bookmark

The black art of splitting a Subversion repository

Saturday, December 12, 2009

Here’s the scenario; you have a Subversion repository that has been doing some multitasking. For whatever reason (convenience, laziness, ignorance), the one repository was used to store multiple projects and having now seen the light you want to split it out into separate repositories. This is entirely possible but it takes a bit of work and in many cases, quite a bit of trouble shooting (the kind you won’t normally find in the SVN books). I’ve done this a number of times recently and learnt a lot in the process so I thought I’d capture this info so that hopefully others can avoid some of the pain I’ve been through!

Background

We’ll assume we have a single repository with a folder in the root called “Websites”. This folder then contains multiple projects each in their own folder named after the particular project. For the purposes of this post we’ll assume the path is “ProjectPath”. During the lifecycle of the project it may have been moved around between different folders or even had content from other projects moved into it.

Process

There’s a three step process involved in splitting a repo:

  1. Dump the source repository
  2. Filter the dump to extract the project
  3. Restore the filtered dump to a new repo

In a perfect world we’d simply do all of this in one go but unfortunately it’s a bit more involved than that. It needs to be done in the three steps and it all needs to happen from the command line using svnadmin.

Dumping

Creating a dump of a repo involves svnadmin enumerating through the revisions in the repo and extracting it out into a dump file. An important point to make clear right now; Subversion is very efficient in terms of the repo compression algorithm it uses. A dump file is pure uncompressed plain text (expect of course for any binaries it contains). The bottom line is to ensure you have plenty of free space available on the drive you plan on using for this process.

To do the dump we’re going to use the dump subcommand. The syntax for this looks like the following:

svnadmin dump REPOS_PATH [-r LOWER[:UPPER]] [—incremental]

The lower and upper bands are quite handy if you only want to take a particular range of revisions from the repo. This can make the process quite a bit faster and consume a lot less space so if your project only occupies a small window of time in the repo history then try and use these switches. The particular project I’m going to use has revisions spread out over pretty much the entire revision history so I’m going to leave these out.

image

Depending on the size of your repo, you could be in for a long wait but at the end of it you’ll have a file called Websites.bak containing your entire repository history.

Filtering the dump

This is the first step where things can start to go wrong. What we need to do is to try and extract just a portion of the dump to create a brand new dump and we can do this by either taking the white list approach and explicitly including paths or the blacklist approach which means excluding paths. Either way, we’re going to use the svndumpfilter command to specify the filter approach, the dump we just created, the dump we want to create from the filter and one more parameter I’ll explain shortly.

 image

When the dump is filtered, there are going to be revisions where “ProjectPath” doesn’t have any changes because it was related to another project in the same repo. The “—drop-empty-revs” switch ensures that if there were no changes to “ProjectPath” in the revision then there will be no records in the dump. It sounds like this will create gaps in the revision history and this is true for the dump file but the gaps will be filled when we load it back in later.

Here’s where is gets tricky; 9 times out of 10 this command will run fine. Where it goes wrong is if your project has moved around a bit. The path named “ProjectPath” might be valid no but what if it was renamed at some time? Or moved to another root path in the repo? Or files from another path were moved into it? Remember the command above only included revisions in the “ProjectPath” folder. Here’s what happens:

image

Getting the filter right

The skipped revisions are there because we added the drop switch to the command. Further up this screen grab the filter was happily extracting revisions found in the included path until it came across a reference in revision 359 to a path that wasn’t included. This is why we see the “Invalid copy source path” error. What we need to do is add this path so it will be included in the filter.

image

You may need to go through this process multiple times. I had to do it half a dozen times on a project recently and unless you know ahead of time what all the referenced paths are (unlikely with a large project spread out over a number of years), it’s just simple trial and error to discover them.

Loading the dump

So now we have a dump which has successfully filtered every revision within the “Websites\ProjectPath” folder (and of course, the other paths the project may have occupied before that). The next step is to load this into a brand new repository which in my case I’ve called “ProjectRepo”.

Back to the svnadmin command again but this time with the “load” subcommand. The first thing we’re going to do is to use the –ignore-uuid command. This is important because the unique identifier of the original repo is going to be different to that of the new “ProjectRepo”. Next we’ll just specify the repo we want to load into and the path of the dump file.

image

What this command is going to do is step through the dump, revision by revision, and restore it into the new repo. You can actually watch this as it goes; open up your favourite repo browsing tool and whilst the load is running you’ll see the project being gradually reconstructed in chronological order with sequential revision numbers (no empty revisions). Until you hit another error…

image 

Fixing the dump

This is the second point where things can start to go awry. Most times the load will be a smooth process but as with the missing paths error above, a repo that has moved around a lot may well end up with errors.

Let’s look a bit closer at this error: “File not found: transaction ‘0-1’, path ‘Websites/ProjectPath’. To understand what’s going on here we need to get our hands dirty and start looking inside the dump file.

imageBecause the dump file is uncompressed and plain text (except for any binary content, of course), it’s easy to open it up in a text editor (I usually use Notepad++). When you do you’ll notice the file is broken up into a series of commits, each with it’s own revision number (line 15 in the image on the right), commit message (line 22), author (line 26) and then a series of paths and actions.

The problem lies in the very first revision. What’s happening is that when line 33 is being executed, the path “Websites” does not already exist and this is why we’re getting the “File not found error” above. This transaction worked just fine in the original repository because the path had already been created in a previous revision but because the filter ran at a level lower than this the transaction which created the folder wasn’t included in the dump.

The fix is easy; we just need to rewrite history! This is actually a good thing because it will allow us to get the repo structure right. Ideally, the work should be in a folder called “trunk” at the root of the repository. What we’re going to do is change every occurrence of “Websites/ProjectPath” to just “trunk” with a quick find and replace. This way when the revisions are imported to the repo it will appear as if the structure was correct from day 1.

Rinse, lather, repeat

The missing paths problem is one which may occur multiple times in the repo. Unfortunately you don’t know how often or where until you run through the load process again and it fails. Each time you need to go through and fix the dump file as per the process again until everything runs without error.

image

Summary

This all ended up being a lot more difficult than I originally expected, largely because of the unexpected errors which continued to crop up, the volume of trouble shooting required and the long durations to dump, filter and load a very large repository. Lesson of the day; think very carefully about your repository structure early on because it can be a serious headache to reorder later on.


Share/Save/Bookmark

I’ve been undefined!

Tuesday, December 8, 2009

Tweets2 Just in case anyone has passed by in recent days and noticed the Twitter panel on my blog displaying tweets that are, well, inconsistent with my normal tweets, fear not! It seems the geniuses behind the Twitter webpart for the Blogger engine have made a small mistake in the JavaScript variable department.

In short, it appears an undefined variable is somehow inserted into a JSON request URL to Twitter and unsurprisingly, the Tweets of an undefined user are being requested. Surprisingly enough though, someone has actually decided that “undefined” is, for some reason, a sensible enough Twitter username to actually use on what appears to be a fairly active basis.

So here we are; undefined (AKA “Adam” based on his website) has unintentionally hijacked my blog’s Twitter feed! From his recent tweets it seems pretty obvious Adam has received quite a bit of attention from people confused by his sudden appearance on their blog. After all, the Blogger gadget in question is the one Google recommends for redisplaying Twitter feeds so I imagine there are a large number of people, inevitably often not technical, who are wondering what the hell is going on. It’s also clear based on Adam’s tweets he’s having a lot of trouble getting through to Google.

Here’s how to fix it

Easy; get rid of the Blogger gadget. This has happened before and with the issue surfacing again I’m not confident it won’t happen again. So let’s keep it simple and ditch the gadget. Fortunately the folks at Twitter have provided a very nifty mechanism for adding  a Profile Widget to your website which is configurable via a browser based UI. Go through the steps, preview the widget then there’s an even an easy option to drop it directly into a Blogger based web log. Problem solved!

 image

For the record

Just in case someone from Google does finally decide to get proactive and fix the problem, here’s the Fiddler trace of what’s going on and where it all goes wrong. I haven’t dug any deeper into the source of the problem but a 404 on the .js in request 13 followed by an undefined variable seems very coincidental:

undefined


Share/Save/Bookmark

Building the ultimate virtual office

Sunday, December 6, 2009

I’m fortunate enough to work in a role which allows me to spend of lot of time talking to people in all sorts of places around the world on a daily basis. As much as I enjoy this varied communication, it plays absolute havoc with your working hours. It’s not so bad speaking to folks in the Americas (I’m a morning person!) and that works well for them but throw in a country somewhere between Sydney and New York and you always end up with a pretty inconvenient time for at least one or two parties.

All this has led to me spending a lot more time taking calls from home in part because of the odd hours but also because it allows me to work in an environment without the usual disruptions you get in an open plan office. On top of the usual work calls and out of hours business, I’ve found myself spending a lot more time researching and playing with emerging technologies lately, all of which has me spending more time in this environment. Given this, I decided to set out and build what for me is the ultimate virtual office. A lot of time and research went into getting everything setup just right so I thought I’d share the results in the hope that other people might find it a useful reference.

Environment

The first thing is I’m fortunate to live in a house that has a lot of space. I’ve got an attic area which is not part of a thoroughfare to other parts of the house and once the door is shut, is isolated from anything else going on downstairs. Having lots of space is not essential to a virtual office but it sure does give you more options when you come to designing one.

Research

Firstly, there are a heap of opinions out there on what works well and not surprisingly, not everyone agrees with each other! Having said that, I did start to see a couple of trends which have ultimately formed the cornerstone of my own virtual office. Some of the resources I found really interesting included a Shed Turned Home Office, Scott Hanselman’s Home Office and this pretty extreme example. See any similarities with these? Two things; lots of screen real estate and a very cool chair. In fact exactly the same chair in each example.

Chair

imageThis might not seem like a logical place to start, but the chair is quite possibly the most important item to go into any office, virtual or otherwise. Beyond just the fact that you spend a considerable amount of time sitting on it, the chair goes a long way to determining your health (particularly when it comes to RSI), your comfort and consequently your productivity. The other thing is the chair has possibly the longest lifespan of just about anything you put in your office. Having said that, it’s a question of quality. A cheap item from Ikea is not only going to expire pretty quickly (my previous one got a few years before it started falling about) but it’s also going to be pretty uncomfortable in the process.

This is where the Herman Miller Aeron comes in. This is as much a piece of art as it as a functional piece of furniture (Wikipedia actually says there’s one in the New York Museum of Modern Art) and it was a symbol of exclusivity during the dot com boom. Interestingly enough, I’m actually seeing a lot of them now on TV shows, being used by news readers and even by the receptionists in the office (not sure why we ended up with simple plastic ones…).It’s an extremely solid piece of furniture with many components such as the arms on the base of the chair being solid steel and not the usual plastic. Even the arms on the arm rests are solid and topped off by nicely padded, adjustable (everything's adjustable!) rests which are very comfy.

The downside with these is that they’re not cheap but it really is a matter of getting what you pay for. Given the amount of time I spend in it and the lifespan I expect it to achieve I decided to take the plunge and dive in. You can get them in a few different sizes to suit, shall we say, different “girths” and although the medium was a snugger fit I ended up going with the larger one which allows me to really sink back into it and even comfortably cross my legs on the chair. The beautiful thing about this chair is that no matter which way I lean or how I position my body it’s always comfortable. I can happily sit in this all day long without getting sore or cramped which is not something I can say for any other chair I’ve used before.

Couch

Ok, this is by no means mandatory office furniture but it has become a lot handier than I expected. It gives me the opportunity to change my working style without actually leaving all the office facilities or becoming distracted by external factors. I love being able to take the laptop over with me and work through a backlog of emails or get engrossed in typing a document whilst I’ve got my feet up. It’s just perfect for when you need a change of environment without breaking from the focus an office environment gives you.

Monitors

image There’s an easy rule of thumb here; the more and the bigger the better! Widescreen LCD monitors have gotten very cheap recently and the sweet spot of value versus features is going up pretty quickly. I found the 24” models are right on the money at the moment, so I got two. Other than the size and the price, the main thing that was important to me was height adjustability. I didn’t want to end up needing to jack up the height with monitor stands or arms; it just needed to work out of the box.

The other really critical thing is that it needed to support 1920x1200 resolution. The resolution is really important because at 24” you don’t want to be looking at massive pixels which is where you’d end up at traditional resolutions. Just to put that resolution in perspective, we’re talking about 2.3 million pixels multiplied by two monitors which is the equivalent of having six traditional 1024x768 monitors.

Samsung have got a pretty good range of monitors which are not only height adjustable but also have very good ratings for response times, brightness and contrast so I ended up getting two 2443BW models. The monitor also includes a built in USB hub which I don’t personally use but it’s always handy to have. The whole screen can also rotate 90 degrees which I’m sure could be very useful in some contexts but I don’t expect I’ll have a need to use it in the mode. Like most LCDs these days there are inputs for both VGA and the digital HDMI format and the box also included a VGA to HDMI converter so plenty of connection options are available.

imageThe next thing was making sure both monitors were usable simultaneously. There are heaps of studies and articles out there about multiple monitor productivity and it’s becoming unheard of for software professionals to just scrape by with a single screen. The trick is making sure the PC hardware can make the most it. My home PC was straight forward as I have a video card with two HDMI out connections so it was just a matter of plugging them in and letting Windows work it all out. The laptop was a little trickier though. In the office I use a docking station which has both a VGA and an HDMI out so I simply plug both those in to the two monitors at work but I didn’t want another docking station to be “docked” at home.

Fortunately Matrox has a really neat solution called DualHead2Go which is a little hardware device with a single VGA and a USB input and two HDMI outputs. This device can output two video streams of up to 1920x1200 each by tricking the host machine into outputting one massive video image (dependant on graphics card and driver version) then splitting it in two before sending the signals to the monitors. The USB connection then uses bundled software to give the machine a sense of what size each window is so you can do things like maximise your windows just to a single screen. Finally, the device can actually output the two 1920x1200 streams plus still use the built-in laptop screen of the same res so you can effectively have three screens totalling 5760x1200.

Desk

There’s really not a lot of technology that goes into a desk. The success Jeff Bezos has had using a door as a desk is proof you can reach great heights without being high tech! For me, the primary criteria was to have enough space without feeling cluttered. I needed to fit a couple of sizeable monitors, my laptop, phone, multifunction printer and have usable space for keyboard and mouse and still feel like I had plenty of free space. I was also aiming for a very light and airy feel so in the end I went for a white enamel item which included a primary desk, a return and some drawers. The return has actually worked out very well as it gives me a place to sit the laptop and use it simultaneously with the desktop.

Silent PC

image I didn’t realise how much of an issue fan noise was until I began rearranging the office and moved my home PC into a location that that directly above our bedroom. The low frequency vibrations that fans put out tend to resonate through floors and become quite audible while lying in bed so something had to be done about them. In a quest to remove and replace the noisy culprits I ended up replacing the two 80mm fans on the front of the case, the 80mm one on the back and the entire power supply. After all that, I accidentally snapped a pin on the CPU when trying to replace the heatsink fan and to cut a long story short, I ended up in a vicious cycle of replacing interdependent components (or others that were just too old) until I had an entirely new motherboard (with no fan this time), CPU (with a super quite, gigantic heatsink fan), graphics card (with no fan) and RAM. Basically everything but the case and the drives!

What I learnt about making a PC silent was quite interesting. There’s an entire site called Silent PC Review dedicated to the art of eliminating noise. The crux of making a PC silent is to use larger, lower revolution fans with high quality bearings and to use dampers between any moving devices and the mounts to the case. To that effect, when I ordered the fans I also order siliceous sheets which are essentially moulded pieces of silicone which sit between the fan and the case and act as little dampers. The Noctua fans I bought also came with rubber mounting pins instead of the usual plastic ones so noise or vibration transfer through to the case is absolutely minimised.

Speakerphone

imageOne thing I do a lot of is talking on the phone. Unfortunately not so much in the social sense but very frequently on teleconferences and often for an hour or more. Handheld phones are simply too uncomfortable for this style of working, especially when meeting participation can often be a passive task and you want your hands free to do other things. The other thing is you really need a mute button out of courtesy to other meeting participants so that when you’re not talking you can type, answer your mobile, have noises going off in the background or whatever else without being an inconvenience to everyone else.

I looked at a lot of different speakerphones but kept coming back to the Polycom Soundstation. You’ve probably used these in meeting rooms before and they’re almost the de facto standard for voice conferencing. Unfortunately they’re not cheap when they’re new but there are plenty of them on eBay and I managed to pick one up for not much more than a tradition style phone with speaker capabilities.

VOIP communication

imageIf you’re not using VOIP in some fashion then the chances are you’re paying too much for phone calls. As much as I like the idea of VOIP though I don’t like the idea of being tied to my computer nor do i like the idea of having one phone for landline (I still want to at least receive phone calls over PSTN) and another for IP based discussions. Fortunately there are a few “dual phones” out there where the base connects to your analogue phone line and either to your PC (which then runs a client) or directly to your wireless router. I ended up getting some cordless Dual Phones which consist of a base then several satellite phones with charging bases you can distribute around the house. As it turns out, they’ve all broken (yep, all three of them) but the concept is very good and I’m sure I’ll find another hardware manufacturer that does a decent job quality wise. Great concept, just poor execution by this particular manufacturer.

Ergonomics

imageMost people (myself included) only begin to think about ergonomics after they begin suffering from working in an ergonomically unsuitable environment. I began getting tingling in my fingers which would then go all the way up my arm and become quite painful. I ended up getting some physiotherapy which included giving me exercises and stretches which helped but the biggest change I made to my working style was to get a decent keyboard and mouse both in the office and at home. These are such simple, comparatively cheap devices and they can make a huge difference to the way you work. If you’re like me and regularly spend the whole day (and often night!) in front of the computer then take a look at the Microsoft Ergonomic Desktop 7000. This is widely considered the equipment of choice by those in programming circles and has almost completely reversed my RSI symptoms.

Audio

image More than just making beeps and alerts, I use my audio setup pretty extensively for watching video content and very regularly for listening to music. This isn’t everyone’s cup of tea in an office environment but I like having the option to pump out something that suits my mood. I already had a Logitech Z-5500 which is a pretty typical high-end PC setup. One thing I really like about it is that it has an optical in which I can drive from the PC plus a standard analogue audio jack I can plug into the laptop or iPhone as required without disrupting the PC setup. You can then select the input source as well as control the volume from a desk mounted control unit which is really neat.

Multi-function printer

image These are literally a dime a dozen now and are very handy little devices. The Canon PIXMA MX700 I got was only a couple of hundred dollars and is a colour scanner and copier (both with automatic feeder so you do stuff in bulk) as well as a fax and a colour printer. The other really neat thing about it is that it’s network attached so there’s no dependency on sharing it through a PC. It’s just always there and always on independently of any other devices.

The only complaint I have of it is that for some reason I can’t set the fax to allow more than five rings before answering which is leading to a lot of running around the house when the phone rings (shared phone / fax line). I think I’ll just bite the bullet and call tech support or even just unplug the phone line; who sends faxes these days anyway?!

Cable management

imageThis is going to sound like I’m a bit fussy but I hate it when you end up with cables all over the place. At last count I have 18 separate devices all plugged into power and easily double that many other cables so there is a lot going on under the desk. The easiest way I found to get everything properly organised was to buy a few cable trunking devices from Ikea which you can then mount up under the desk and run the cables through. It’s a neat design with lots of little wire “fingers” sticking out from the edges so you can drop cables off or join them back to the trunk at any point. Once it’s all set up it means you can pretty much secrete everything up under the desk and not need to look at it on a daily basis. Of course if you get under the desk and see what’s going on it’ a bit of a nightmare but I tend to avoid doing that!

The end result

In the end the whole process took longer and cost more than I expected but I’m very happy with the result. I’ve now got an environment I can comfortably sit in for hours on end in peace and quite with everything I need to be super effective right at my fingertips. My biggest problem now is making sure I make a conscious effort to get out of the office and enjoy the beautiful Sydney weather!

Here’s how it all turned out:

IMG_7110

IMG_7107

IMG_7111


Share/Save/Bookmark

Disclaimer

Opinions expressed here are my own and may not reflect those of my employer, my colleagues, my mates, my wife and so on and so forth. Unless I’m quoting someone, they’re my own opinions and may not necessarily be cohesive nor entertaining but hey, at least they’re original!