Win Library Tool [revised for Windows 8]

UPDATE: This tool has been updated and now works on Windows 8, however from my limited testing, the new metro interface has extremely limited support for libraries. Unfortunately using this tool I couldn’t find a way for photos added from a network drive to appear in the ‘photos’ metro app even though they appear in the library in Windows File Explorer. Windows 8 is astonishingly bad.

Download Executable | Source Code

Windows libraries (introduced in Windows 7) could have been a really useful feature of Windows, however unfortunately they arrived in a slighly cut-down form out of the box.  Microsoft decided against exposing some really useful capabilities to users, like adding network locations, pretty much the first thing I tried to do.  You get this message:

windows7libraryerror

Luckily, you can add network locations (and any other un-indexed locations), but it must be done programatically.  MS supply a command line utility slutil.exe, candidate for the worst named executable in history.  Pretty sure it stands for shell_library_util.  Anyway, I decided to write a tool to make it easy to add network locations, and added a few other features as well:

  • Add network (UNC or mapped drive) and any other un-indexed folders to libraries.
  • Backup library configuration, such that a saved set of libraries can be instantly restored at any point (like after a re-install of the OS or for transfer between multiple computers).
  • Create a mirror of all libraries (using symbolic links) in [SystemDrive]:\libraries.  This means you can reference all your files using a much shorter path, and also provides another entry-point to your files in many places in the Operating System (e.g. file open/save dialogs).
  • Change a library’s icon.

Hopefully it’s easy enough to use, so I don’t have to explain it :)

You can download it for free below.  (Note: This will only run on >= Windows 7.)

Download Installer | Source Code

I must give credit to Josh Smith for his TreeView CodeProject article, upon which this solution is modelled.

The application uses the Microsoft API CodePack to manipulate libraries, which I encourage you to check out if you are writing software to integrate / take advantage of new features in Windows 7.

If you want to learn why and how libraries were introduced in Windows 7, including diving into the .library-ms file format, you can read this MSDN article.

Now featured on Tekzilla!

Can’t scp using git-shell

I recently created a new Android app on my local dev box, but when I went to copy it to my git server using:

scp -r -P 9876 AppProjectFolder.git git@myserver.address.com:/opt/git

I got this:

fatal: unrecognized command ‘scp -r -t /opt/git’
lost connection

After researching, I found it is due the git user on my server using git-shell (to restrict commands that can be used). However, I’m sure I used to be able to use the scp command even when using git-shell. I couldn’t find the root cause, so I just modified /etc/passwd to set the git user to use /bin/bash temporarily, then switched it back after the files were copied. My server is running Fedora 19, if anyone knows what can cause this and/or how to fix it please post a comment.

Run unit tests in a batch loop

We had a case where a tests was randomly crashing the MSTEST agent process, leave no trace of the root cause. So to reproduce, we ran the test in a loop in both MSTEST and xUnit frameworks using the following scripts, posted here for future reference:

rem Run unit tests in an assembly in a loop using xUnit (build 1705).
FOR /L %%i IN (1,1,5000) DO (
xunit.console.clr4 UnitTests.dll /xml C:\xunit-results\output%%i.xml
)

rem Run unit tests in an assembly in a loop using MSTEST.
FOR /L %%i IN (1,1,5000) DO (
mstest /testcontainer:UnitTests.dll /resultsfile:c:\mstest-results\output%%i.xml
)

CSR bluetooth dongle killed by Windows update

An optional update for my USB bluetooth dongle (which I used to connect my Logitech bluetooth keyboard) recently appeared on one of my Windows 7 machines. Trustingly, I proceeded with the update, only to find that afterwards, my keyboard no longer worked! And there was no blueooth icon in the system tray to inspect the status of bluetooth devices. After googling, I found out that this update has killed many people’s bluetooth hardware and the solution is to uninstall it an go back to the default Windows drivers. The solution that worked for me (and others) detailed on this thread, which I will summarise (paste) here:

To accomplish this select “Update Driver Software” from “CSR BlueCore Nanosira” (the working device), then select “Browse my computer for driver software” and then “Let me pick form a list of device drivers on my computer”. In my case Windows presents the new driver from CSR (“CSR BlueCore Nanosira”) and two generic drivers as you can see in screenshot 2.

I selected “Generic Bluetooth Radio” from the list and clicked OK. Then I had “Generic Bluetooth Radio” and “Microsoft Bluetooth Enumerator” back under “Bluetooth Radios” and the Bluetooth icon appeard in the taskbar again. After that I was able to use my bluetooth mouse and keyboard again (even without pairing it again).

Thanks to davewebb8211!

Then you will want to hide that nasty windows update as follows:

bluetooth-update

No sound in Kodi / XBMC with ASUS Xonar

I recently replaced the motherboard in my media centre due to on-going bluescreens, and I unwittingly selected a refurbished board with no on-board audio (ASUS Rampage Extreme II). The two main PCIE sound card manufacturers appear to be ASUS and Creative. I selected ASUS Xonar PCIE 7.1 DX for two reasons:

  1. I’ve used plenty of Creative hardware before and they are getting worse over time.
  2. It was the only one they had in the shop!

