SVN to Mercurial

Synchronizing SVN repository to Mercurial one is deceptively easy. Convert extension is as simple as it gets:

hg convert svn://1.2.3.4/Repo Repo

Unfortunately, this method has issues with speed, especially when there is huge SVN repository on other side of slow (and unreliable) VPN connection. I had seen few hours download times per commit if everything goes well. If something fails, you are back at square zero and you need to re-sync complete commit again. And even if commits are not big, scanning time will drive you crazy.

I found that, under those circumstances, two step approach works best. First we synchronize remote SVN repository to local (SVN) one. In all instances I tried this, SVN offered superb speed (compared to Mercurial) and it hasn’t suffered from broken connections as much.

My client of choice was Visual SVN and few commands were all it took to create local copy:

> svnadmin create C:\Repo

> echo exit 0 > c:\Repo\hooks\pre-revprop-change.bat

> svnsync initialize file:///C:/Repo svn://1.2.3.4/Repo
Copied properties for revision 0.

> svnsync sync file:///C:/Repo svn://1.2.3.4/Repo
Committed revision 1.
Copied properties for revision 1.
Transmitting file data ...

After local copy is created, you can use hg convert without further trouble.

SetWindowLongPtr

[SetWindowLong](http://msdn.microsoft.com/en-us/library/windows/desktop/ms633591(v=vs.85).aspx) function is well known among those who want to change various properties of already created windows. However, there is a slight issue with it on 64-bit Windows - it does not work properly. Someone originally defined this function to return LONG. Unfortunately LONG is actually defined as a 32-bit integer on both 32 and 64-bit Windows. Since SetWindowLong is also intended for setting some pointer sized properties (e.g. GWL_WNDPROC) this will not do.

Fortunately Microsoft also saw the error and created new function SetWindowLongPtr which corrects declaration so it is valid for both 32 and 64-bit world. Except they didn’t.

While comment clearly says “This function has been superseded by the SetWindowLongPtr function. To write code that is compatible with both 32-bit and 64-bit versions of Windows, use the SetWindowLongPtr function.”, this is not really the full truth. If you check its declaration in WinUser.h you will see the ugly truth - on 32-bit system, SetWindowLongPtr is a simple #define toward good old SetWindowLong. This means that statement is valid for someone working in C/C++. For all other languages, this statement is misleading at best.

Solution for C# is simple, just check whether code is running in 32-bit mode and call SetWindowLong yourself. In all other cases just call SetWindowLongPtr. Code Analysis will complain a bit about CA1901 (P/Invoke declarations should be portable) and CA1400 (P/Invoke entry points should exist) but we can safely ignore these warnings if we make sure to call correct function ourselves.

These declarations should do the trick:

public static IntPtr SetWindowLongPtr(IntPtr hWnd, Int32 nIndex, IntPtr dwNewLong) {
    if (IntPtr.Size == 4) {
        return SetWindowLongPtr32(hWnd, nIndex, dwNewLong);
    } else {
        return SetWindowLongPtr64(hWnd, nIndex, dwNewLong);
    }
}

[DllImport("user32.dll", SetLastError = true, EntryPoint = "SetWindowLong")]
[SuppressMessage("Microsoft.Portability", "CA1901:PInvokeDeclarationsShouldBePortable", MessageId = "return", Justification = "This declaration is not used on 64-bit Windows.")]
[SuppressMessage("Microsoft.Portability", "CA1901:PInvokeDeclarationsShouldBePortable", MessageId = "2", Justification = "This declaration is not used on 64-bit Windows.")]
private static extern IntPtr SetWindowLongPtr32(IntPtr hWnd, Int32 nIndex, IntPtr dwNewLong);

[DllImport("user32.dll", SetLastError = true, EntryPoint = "SetWindowLongPtr")]
[SuppressMessage("Microsoft.Interoperability", "CA1400:PInvokeEntryPointsShouldExist", Justification = "Entry point does exist on 64-bit Windows.")]
private static extern IntPtr SetWindowLongPtr64(IntPtr hWnd, Int32 nIndex, IntPtr dwNewLong);

Babysitting

I’ve been going to a road trip with my family over a weekend and, of course, I forgot to bring audio cable. That small piece of wire was all that was keeping me apart from having my phone output beautiful music for my kids on a car stereo. No biggie I though, car has a bluetooth, it will be a cakewalk to connect the phone.

It wasn’t.

You see, Ford in its eternal wisdom decided to forbid setting such things while car was moving. And the message clearly said: it was for my safety. I found that strange because I was sitting on a passenger seat, pretty sure that I wasn’t one holding the steering wheel. If car is moving, nobody should be allowed to do anything it seems.

And this “security features” seem to be just part of a bigger trend. Let’s just take National Highway Transportation Safety Agency recommendations for GPS functionality. For example, they suggest (V.5.b) that dynamic maps are not the best choice when it comes to visualization of travel data. Their recommendation is to have GPS update every few seconds. Yes, people looking every few seconds for updated map wondering whether what they see is a current information or they have already screwed the turn will definitely make for safer driving.

We should also not forget Transportation Secretary Ray LaHood saying that your mobile phone should be disabled while in a car. I understand that mobile phone is a distraction but thing is that there is no way to reliably detect who is driving. And why shouldn’t passenger use driver’s mobile phone to, God forbid, look up maps or even worse, speak to his Mom who called him at wrong moment?

I am quite annoyed by all this babysitting and forbidding various distracting things for no measurable effect. It restricts quite useful scenarios when you do have two persons in the car and it does not offer any real safety benefit when you don’t. Face it, idiots will stay idiots and no amount of “features” will make them a good driver. They will just think of something else to entertain them while hurling on a highway toward eventual doom.

Windows 8.1

Illustration

Last week Microsoft announced Windows 8.1 preview and I decided to install it on my personal machine. I mean, what could go wrong?

Installation process was really simple. First there was a quick fix for Store, followed by quick restart, Store-based install, and an 0xc0210000 error code. After some troubleshooting and a question later, problem went away when I disabled all startup applications. I would not call this a rock solid installation process in any case. But it did work (eventually).

First thing you might notice after reboot is that DPI is all wrong. Not only that Windows will not recognize high-DPI screen as they used to but, if you manually select larger text, they will also make everything blurry. Only way to get things back to normal is to select one scaling level for all displays. Once that box is checked you will be able to set DPI without blurriness.

Mind you, this might as well be issue with a graphics driver. Windows 8.1 changed driver model slightly once more and Intel HD 4000 has not received update yet. Most visible consequence of this are occasional video artifacts and a missing screen brightness adjustments. Fresh install of Intel graphics driver sorted this out.

I thought search cannot get much more wrong than what we got with Windows 8. I was semi-correct. Finally applications, settings, and files are searched together (as they were in Windows 7). However, you will get only first four hits to chose. Rest of screen will be taken with Internet search suggestions. Nice way to waste space.

Start button is a joke. Instead of full featured and loved implementation we had in Windows 7, there is a button that supports few menu options when right-clicked. Judging by the attention to details it was probably implemented by a janitor. I guess it is not all bad news because finally you can disable upper-left and upper-right hot corners. Yippee, close button is usable once more without fighting with charms menu.

There are few new Metro-style applications slowly taking over functionality from their desktop equivalents. For example, we have fully functional Metro Calculator. Oh no, wait, it misses Programmer mode. I guess that student developing it ran out of time. Most other applications that are metro-lized suffer same issue. They are just not finished so they will miss features or two when compared to their desktop brothers.

Explorer got a slight update. Not only it is called File Explorer these days but it also offers This PC as start page instead of My Computer. Some poor soul worked his heart out for this one.

Not all changes are superficial though. SkyDrive got more integrated and I find that a good thing (as does NSA :)). New DPI model shows promises in cases where you have two monitors with different DPI settings. And lets not forget boot to desktop.

