Friday, July 26, 2013

I have moved over to my professional blog at KP Automation.  Please follow me there!

Tuesday, November 9, 2010

Stack Overflow rocks!

I've been using Stack Overflow for a couple of years now. In my opinion, this is the single best site to search for answers to technical or programming questions. Highly recommended! I post there as user kevin-p

If you haven't heard of Stack Overflow, its Wikipedia article provides a good overview of how it works.

Thursday, August 20, 2009

Windows Vista: Creating an NTFS mount point folder for a TrueCrypt volume

This is a forum post that I made on the TrueCrypt forums.

I wanted to mount a TrueCrypt volume as a Windows NTFS folder using an NTFS mount point. I spent a lot of time figuring out how to do this, so here are the instructions for anyone else who wants to do this.

This is tested on Windows Vista. Use on other versions at your own risk.

Goal: Mount a TrueCrypt volume as an NTFS folder, e.g. C:\Users\MyName\MyEncryptedFolder

1) Create a TrueCrypt volume as documented in the manual. I believe that this needs to be an NTFS volume, but I have not verified this.

2) Mount the TrueCrypt volume as a drive letter, e.g. Z: Important: Windows Vista wants you to re-use this same drive letter in the future, so choose it carefully.

3) Verify that Z: was mounted correctly and you can see the files inside.

4) Create an empty folder named MyEncryptedFolder in C:\Users\MyName\ This has to be on an NTFS device or partition. This folder must be empty.

5) Open a Command Prompt window in Administrator Mode. *** Important: Click on Start, find the Command Prompt, right-click on it, select Run as Administrator. If this works properly, you should have a new Command Prompt window named Administrator: Command Prompt ***

6) In this window, type the command: mountvol.exe You should see your TrueCrypt drive letter below in the form:

\\?\Volume{0384767c-8db8-11de-b19b-00247e518e40}\
Z:\


Copy the volume ID above including the slashes into the clipboard. You will use this shortly.

7) Type the command:
mountvol.exe C:\Users\MyName\MyEncryptedFolder \\?\Volume{0384767c-8db8-11de-b19b-00247e518e40}\


(Substitute your path and volume IDs as needed).

That should be it! You should now see MyEncryptedFolder with a slightly different icon and the contents of your TrueCrypt volume inside it.

Notes:

a) If you dismount the TrueCrypt volume, and try to browse the MyEncryptedFolder, you will get a generic message that this folder "refers to a location that is unavailable". Simply mount your TrueCrypt volume again, and everything will start working properly once more.

b) The folder mount point seems to be tied to the drive letter for some reason, so if you change the drive letter, you will have to delete and recreate the mount point. See mountvol.exe for instructions on how to do this.

Tuesday, April 14, 2009

IntelliParse

I've started my first SourceForge project named IntelliParse. As the description goes, this is...

A library to parse user-entered form data such as telephone numbers, social security numbers, dates, etc. and intelligently convert them to usable and normalized forms, with country codes, area codes, etc.


I intend for this library to be a cross platform and available on all modern operating systems for the desktop, laptop and smartphone. I'm in the process of deciding on a directory structure, and its taking shape with the answers to this StackOverflow question:


/project //Top level folder

/bin //Binaries ready for deployment
/linux_amd64 //Linux AMD64 platform
/debug //Debug build - duplicated in all platforms
/release //Release build - duplicated in all platforms
/linux_i386 //Linux 32-bit platform
/macosx //Mac OS X
/win32 //Windows 32-bit platform
/cygwin //Windows 32-bit platform compiled with Cygwin
/vs.net //Windows 32-bit platform compiled with Visual Studio .NET
/win64 //Windows 64-bit platform

/build //Make and build files, IDE project files
/linux_amd64 //Linux AMD64 platform
/linux_i386 //Linux 32-bit platform
/macosx //Mac OS X
/win32 //Windows 32-bit platform
/win64 //Windows 64-bit platform

/config //Configuration files that accompany the binaries

/data //Data files that accompany the binaries

/doc //Documentation

/lib //External or third-party libraries
/platforms //Platform-specific code for ...
/linux_amd64 //Linux AMD64 platform
/linux_i386 //Linux 32-bit platform
/macosx //Mac OS X
/win32 //Windows 32-bit platform
/win64 //Windows 64-bit platform
/src //Available library source code in subfolders

/src //Source code tree - this will contain main.cpp
/bindings //Bindings to other languages such as ...
/python
/java
/h //Header files
/modules //Platform-independent modules, components or subprojects
/platforms //Platform-specific code for ...
/linux_amd64 //Linux AMD64 platform-specific code
/linux_i386 //Linux 32-bit platform-specific code
/macosx
/win32 //Windows 32-bit platform-specific code
/win64 //Windows 64-bit platform

/test //Automated test scripts


I am planning on using CMake and Subversion.

Thursday, November 6, 2008

Quick and dirty connection to Oracle using ADO.NET

My C#.NET application needs to read from an Oracle database. There are many elaborate ways to connect to a database in .NET, including the Linq for Entities ORM. However, this was way too much for my purpose. I've found the following code to be much simpler. It's largely copied from a C# Station post. The key difference is that you have to use the OracleClient class.

First: Make sure that your project has a reference to System.Data.OracleClient


string connectionString = @"
SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP
(HOST=OracleHost)(PORT=OraclePort))
(CONNECT_DATA=(SERVICE_NAME=OracleServiceName)))
;uid=UserID;pwd=Password;";

OracleConnection conn = new
OracleConnection(connectionString);

OracleDataReader rdr = null;

try
{
// 2. Open the connection
conn.Open();

// 3. Pass the connection to a command object
OracleCommand cmd = new OracleCommand(
"select * from mytable", conn);

//
// 4. Use the connection
//

// get query results
rdr = cmd.ExecuteReader();

// print each record
while (rdr.Read())
{
for ( int i = 0;
i <rdr.FieldCount; i++)
Console.WriteLine(rdr[i]);
// Print each field
}

}
catch
{
throw;
}
finally
{
// close the reader
if (rdr != null)
{
rdr.Close();
}

// 5. Close the connection
if (conn != null)
{
conn.Close();
}
} // End of try-catch-finally


Thanks are also due to ConnectionStrings.com

Friday, September 19, 2008

Convert < and > to & lt; and & gt;

If you're trying to display HTML or XML tags on a web page, like in my previous post, most web publishing systems will swallow up the tags and the output will not be what you expect.

I came across this nice web converter that converts the < to & lt; and the > to & gt; allowing your content to remain unmangled.