Tuesday, May 24, 2011

Finding active file in Vistual Studio 2010 solution explorer

I often use Ctrl-, (control comma) or another search variant to locate files when I'm working in Visual Studio 2010. Unfortunately, it often leaves me with a bunch of open windows and no easy way to navigate to the project, directory, or other tree area within my solution where the file actually lives. The pop up search box often gives the path, but it is still a nuisance to go expand a bunch of "+" signs to go find it. I knew there had to be an easy way.
As it turns out, there is. Visual Studio has an option (Tools > Options > Projects and Solutions > General) called "Track Active Item in Solution Explorer" that will automatically update the solution explore to hop to the file that is active.
The downside, of course, is that it ALWAYS does this. I originally found the feature via another post that tells how to create a macro to do this on-demand: [locate-file-in-solution-explorer-visual]. Now I just have to figure out how to add a macro to vStudio. :-)

Happy coding.

Wednesday, May 4, 2011

Working with XML and XSD schemas in Visual Studio

I recently started working with XML files as part of a SharePoint project I was working on in Visual Studio. As the project evolved, I started creating some crazy XML files that defined the structure of a SharePoint site. It wasn't long before the crazy schema I invented on the fly started become confusing. Worse, I started forgetting the structure of the elements I had invented and had to start looking through the source code that processed it to try to remember what the structure and options were supposed to be.

Better solution: Create an XSD file with the structure definition in it. Basically, I followed these steps.
  1. Reverse engineer the XSD from my XML file
  2. Annotate the XSD file with some documentation about what it all meant
  3. Add a reference to the XSD in the XML file
  4. Continue editing the XML file in Visual Studio
Reverse Engineering the XSD 
First step was to create an XSD. I didn't want to type it all by hand, so I found this link: http://www.dotkam.com/2008/05/28/generate-xsd-from-xml/. It referenced a tool called "Trang" which processes and XML file and produces an XSD. Download it here.

I created a simple batch file:
@echo off
: Batch file to invoke Trang to convert an XML file to a XSD
set JAVA_HOME=C:\apps\jdk1.6.0_20
set TRANG_HOME=C:\apps\trang
%JAVA_HOME%\bin\java.exe -jar %TRANG_HOME%\trang.jar %*
 Then I converted my existing XML file:
xml2xsd.bat myFile.xml schema.xsd

And it produced a reasonable XSD file that I could begin using. What's nice, is if you load this file into Visual Studio, it provides some nice tools for exploring and viewing your schema. (I have NOT found any good ways for actually editing the schema other than hacking on the XSD code.)

Annotate XSD Schema

Once you get the basic XSD file, it's nice to add some explanation to it. You can easily use the "xs:annotate" and "xs:documentation" elements to do that.

<xs:annotation>
<xs:documentation xml:lang="en">
Documentation about your element.
Hint: First line is shown as "documentation"
<xs:documentation>
<xs:annotation>


This allows you to self-document the XSD file so you can look at it later and remember what the hell you were thinking when you first made it. It also has the added benefit of showing up when you turn on "Show Documentation" in Visual Studio Schema Model view.

A quick note on Visual Studio: When you open an XSD file in Visual Studio, it shows you the "XML Schema Explorer." From there, you can select elements and "Show in Content Model" which allows you to expand elements and browse through your schema. There are other modes, too, but I haven't figured them out.

Add Reference to XSD in XML File

Once you have an XSD, it's nice to actually make use of it. You can do this by annotating the root element in your XML file:

<RootNode  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="MySchema.xsd">

This allows anything processing the XML file to actually find the XSD and determine whether your XML file is "correct."  In my case, my XSD file was in the same directory as the XML file, so I didn't have to post the XSD anywhere.

Continue Editing XML File in Visual Studio

After doing all this, you're back to editing your XML file. The nice side effect of all this in Visual Studio is that it activates Intellisense for XML editing. This means:
  1. It will suggest name completion as you start typing elements and attributes
  2. It will suggest elements and attributes that can be inserted in a location
  3. It will suggest errors when you type elements that don't exist
I immediately found that this helped me work with my XML files much more quickly without creating bad formatting errors.

Wednesday, February 2, 2011

Upgrade and clone hard drive in laptop

I recently bought an upgraded hard drive to put into my laptop.

Side note: Momentus XT 500 GB "hybrid" hard drive. This is a 7200 RPM drive with 4GB of solid-state disk internal to act as a write-through cache. It's supposed to drastically speed up the performance of the drive for executing common things (like booting, swapping, running apps).

Goal: clone current hard drive, swap, then boot.

