Richard Smith's Blog http://richard.smith-sa.com/ The thoughts of an easily distracted software developer... en-us Tue, 13 Oct 2015 00:00:00 +0200 http://richard.smith-sa.com/2015/10/13/sudo.html http://richard.smith-sa.com/2015/10/13/sudo.html <![CDATA[sudo]]>

sudo

I’ve written a very simple helper tool to elevate processes on Windows. You can find the project at sudo and you can download at sudo - 1.0.1.

]]>
Tue, 13 Oct 2015 00:00:00 +0200
http://richard.smith-sa.com/2015/09/26/smtptester.html http://richard.smith-sa.com/2015/09/26/smtptester.html <![CDATA[SMTPTester]]>

SMTPTester

One of the challenges I’ve had is testing SMTP server configuration’s supplied by our clients. Often there are problems with certificate validity or various other security settings. I wrote a simple tool to allow for testing/debugging from the command line. You can find the project at SMTPTester and the first version can be downloaded at SMTPTester - 0.1.0.

It allows you to send test messages, dump the certificate’s of the SMTP server to disk and optionally ignore certificate errors. There is detailed error logging available in verbose mode.

../../../_images/SMTPTester.png ]]>
Sat, 26 Sep 2015 00:00:00 +0200
http://richard.smith-sa.com/2015/09/21/clearing_a_ftp_directory_with_teamcity___lftp.html http://richard.smith-sa.com/2015/09/21/clearing_a_ftp_directory_with_teamcity___lftp.html <![CDATA[Clearing a FTP directory with TeamCity & LFTP]]>

Clearing a FTP directory with TeamCity & LFTP

I recently needed to setup a TeamCity build which deployed to an FTP site. Configuring the deployment itself was simple: just use the Deployer plugin to copy the build artifacts across.

Unfortunately the plugin doesn’t support cleaning out the destination directory before copying the artifacts. The solution was to use LFTP to run:

rm -rf /my/target/dir/*

There is a windows build of LFTP available here. You can then just configure a command line build step in TeamCity to run something like this:

lftp -u user,password ftp://my.ftp.site.com -e "rm -r /my/target/dir/*; bye"
]]>
Mon, 21 Sep 2015 00:00:00 +0200
http://richard.smith-sa.com/2014/03/03/exif_data_analysis_spreadsheet.html http://richard.smith-sa.com/2014/03/03/exif_data_analysis_spreadsheet.html <![CDATA[Exif data analysis spreadsheet]]>

Exif data analysis spreadsheet

Lately I’ve been debating my next lens purchase and trying add a bit of objectivity (not particularly easy) to the process. I started out wanting to do get some simple info on common focal length usage and came across ExposurePlot, however it doesn’t work with Canon raw files. I subsequently discovered the excellent ExifTool which works with just about every image format known to man.

I’ve put together a simple Excel spreadsheet to pull in data from ExifTool in CSV format and display a few charts based on the sliced and diced data. It is fairly easy to use:

  • Run the batch file to dump the data to CSV.
  • Refresh the data connections in Excel.

You get some nice charts to play around with:

../../../_images/exif_data_analysis_spreadsheet_1.png

You can grab the spreadsheet and batch file here. N.B. This is released as is without warranty of any kind. Use at your own risk. You’ll need a copy of ExifTool in the same folder. Run the batch file passing in the folder where the images you would like to analyse are; then open the spreadsheet and refresh all.

]]>
Mon, 03 Mar 2014 00:00:00 +0200
http://richard.smith-sa.com/2014/02/18/profiling_a_unit_test_in_vs2012.html http://richard.smith-sa.com/2014/02/18/profiling_a_unit_test_in_vs2012.html <![CDATA[Profiling a unit test in VS2012]]>

Profiling a unit test in VS2012

Just a quick useful tip, you can run the Visual Studio profiler on a unit test. It’s fairly well hidden but you can access it by right-clicking on a test in the “Test Explorer” and selecting “Profile Test”:

../../../_images/profiling_a_unit_test_in_vs2012_1.png

Very useful and well hidden feature.

]]>
Tue, 18 Feb 2014 00:00:00 +0200
http://richard.smith-sa.com/2013/12/31/some_photos___a_simple_flickr_gallery.html http://richard.smith-sa.com/2013/12/31/some_photos___a_simple_flickr_gallery.html <![CDATA[Some photos & a simple Flickr gallery]]>

Some photos & a simple Flickr gallery

I have recently gotten back into photography and am slowly building up a collection of images on Flickr. For now it is mostly wildlife shots but as I work through the backlog in Lightroom you can expect a bit more variety.

I figured it would worth it to show some of these photos on the blog so I put together a quick and dirty gallery of my photostream using jQuery and the Flickr Api. You can check it out at Photography.

It relies on inserting raw HTML into the reStructuredText source of the blog at build time. You achive this by using the immensely useful “raw” directive:

.. raw:: html
    :file: gallery.html

Apart from that it was fairly easy to use the getPublicPhotos call to retrieve the photostream and then use jQuery to build up the gallery (each and getJSON).

]]>
Tue, 31 Dec 2013 00:00:00 +0200
http://richard.smith-sa.com/2013/07/24/runtime_architecture_detection___dllimport.html http://richard.smith-sa.com/2013/07/24/runtime_architecture_detection___dllimport.html <![CDATA[Runtime architecture detection & DllImport]]>

Runtime architecture detection & DllImport

I have been playing around with the excellent Math.NET Numerics lately and wanted to see if I could use native MKL libraries with our product. A requirement of this would be that we could ship an Any CPU version of the application and detect which native library to load. Normally this is fairly easy with .NET assemblies as you can just hook into the AppDomain.AssemblyResolve event. You then do something like this:

private Assembly currentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
    Assembly asm = null;
    string appPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
    string asmName = string.Format("{0}.dll", args.Name);
    string asmPath = string.Empty;

    if (Environment.Is64BitProcess)
        asmPath = Path.Combine(appPath, "x64", asmName);
    else
        asmPath = Path.Combine(appPath, "x86", asmName);

    if (File.Exists(asmPath))
        asm = Assembly.LoadFile(asmPath);

    return asm;
}

This unfortunately doesn’t work with unmanaged assemblies referenced with a DllImport attribute. These assemblies are loaded using the standard windows loader which lives outside .NET. What you can do however is use the SetDllDirectory system call to insert an additional search path for the windows loader before loading takes place. You can then call SetupNativeSearchPaths on start up (or some other time before the unmanaged assembly is loaded):

[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetDllDirectory(string pathName);

public static bool SetupNativeSearchPaths()
{
    string appPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
    string asmPath = string.Empty;
    if (Environment.Is64BitProcess)
        asmPath = Path.Combine(appPath, "x64");
    else
        asmPath = Path.Combine(appPath, "x86");

    return SetDllDirectory(asmPath);
}
]]>
Wed, 24 Jul 2013 00:00:00 +0200
http://richard.smith-sa.com/2013/06/14/new_theme___tinkerer_update.html http://richard.smith-sa.com/2013/06/14/new_theme___tinkerer_update.html <![CDATA[New theme & Tinkerer update]]>

New theme & Tinkerer update

Tinkerer has released V1.2, I’ve just updated to the latest version and the new “flat” theme.

]]>
Fri, 14 Jun 2013 00:00:00 +0200
http://richard.smith-sa.com/2013/05/29/installing_pip_on_windows.html http://richard.smith-sa.com/2013/05/29/installing_pip_on_windows.html <![CDATA[Installing pip on windows]]>

Installing pip on windows

Quite often Python projects recommend the use of pip for installation. For example tinkerer recommends that you install using:

pip install tinkerer

The problem is that pip and it’s dependency distribute aren’t supplied with the default Python install on windows. Additionally a simple there isn’t a convenient windows equivalent of:

sudo apt-get install python-pip

It took some figuring out how to get hold of pip and its dependencies on a windows machine. I’ve listed the steps required below.

Read more...

]]>
Wed, 29 May 2013 00:00:00 +0200
http://richard.smith-sa.com/2013/05/28/first_steps___.html http://richard.smith-sa.com/2013/05/28/first_steps___.html <![CDATA[First steps...]]>

First steps...

I’ve decided to try and capture the various interesting (or not so interesting) things I discover on a day to day basis. Additionally this should give me a chance to learn a bit more about python and web development on the side (I’m primarily a C# developer who works on a desktop/server based platform). So far it looks like I’ll be running this blog using Tinkerer and hosting it on App Engine. I should have some details of the setup process up shortly.

]]>
Tue, 28 May 2013 00:00:00 +0200