It is a bit unfair to judge Windows based on just a preview, but I have a feeling that Windows 8.1 are going to be just bunch of fixes and applications that should have been there from day one with Windows 8. Regardless of my bickering, they are improvement over Window 8 and things are bound to get better once install procedure is fixed and manufacturers get their drivers in order.

As far as I am concerned, possibility to disable upper-corner charms and “everywhere” search are reason enough to upgrade. Especially since it will be free.

Agilent U1232A

Illustration

Newest in line of my multimeters is a 6000-count Agilent U1232A.

This device falls into a category of electrician’s multimeters which is most noticeable on current range which only starts at 1 mA. Other specs for this multimeter are also nothing special; you cannot even use K-type probe directly with it. Considering cost in excess of $100, why would anyone buy it?

Because trust is important. While every multimeter states at least CAT III 600V rating, just few of them really do. In reality they will fry if you do something stupid (e.g. measuring current on ohm range). And it is not question whether you will do something stupid, it is just question of time. This multimeter can handle stupid.

DC voltage measurement is 0.5% + 2 counts from 0.1 mV to 600 V which is more than decent. AC voltage is slightly worse with 1% + 3 counts but no real surprise there. Nice addition is low input impedance mode as a separate switch selection. Not only that it will deal with “phantom” voltages but it will automatically detect whether voltage is AC or DC.