Approach 1: purchase Apricorn EZ Gig product that comes with a cable and a software package to clone the drive. Price: $39. Unfortunately, they were out of stock locally, so I attempted the poor-man's approach.

Approach 2: Use an adapter kit I had laying around to hook up the drive to USB, then use CloneZilla to do it.


  1. Visit http://clonezilla.org/clonezilla-live.php and download clonezilla ISO. (I got the AMD64 arch for my E5500 laptop)
  2. Visit http://tuxboot.org/download.php so I can burn the ISO to a USB stick.
    1. Follow to source forge, go into the latest date directory, and download the tuxboot-windows.exe version.
  3. Run tuxboot.exe (it wants admin access to write to the device)
  4. Burn the image to the USB device. Don't worry about rebooting since you won't be booting to this machine immediately.
  5. Reboot onto the USB stick
  6. Follow prompts to start up clonezilla
  7. Choose drive-to-drive clone
  8. Follow prompts, pick the right drives for source and destination
  9. Let it churn. My machine was doing approximately 2-3 GB/min, so it took a few hours.
When it finished, I simply swapped the drives and the system magically booted up. Easy, peazy, lemon squeezy.

Upgrade to Momentus XT hybrid drive

I just upgraded my old Hitachi 5400 RPM 250 GB laptop drive to a Seagate Momentus XT 7200 RPM 500GB "Hybrid" drive. It's got 4GB of build in SSD solid-state NAND gate flash memory that acts as a smart cache with what they call "Adaptive Memory Technology." Supposedly it figures out the files you use the most and drops them on the SSD portion of the disk to speed things up.

First step was to hook up the drive with a SATA-to-USB adapter and connect it to my drive. The I used Clonezilla to clone drive-to-drive and it reproduced my 170 GB partition from the old drive onto the new one as a bit-by-bit copy. Then, simply switch the drives in the PC and everything magically works just like it did before. Easy as pie. (I don't know why people say this. Have you ever baked a pie? It's a PITA.)

It certainly SEEMS faster, even after a few minutes of using it. Rebooting my 64-bit windows 7 laptop is very quick. It boots in less than 30 seconds now to the login screen. It used to be over 40 sec. I ran a benchmark utility (Passmark Performance Test) and it claimed the new drive was 2-4x faster for sequential read-write performance. I'm sold.

I read some reviews and they were generally positive with a people complaining that the drive didn't spin down very often, it was noisy, or it vibrated a lot. I'm not sure, but I think it's a little louder. Considering my laptop sits on a desk and not my lap most of the time, I don't care much.