Anyway, first problem was that the card didn’t physically fit in my PCIE x1_1 slot due to the CPU heatsink placement! Luckily I found out that you can put a smaller PCIE card in any larger PCIE slot. So I was able to install it in my 2nd PCIE x16 slot.

Second problem is that when I went the install the drivers from ASUS, the driver installation didn’t detect the card and just hung. I forced a reboot, ran the installation again, and amazingly the installation worked 2nd time around and sound in Windows 7 was now working.

When I fired up Kodi however, there was no sound. Looking into the log file i saw this:

CAESinkDirectSound::Initialize: cannot create secondary buffer (DSERR_UNSUPPORTED)

And after googling that I saw that many people were having problems with ASUS Xonar cards in XBMC / Kodi. The main solution was to go into system – audio settings and change from using DirectSound to WASAPI. This did work for me, however it means that when Kodi is running, no other application can output sound, i.e. Kodi has exclusive access to the audio hardware. While not optimal, this is at least a workable solution. But I probably won’t be buying ASUS Xonar sound cards in the future.

Starting a legacy animation with delay from script in Unity

Applies to: Unity 4.5.5f1 (and possibly other versions)

Unity has introduced a new animation system called Mecanim, but the existing animation system is still available to use. If you are using the old animation system you’ll be using an ‘animation’ component rather than an ‘animator’ component on your gameobject. And when you do so, you’ll likely see at least one of these warnings:

The AnimationClip ‘x’ used by the Animation component ‘y’ must be marked as Legacy.
Default clip could not be found in attached animations list.

There are two ways to solve this, depending on whether you have a model (e.g. via a prefab) or not.

You have a model
Select the model and on the Rig tab of the import settings, change the animation type to ‘legacy’.

rig-tab

You don’t have a model
In this case, select the animation and then in the inspector, RIGHT-click the ‘Inspector’ tab and choose ‘Debug’.

inspector-debug

Then change the animation type value from 2 to 1. Then change back to ‘Normal’ mode on the Inspector tab and when you run your app, this warning should be gone.

It is simple to apply your legacy animation to a gameobject by simply adding an ‘animation’ compoment and dragging the animation to appply onto that component. In this case, the animation will by default play on startup of your app. But what if you want to start the animation after some delay via a script, for example. To do this, uncheck ‘Play automatically’ in the animation component, then add a new script component to your game object. You can use the following code to start the animation after a 3 second delay. This also demonstrates how to achieve a fixed delay from a script.

public class startanim : MonoBehaviour {

	private bool started = false;

	// Use this for initialization
	void Start () 
	{
	}
	
	// Update is called once per frame
	void Update ()
	{
		if (!started)
		{
			executeWait();
			started = true;
		}
	}

	private void executeWait()
	{
		StartCoroutine(Wait(3.0f));
		Debug.Log("This line runs *immediately* after starting the Coroutine");
	}
	
	private IEnumerator Wait(float seconds)
	{
		yield return new WaitForSeconds(seconds);
		Debug.Log("3 seconds has passed, animation is now starting.");
		this.animation.Play ();
	}
}

Finally, the debug output can be viewed at the bottom of the unity window:

debug-output

Auto-Complete not working in Eclipse

After upgrading from Linux Mint 13 to 17 (and Eclipse from Juno to Luna) I noticed that auto-complete (also called content assist) which is normally invoked using Ctrl+Space is not working anymore. After searching I found it is not actually caused by Eclipse, but instead the IBus (Keyboard) preferences eat Ctrl+Space so Eclipse never receives it! This is a very poor choice of global shortcut and it has been reported as a bug here. You can confirm Eclipse is not receiving it by going into Window->Preferences->General->Keys and attempting to enter Ctrl+Space for a key.

Until it is fixed, you can work-around it by right-clicking the keyboard icon in the system tray (next to the clock), choose ‘Preferences’ and select a different shortcut for ‘Next Input Method’.

Unknown Hard Error

This stupid error plagued me for almost a year before a colleague of mine found a fix. If you see this:

unknown-hardware-error

You can make the following registry change to avoid this. This was happening on machines that were running UI tests, so this top-most dialog was causing tests to fail, pretty horrible considering there is no explanation as to the cause. Apply this reg change and move on:

HKLM/SYSTEM/CurrentControlSet/Control/Windows/ErrorMode=2

For reference see:

http://support.microsoft.com/kb/124873/en

Command history in Android Terminal

Here’s a tip if you are usingthe Terminal Emulator app by Jack Palevich in the Play Store:

To recall your previous command use VolumeUp + w (lower case) and VolumeUp + s (lower case) to move forward in the command history.

Because typing on a tablet soft keyboard sucks.

USB Driver for Nexus 5 on Windows 7

When I plugged in my Nexus 5 to my Windows 7 PC, it was not recognised, even after I used the Android SDK Manager to install the latest Google USB Driver. I finally worked out that there is a manual step you must take: Check the tooltip to find out where the USB driver was downloaded to (I found one under Program Files folder that was not installable – make sure you refer to the tooltip), and use Device Manager to update the driver, pointing to this folder. Then you can debug on your Nexus using ADB.

usb-driver