Simple hand-wave above its screen can produce quite a big voltage spikes (up to few hundred mV) in this multimeter. It is not necessarily an real-life issue with measurements since I don’t ever hold my multimeter in hands but it is something to be aware of. It seems that someone at Agilent decided to go a bit cheap on shielding.

Resistance is 0.9% + 3 on all ranges except 60 MΩ. Resolution better than 100 mΩ would be good but it is definitely not something I need every day. Still, it would be nice if it went at least one decade lower. Continuity tester is speedy and it will even flash screen at you. I love this for late night sessions because sound can be turned off.

Diode measurement is basic and, of course, cannot light up white LED. I find that slightly disappointing but I know of even more expensive multimeters without this functionality.

Capacitance range goes from 1 nF to 10 mF. If you need to measure smaller capacitance, you will need to have additional LCR meter. This multimeter is good for troubleshooting bad power supply caps but not that good if you want to check oscillator cap values.

There is one mode that sort-of measures temperature but only with additional accessory. If you don’t have such accessory you can use it as fixed 600 mV range but I don’t see the point. If you are not going to include direct K-type measurement, there is no need to include temperature setting especially when multimeter offers nice scaling function.

Current range starts at 1 mA and goes to 10 A of continuous current. If you just need quick measurement you can go up to 20 A for 30 seconds. While this is something that most multimeters can handle, not all of them are ready for new measurement within a minute after overload. Multimeter also has µA range that is not suitable for any real measurement because it has more holes than a Swiss cheese. It is only suitable for measuring some (e.g. flame) sensors and not for general-purpose measurement. Unless you use something like µCurrent you can forfeit low-current work.

Menu system is logical and it is usable even without manual. You can set surprisingly big number of options ranging from beep frequency and backlight all the way to smoothing. There is a possibility of basic data logging on multimeter itself but it is very restricted. Fortunately there is an optional IR to USB cable (that does not work with Windows 8, but more on that later).

Looking directly at display numbers look clear and big. However, it gets really washed out when watched from above. It is only slightly better looking from side and generally I find it rather disappointing. How come that Uni-T can provide superior LCD screens even with its cheapest multimeters and Agilent cannot get it right with one that is at $130. Selection switch is really spongy and unlike any other I have tried. It was necessary to make it a bit softer in order to allow for one-hand operation but Agilent went a bit too far in my opinion.

Build-wise this is really nice meter. Sockets are full metal and they give nice feel when you plug cable into them - not too soft, not too firm. Rubber foot fits nicely around multimeter offering protection and good feel. Some reported on it getting easily dirty but I cannot testify to that. Either I keep it too clean or (as wife can testify) I have blind spot when it comes to dirt. AAA batteries hide under single threaded (semi-captive) screw alongside a single 11 A HRC fuse.

Two more self-tapping screws hold a case together. PCB inside is nice and clean without many surprises. Protection comes in form of two power resistors, few PTCs, and a glass encased varistors. There are a few isolation slots at a strategic places so high voltage should not be an issue. Sockets are connected via hex head and no amount of vibration will set those free. This multimeter has potential to last a long time even with all expected abuse.

Carrying case is an optional accessory and comes at price of $20. For that price I have an issue with velcro strap. Even Uni-T gives elastic strap in its free case and it is infinitely more practical.

USB to IR cable has much bigger issue. In their wisdom Agilent decided to use obsolete chip (PL-2303HXA) and thus there is no Windows 8 driver support. Not now, not ever. I did manage to make it run on Windows 8 by making a completely new board.

Agilent’s Data Logger GUI was probably build by prisoners around 200 BC judging by its quality. I haven’t seen program that requires administrator rights on computer in a while. Yes, corporate users without administrative privileges on a computer can forget about it.

All things considered, I am still happy with this multimeter. Agilent did a really lousy job on accessories side but main device is good enough that you can forget few shortcomings.

P.S.: If you are interested how it looks inside, I have a close-up PCB images for you.

P.P.S.: There is quite long review video for this multimeter on YouTube.

P.P.P.S.: If you need IR to USB cable under Windows 8, check alternative communication board (you will still need Agilent’s cable).