One suggestion I found was to upgrade from SD23 firmware so SD24. So I went to the page and did it. (http://seagate.custkb.com/seagate/crm/selfservice/search.jsp?DocId=215451). The problem is, it got stuck when I downloaded and ran the upgrade.

When I booted the machine, it would give me "Invalid System Disk. Press any key..." After that, it would boot into Windows 7 fine. Rebooting many times and re-running the utility did nothing.

Eventually I figured it out. I hit "F12" during start up to get boot options. Then I simply selected "Boot from internal HDD" and it magically fired up the upgrade utility for the firmware. 30 seconds later, it finished, shut down, restarted and now it works fine. Problem solved.

A little wonky, but it worked. Dunno if it made the drive any better. Time will tell.

Monday, January 24, 2011

Neat tire sizing tool

I came across this neat tire size comparison tool:

http://www.rimsntires.com/rt_specs.jsp

It allows you to plug in various sizes of tires and it analyzes how it will changes clearance, indicated speed, etc. on your vehicle.

Wednesday, January 12, 2011

2008 G35x Driving Impressions: First Few Weeks

Update: I had this sitting in "draft" mode for a really long time. I'm posting it now because I forgot to do so a long time ago.

As I wrote in my original post, I recently purchased a 2008 Infiniti G35x Sedan. I've been driving it for a few week and overall, I really like it. It definitely has a different feel from my previous daily driver, a 2005 Subaru WRX Sport Wagon. Of obvious note: it's got a 3.5L 300 hp torquey V6 instead a 225 hp turbo-charged 2.0L 4-banger, it weighs 3800 lbs instead of 3300, and it's got a "sport" automatic 5 speed transmission instead of a 5 speed manual.

First, I really like the motor. It's eager to rev, but doesn't need to for producing power. I like the instant-torque of the bigger motor. It's got a nice, throaty growl to it. I've seen C&D and other reviewers claim it's kind of raspy and unrefined compared to some of the BMW's, but I've never had a BMW, so I don't really care.

The 3800 lbs is noticeable. When cornering, there car definitely wants to push. It's also got a good amount of sway in the car due to all the mass. Expansion joins on exit ramps produce a nice shimmy in the rear end of the car although the suspension keeps all the wheels planted. Launching the car from a stand-still makes good use of the AWD and the car rockets forward with a very satisfying amount of thrust.

As a life-long stick driver, the manumatic transmission takes some getting used to. As I wrote in my other post, I'm used to manual transmissions that do exactly what I want them to do and ONLY when I want them to do it. I admit it -- I'm a control freak. Further more, the throttle has a direct linkage to the wheels without any RPM slop due to a torque converter. With that said, I'm slowly getting used to the new transmission. I like the fact that I can put it in manual mode for cruising on the highway or in traffic. On the highway, I want to be able to apply full throttle to get a short jolt of speed without the transmission down-shifting and winding out to 6000 RPM's. In this case, the slush-box torque converter actually works well to allow the revs to increase slightly and get some additional power. (In most cases, I still prefer it if it just locks-up and keeps the revs matched to the wheel speed.) In traffic, I like to be able to put it in a gear and drive with the throttle instead of jamming on the brakes all the time to slow down slightly. It's actually a blessing to not have a clutch to deal with. Finally, I like being able to manually select a gear during almost-stop turns (e.g., making a turn in an intersection) so you don't get the delay-down-shift-surge lurch while the tranny tries to figure out what gear it wants to be in.

The car has two automatic modes: Drive (D) and Drive Sport (DS). While cruising around, they both seem kind of similar. DS is more aggressive during braking: it automatically down shifts, anticipating your going to get back in the throttle. This is a little annoying when approaching a stop sign, but could be beneficial if you were driving around a track or on a curvy road. However, in both those situations, I would probably have the car in manual mode, regardless, so the point becomes kind of moot.

I tend to use the automatic modes when I'm puttering around not paying attention. (Now I know what the other 90% of the population feels like. Frankly, I like actually having something to do and concentrate on during driving.) In fact, I find my most common gear pattern to be as follows: cruise in 5th gear manual, slow to a stop, pop shifter into "D" to reset "auto mode", then back into "DS" to get in automatic-but-ready-to-manually-shift mode. Accelerate normally, allowing the transmission to up-shift as it goes. Once I reach speed, bump shifter forward to "5" manual mode and cruise there. Apply as much throttle as I want to change speed. When necessary, bump down a gear for additional speed, then return to tall gear for cruising in 5th. If I need to stop, rinse and repeat.

Overall: I really like the car. It's a bit of a heavy pig compared to the WRX, but it's also a lot faster and pleasurable to drive. I'll have to write more about my recent experiences in the snow as well as my general impressions of the various technology and luxury features of the car.

2008 G35x Sedan Driving Impressions: The Facts

So, I recently upgraded my 2005 Subaru WRX Sport Wagon to a 2008 Infiniti G35x Sedan. The WRX was a great little sport compact car, but at its core it was still a suped-up Impreza compact car with very basic attributes. I was interested in getting something a little bigger, a little stronger, and with some more luxury.  My basic criteria:
  • Sport sedan or wagon
  • 300-ish HP from a non-turbo charged engine
  • 4 doors, big enough to take on weekend trips with family
  • More luxury features (bluetooth, ipod connector, HID lights, leather, etc.)
  • AWD. (I don't need it THAT often, but really enjoy having it during the few times it snows every year.)
  • "Sporty" transmission (either 5+ speed manual or decent manu-matic)
  • Couple years old to save on depreciation
The combination actually makes it a short list. I looked at the 2007 Acura TL Type-S which I really liked. It had good power, lots of features, good fit and finish, and looks very sharp. Unfortunately, I really don't like FWD cars much, so opted out. Lexus IS AWD was good option: very sport looking, handles well, but only comes in the 250 motor which is a little underpowered for the weight of an AWD car. BMW 3-series IX, but the 328 is kind of underpowered and frankly I didn't want to pay the price of maintaining a BMW. The 335 IX kicks ass, but I wasn't willing to pay the price. Audi would have been a good option, but I didn't want another 2.0L turbo and there weren't another option with going with the S4 was kind of pricey. This left me with the G35x, which hit well on all elements and I just generally liked. The 2nd generation '07+ sedans got a major styling make over which drastically improved the looks, in my opinion. The G35 fit the bill and I've been very happy with it.

Some general facts about the car:

The Motor. Potent V6 that makes 306 hp, 268 lb-ft of torque which is good for 0-60 in approximately 5.6 seconds. This is close to the rated times of my 1994 RX-7 (when it was stock) and not bad for a 3800 lb car. Overall - it feels very strong and it's an nice change to be able to stomp on the gas in a high gear and have it go somewhere without having to downshift. (See below: automatic transmission that will actually stay in a gear.) The motor's additional power in the 2nd generation seems to have come from running higher compression with some other minor tuning adjustments.

The Transmission. The AWD "x" model only comes with a 5 speed automatic. Historically, I really don't like auto trannies very much, but I'm slowly getting used to this one. I don't care so much about the clutch, but I really want the transmission to do WHAT I want WHEN I want it to do it, and NOT to do things I don't want when I don't want it. So far, this one isn't bad. It has normal "(D)rive" mode, "(D)rive (S)port" mode, and manual shift mode. Drive mode is as you would expect. It is smooth in normal driving and responds with fairly crisp upshifts when wound out to high revs. It's fairly down-shift happy and drops a gear any time you give it moderate throttle, which I personally find annoying. Drive-Sport mode is a little more aggressive, holding the revs longer before up shifting and automatically rev-match down shifting during moderate or hard braking. It's still a little shift-happy, IMHO. Entering DS mode from D usually results in a down shift from current gear (e.g., 5th to 4th) but it will eventually up shift back to the higher gear if you cruise with steady throttle for a while. Manual mode is entered by bumping the shift lever up or down while in DS mode. It switches to manual-only shifting with a dash indicator of the current gear. Unlike some other (lousy) manumatics that I have drivent, it WILL actually stay in the gear you tell it to, including bumping off the rev limiter if you wind it out too far. (Err ... oops.) It will, however, down shift automatically to 1 when you come to a stop. It responds rapidly with crisp down shifts (maybe 0.25 second) when you bump the lever, but has very sluggish up shifts (0.75-1.5 seconds, perhaps). This lag is kind of annoying some times when I want to get on the throttle briefly, then back off and upshift a couple times to resume cruising mode. Supposedly, the models that include paddle shifters will allow you to bump gears up and down while in D mode, then it will resume normal D mode after a brief delay. (This seems desirable to me and the paddle shifters are actually a bolt-on addition that I might get.) The torque converter has about a 2000 RPM swing between full throttle and coast-down off throttle when cruising in a high gear. This amount of swing seems a little extreme, but allows the motor to rev up nicely and apply torque when cruising around in a single gear. This is a welcome change for me compared to the anemic turbo-laggy 4-banger that I've been driving for 6 years. The slush-box does lock up when cruising so throttle application has a more direct effect on the wheels at highway speeds. 

Styling. This is, of course, subjective but I think the car has very crisp, sporty styling that is just slightly on the "soft" side. I really like the changes they made to the back end for the 2nd generation remake they did in 2007. I do think the front-end styling on the base and "journey" models is a little "soft" however and I prefer the sport models that have a more aggressive, angular front air dam. I think a slightly more angular set of ground effects (front lip, side skirts, rear bumper) would improve the sportiness of the car quite a bit. It's possible a rear spoiler might sharpen it up a bit, but it also might ruin the clean lines of the car. For reference, I like the look of some of the Lexus IS sedans as well as the Acura Type-S.

Features. I seem to have picked a version of the car that has almost all the options available with the exception of paddle shifters, sport seat, and active suspension (which I'm not sure is available on the AWD car). It does not have the larger brakes, either, but those don't seem to be available on the AWD model, even on the G35xS "sport package" (not to be confused with G35S sport *model*) which I did not get, hence the missing paddle shifters and sport seats. Here are some noteable features:
  • "Intelligent" Cruise Control (part of Technology Package) with laser-guided distance sensing system that automatically controls speed if you approach another car. This means if you're set at 65 and you come up on the bumper of another car, the system will automatically will slow down and maintain safe following distance (3 selectable distances). If you get too close, it will actually apply up to 25% braking force (while moving the pedal and showing the brake lights). The sensor is embedded in the front left bumper and looks like a 4" reflective sensor with a redish tint. (It took me a while to figure out what it was when I bought the car.)
  • HID auto-adjusting headlights (part of Technology Package) that actually turn direction with the steering wheel. This is very noticeable at slow speed where the inner headlight literally pivots toward the direction of the curve when you turn the wheel.
  • Traction Control (Vehicle Dynamic Control) with selectable Snow Mode that, most importantly, can be (almost) completely turned OFF. With AWD, the system does some magical combination of adjusting torque to each wheel, retarding engine power, and individually applying the brakes to a slipping wheel to attempt to control vehicle dynamics and allow the car to maintain grip and a stable forward direction. I had a recent opportunity to drive it in the snow and the system (while "on") does a good job at sensing vehicle dynamics and correcting the car in slides. If the car starts to slide under power, you can actually feel the system cut power and apply brakes to a slipping wheel. Combined, this has a very effective ability to bring the car back into line and allow you to maintain a forward trajectory. A steady, moderate throttle allows the wheels to independently drag you in the right direction. It's fairly impressive. The "Snow Mode" switch further retards engine response to prevent you from spinning wheels. Most importantly, hitting the "VDC Off" button seems to do just that: stop the system from intervening when you actually want to have some fun with the car. (More on my adventures in the snow with this in a later post, perhaps.) Side note: I read somewhere that the system might still intervene with brakes on a slipping wheel, but I haven't seen any indications of this yet.
  • Navigation system (07-08 maps) with backup camera that has guided steering lines when you turn the wheel. It's driven by either touch screen or 8-way control pad and/or limited steering wheel up/down/select controls. It also has lots of physical buttons which I like. Generally, I find the system fairly easy to use and the Nav seems to be adequate. One pet peeve: it shows "remaining time" to destination instead of "estimated time of arrival." This makes it difficult to play my favorite game of "beat the clock" when driving to destinations. It's got simplistic voice activated menus that allow you to pick choices and set destinations hands-free while driving.
  • Bluetooth integration that syncs with up to 8 different phones, so you and your wife and kids and friends can all connect their phones (one at a time). It can download the phone book, but I've had weird experiences of it duplicating my phone book entries. The search mechanism SUCKS and you basicallly have to just scroll through your list at 3-letter increments (A-C, D-F, etc.) looking for entries. You can add individual ones to your local phonebook in the car, which are the only ones accessible while the car is in motion. The voice activated menus for dialing work here, as well, and seem to be adequate. I have to say, it's VERY nice to jump in the car and have it automatically connect to my phone so I can make and receive hands-free calls. I can still dial from the phone, if necessary, but it auto-switches to the car as a bluetooth head set after dialing. There's easy to hit menu items for "use handset" if you decide NOT to talk on speaker phone. I've been told that the call quality is pretty good, so overall I give it a thumbs up.
  • iPod integration which can be controlled from the on-screen navigation. Seems nice enough. Also has 3 RCA jacks for auxiliary input in case you have a non-iPad music player. Supposedly, it can display video on the Nav system monitor while parked, but I haven't tried it. I don't know if it will let you play iPod videos, but I doubt it.
  • Compact-Flash card slot for playing MP3's and maybe some other stuff.
  • Music Box 10GB internal hard drive that can rip music from CD's and store internally. Seems nice enough, but I haven't bought any CD's in years. It does not seem to let you just copy MP3's into the system or transfer from your iPod, so I'm not sure I'll use it much.
  • Proximity-Sensing Keyless Entry with Push-button Start. Kind of a neat feature, but it allows me to unlock and enter the car, then push a button to start it without taking my keys out of my pocket.
  • Auto-positioning power seats that have a "1" and "2" setting so my wife and I can automatically set our positions. Supposedly, it can sense which key fob is in the car and automatically set it that way, but I haven't configured that yet. This also includes positioning of the power mirrors and tilting extendable power steering wheel column.
  • Heated seats ("Go bummy!") and Heated Mirrors which have already come in handy this winter.
  • Homelink Garage Door Opener which eliminates one other do-dad that I would otherwise have to hang on my visor.
  • Leature seats that I'm still getting used to. Leather is, in my opinion, not as comfortable as a good sport cloth, too slippery, too cold in the winter, and too hot in the summer. It is, however, the ONLY option available in most modern high-end cars. It has the advantage of being easy to clean, which I'm looking forward to considering what my kids have done to our other cloth-upholstered cars. The seat itself is reasonably comfortable, but I find myself sliding around in it a bit too much. Perhaps the one thing I wish I'd know about and possible searched for was the sport seat in the "sport package" that has better thigh and side bolsters. Oh, well.
  • Rear pass-through panel into the trunk. I would much prefer it if the seats actually folded down, but that doesn't seem to be common in any of these cars.
It's also got some other decent features like bottle-holder slots in the map pockets in the doors, analog clock in the dash, faux-wood finish, proper knobs for the radio, dual-zone automatic climate control (with knobs), and kid-activated map lights in the rear seat.

Next up: driving impressions (as my daily driver) and some fun driving in the snow (aka "slippy slidey" in 10-year-old boy speak) that earned me the humorous name of "drift king" from one of my son's teachers.