Archive for July, 2012

Creating New Folder in Windows Explorer

Here’s one I forget every so often. What hot key combination will let you create a new folder in Windows Explorer?

In all versions of Windows, with a folder opened in Windows Explorer use Alt + F, W, F. This basically walks you through keyboard navigation of the Explorer menu.

Windows 7 has added a hot key combination specifically for this task. Ctrl + Shift + N

Thanks to How-To Geek for the tip!

Tags: , , , , ,

Tuesday, July 10th, 2012 Tips and Tricks No Comments

Remove Drive Letter for Encrypted Partition

I created a TrueCrypt partition on my machine that is assigned a letter when mounted through TrueCrypt. Through this drive letter TrueCrypt gives access to the files as if they were on any other drive, performing the encryption and decryption behind the scenes.

However, the encrypted partition itself is also recognized by windows and is given its own drive letter. Windows sees the partition and thinks it is unformatted and gives you the option to format it. I’d rather this “unformatted” partition not show up in Windows Explorer at all. To get rid of this drive letter do the following:

(This is for Windows XP. Vista and Windows 7 may be slightly different. If they are VERY different, email me or leave a comment with the correct procedure and I’ll update this post.)

  1. Right-click “My Computer” and select Manage.
  2. Select “Disk Management”.
  3. Right-click the encrypted partitionand select “Change Drive Letter and Paths…”
  4. Click Remove.
  5. Click Yes to confirm.

Further reading:

Tags: , , , ,

Saturday, July 7th, 2012 Security, Tips and Tricks No Comments

java XML parsing: line 1, character 38, unable to switch the encoding

While working on a Java web application I was trying to import an XML file into a Microsoft SQL Server database table with an XML type column. Everything seemed to be OK except I was running into the following error:

java XML parsing: line 1, character 38, unable to switch the encoding

After much googling the consensus was that this error is raised because SQL Server stores XML in the XML type column using UTF-16 character encoding while the file I was trying to insert was UTF-8 encoded. So, I had to convert my input data from UTF-8 to UTF-16.

My original code was doing this:

String str = new String(data);

The String class defaults to UTF-16 unless specified otherwise. However, to be sure I changed the above to:

String str = new String(data, "UTF-16");

Nope, didn’t work… Well, the documentation for the String constructor isn’t the greatest so maybe the encoding parameter is just used as a hint at what the input data is supposed to be. The behavior of this constructor when the given bytes are not valid in the given charset is unspecified. Not entirely clear… Just to be sure, I changed it to this:

String str = new String(data);
str = new String(str.getBytes("UTF-16"), "UTF-16");

Still no luck. Ok, how about using CharsetEncoder/Decoder

Charset utf8= Charset.forName("UTF-8");
Charset utf16= Charset.forName("UTF-16");

CharBuffer cb = utf8.decode(new ByteBuffer.wrap(data));

ByteBuffer outputBuffer = utf16.encode(cb);

String str = new String(outputBuffer.array(), "UTF-16");

Still no.

Well, looking at the XML document itself I see the XML declaration is specifying the encoding attribute as encoding="UTF-8". I delete it and finally it works.

So, even though I changed the input to the correct encoding, the fact that this attribute was specified in the XML document itself caused SQL Server to complain. Ok fine… However, I ended up removing all the encoding conversion code that I had been playing with and reverted back to the original code:

String str = new String(data);

Tried the import again but without the encoding attribute and it still works. SQL server will do the conversion for you if the encoding attribute isn’t specified. It won’t touch it however if it is.

So, options now are, 1) either remove the encoding attribute altogether, or 2) make sure the file is UTF-16 encoded with the encoding attribute set accordingly.

Related links:

Tags: , , , , , , , ,

Saturday, July 7th, 2012 Database, Java, Programming, SQL Server No Comments

Facebook Fail!

It seems someone at Facebook has broken the BigPipe. Currently, the site is broken for me on both Firefox and IE8. Looks like this problem has been around for a while. Something seems to get screwed up client side but I can’t tell what. Clearing the cache and other temporary data doesn’t seem to fix it. So far, the only thing that seems to work is to reboot the machine.

Tags: , , , ,

Thursday, July 5th, 2012 Uncategorized No Comments

Exclude Documentation for Protected Members in Doxygen Output.

Doxygen is a tool for generating documentation by extracting code structure and relations, code signatures and specially formatted comments from application source code. It’s a very powerful tool that I’ve used on several personal and work related projects.

One of the features it provides is customizability. For example, it can be configured to generate separate documentation for internal or external use. Internally used documentation may include all public and private methods of classes while external documentation my only provide documentation for public APIs.

To exclude private class members the configuration option EXTRACT_PRIVATE which defaults to YES should be set to NO. If you really want to generate public documentation you likely want to exclude protected members as well. There is no EXTRACT_PROTECTED configuration option but you can work around it by using the following:


ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
PREDEFINED = protected=private

This will cause the Doxygen engine to treat the protected keyword as a macro and replace it with private during processing. With EXTRACT_PRIVATE set to NO, protected members will also be excluded.

Source: http://osdir.com/ml/text.doxygen.general/2004-12/msg00047.html

Tags: , , , , ,

Wednesday, July 4th, 2012 Cpp, Programming No Comments