Technology Tamed

  • How to Find Application Pool by Process ID from within Visual Studio 2012

    5/5/2014 5:35:49 PM by tristan

    it’s always frustrating when commencing a debugging session of an IIS hosted application in Visual Studio having to try and identify which worker process to attach to when you have multiple sites running.

    Attaching the debugger

    To identify which process to attach to, I’ve long been a fan of the command “appcmd list wp” to find out which process ID is which application pool when debugging within visual studio;

    appcmd list wp

    More recently I got fed up with having to switch out of visual studio to my console window to run the command only to switch back into Visual Studio to get the debugger attached.

    There had to be a better way. A way to execute the command from within Visual Studio.

    In Visual Studio 2010 there was PowerConsole, a gallery extension that gave a Powershell prompt from within Visual Studio, but it isn’t supported in Visual Studio 2012. Researching further I came across a post on Stack Overflow related to Poweshell inside Visual Studio.

    The second answer gave me an interesting lead;

    “The NuGet Package Manager has a NuGet Package Manager Console which is a PowerShell host. Open the console by clicking Tools > Library Package Manager > Package Manager Console.”

    I didn’t know that. Interesting.

    Sure enough, a swift powershell command later;

    $appCmd = "$Env:SystemRoot\system32\inetsrv\appcmd.exe"
    &$appCmd list wp

    Package manager console

    Voila. Problem solved. Now I can quickly resolve the process ID of the application without having to leave visual studio. Happy days.

  • Miniprofiler, MVC and NHibernate

    5/5/2014 5:37:14 PM by tristan

    I’m unfashionably late to the party on this one. Whilst reading Professional MVC4 recently, Phil Haack mentions a NuGet package called MiniProfiler which his team found helpful in the development of the NuGet gallery. I made a mental note to have a look at.

    I’m not quite sure how I managed to miss this before as both Scot Hanselman previously blogged about this in his post NuGet Package of the Week #9 - ASP.NET MiniProfiler from StackExchange rocks your world as did K Scott Allen in ELMAH and MiniProfiler In ASP.NET MVC 4.

    The Essentials

    MiniProfiler was designed by the development team at Stack Overflow. It’s a simple but effective in browser mini-profiler for ASP.NET, WCF and the .NET platform. Once installed and properly configured, MiniProfiler adds a little widget to every page on your site when running in localhost. This widget initially indicates the time taken by the server to process the request ;

    Mini Profiler Widget

    Click on the widget and you’ll get profiling information for the current page. For example, below you can see that the a request to this site’s book review of dependency injection in .Net ran 5 SQL queries and spent 23.8% of the execution time in that SQL. 

    Mini Profiler Trace

    As a developer, Miniprofiler raises your awareness of what SQL statements are actually being executed. MiniProfiler will expose this information to you. Simply click on the “sql” links to see the generated SQL, as well as the containing method, as shown below. 

    Mini Profiler SQL Trace

    Adding support for MVC

    Adding the NuGet package MiniProfiler.MVC3 adds much better support for MVC applications by adding timing information for certain key points in the request life cycle, such as rendered views and partial views.

    Inviting NHibernate to the party

    NHibernate is a fabulous ORM, but it can have a tendency to disconnect the developer from thinking about the underlying SQL being generated and executed. definitely. NHibernate Profiler is great for this in a full on profiling/debugging session, but wouldn’t it be great to have this information more readily available?

    Out of the box MiniProfiler won’t integrate with NHibernate, but fortunately, there’s a NuGet package for that! Just install MiniProfiler.NHibernate and then configure our NHibernate session to use this connection driver;

    cfg.SetProperty(Environment.ConnectionDriver, typeof(MiniProfiler.NHibernate.MiniProfilerSql2008ClientDriver).AssemblyQualifiedName)

    Summary

    I don’t envisage that you’ll be replacing either dotTrace or NHibernate Profiler any time soon for detailed profiling/debugging, but to give you a quick overview of what’s going on Miniprofiler + MiniProfiler.MVC3 + MiniProfiler.Nhibernate is giving me a warm feeling thanks to these features;

    • Quick obvious performance information at your fingertips
    • Unobtrusive enough that it won’t annoy
    • Always present on the developer’s local machine so encourages some thought to be given to performance
    • Attractive, functional UI
    • Configurable if required to be enabled for remote access on production servers by user/role


    It’s now installed on my current client’s codebase and is already helping the multi developer team improve the performance and efficiency of the codebase. I recommend you use MiniProfiler on your project. For The Win.

  • Book Review – Professional MVC4

    5/5/2014 5:37:43 PM by tristan

    Professional MVC4 by Jon Galloway, Phil Haack, Brad Wilson and K Scott Allen, Published 2 Oct 2012

    Professional-MVC4 With an impressive list of contributing authors I had high expectation for this book and I wasn't disappointed.

    I've been enjoying developing in ASP.Net MVC for the last four years and felt that I would benefit from some more formal coverage of the new features, particularly Web API than I would achieve from just keeping in the loop on the blog scene. If you are an experienced MVC developer keen to explore the new functionality available in MVC4 then this book should should whet your appetite and although not all of the new features are covered in depth, for example the mobile project template, references are provided to point you in the right direction of resources to further your reading on the subject.

    It should be noted that although this book is suitable for programmers new to ASP.Net MVC and C# I wouldn't recommend it as a one stop study aid as it doesn't dive deep enough into examples of the more complex problems that you are likely to come across as an MVC web application developer.

    The book covers rather more than just MVC itself, with chapters devoted to dependency injection and unit testing.

    One minor complaint is that the source code referred to in the book can only be installed via 15 discreet nuget packages rather than just being able to download a zipped solution containing all of the code.

    Overall I enjoyed this book. Recommended.

  • Local Continuous integration

    5/5/2014 5:38:21 PM by tristan

    continuous integration Whilst on holiday recently I was catching up on some past episodes of dnrtv and was watching Jean Paul Boodhoo’s software craftsmanship bootcamp series. One of the things that caught my eye was JP’s use of a continuous build/testing script that monitored the codebase locally, on the development machine, for changes and upon detecting a change attempted to build the codebase and then run the tests using growl as the notifier upon success/failure.

    I was pretty intrigued by the concept of taking continuous integration to the local development machine.

    Think about it.. it’s a pretty extreme step downstream of the (now traditional) build server.

    So taking JP’s code I put it into action on the current codebase I’m working on. It worked… kind of. Due to the size of the enterprise level solution, the continuous build was pretty slow making the feedback loop uncomfortably laggy.

    Enter Redgate’s .Net Demon. I’d not heard of this tool before but it absolutely nailed the speed of the continuous build. .NET Demon compiles your code continuously replacing the Visual Studio build system. I won’t go into a full review of .Net Demon here as Gregor Suttie has already done a good job of this.

    The next task in achieving the goal of local continuous integration was to get the unit tests running running after the build.

    Enter the TestAfterBuild extension. This neat little extension will run your chosen test runner (Resharper, TestDriven, NUnit) after a successful build. In the case of resharper, it can rather usefully run only the tests in the current test session;

    image

    I’m really rather impressed by this trinity of .Net Demon, Resharper and TestAfterBuild. A journey that started out as an exploratory journey into local continuous integration has ended with a lightening fast build and the ability to run the tests I want upon completion of that build, and I haven’t even thought about committing yet.

    Naturally all of this extra tooling eats up your spare processor cycles but on a modern multicore setup I haven’t noticed a performance hit. 

    There are competitors such as NCrunch but already owning a Resharper license it was a no brainer to spend an additional £20 on the .Net Demon license.

  • Changing Screensavers on the Kindle Paperwhite

    3/2/2013 4:04:36 PM by tristan

    kindlecustomscreensaverblog

    I recently wanted to add my own screensaver to my new Kindle Paperwhite. Unfortunately this isn’t possible without jail breaking the Kindle first and then installing the screensaver hack. The process was pretty painless but I had to do some searching around to find all the resources so I thought I’d try and pull everything together in one place.

    You’ll need to follow the following steps in order

    1. Identify your firmware version
    2. Downgrade firmware to 5.3.1 if requires
    3. Install the jailbreak
    4. Upgrade the firmware
    5. Reinstall the Kindle developer certificates and the rescue pack
    6. Install the screen saver hack
    7. Create a screen saver
    8. Upload your screensaver


    Required Files
    Firmware version 5.3.1 (if you need to downgrade from a later firmware)
    The jailbreak
    The latest firmware version (Currently version 5.3.3)
    The developer certificates
    Kindle Python
    The screen saver hack

    1. Identifying your firmware version

    To determine your software version, from Home, tap Menu, then Settings. From Settings, tap Menu, then Device Info.


    If you see a version later than 5.3.1, proceed with the steps below to update your Kindle to the latest software.

    2. Downgrading the firmware to 5.3.1 if required

    This jailbreak cannot be installed on newer firmware versions newer than 5.3.1.  You have to downgrade to an older version (e.g., 5.3.1) first before installing the jailbreak, then update to the new version. The jailbreak as such will survive the update, but you have to reinstall the Kindle developer certificates and the rescue pack.

    1. Download version 5.3.1 software: Download firmware version 5.3.1

    2. Transfer software to your Kindle: Turn your Kindle on and connect it to your computer using the USB cable. Drag and drop the new update file from your computer onto the Kindle drive. Do not drop the file into one of the folders within the Kindle drive.

    3. Monitor file transfer and disconnect: Check your file transfer progress to ensure file transfer to your Kindle is complete before disconnecting. After the file has transferred successfully, eject the Kindle to safely disconnect your Kindle from your computer. Disconnect the USB cable from your Kindle and your computer.

    4. Start the software update: From Home, tap Menu, then Settings. Tap Menu, then Update Your Kindle. (This option will be greyed out if the most recent update has already been installed or if the file transfer was not successful.) Tap Ok if you want to perform an update. You will see Your Kindle is Updating.

    5. Once the update is complete: Your Kindle will automatically restart.

     

    3. Installing the jailbreak

    (Original thread here)

    Now that you have version 5.3.1 installed the Kindle is ready to have the jailbreak applied.

    1. Copy the "jailbreak.sh" and "MOBI8_DEBUG" files directly to the root directory of the attached drive (i.e., not into "documents" or any other directory).
    2. Copy the "jailbreak.mobi" file into the "documents" directory on the Kindle.
    3. Safely eject the "Kindle" drive, and disconnect the device.
    4. You will see a new document called "Paperwhite Jailbreak". Open this document. Make sure that you are viewing it in portrait mode.
    5. Follow the instructions in the document.

    There’s a good you tube video of running the jailbreak here

     

    Note that this jailbreak installs four components,

    The actual device jailbreak, i.e., the certificate which allows to install custom update packages.
    The Kindle developer certificates (re-installation required after firmware update!)
    The jailbreak bridge (enabling the jailbreak to survive the firmware update)
    The Rescue Pack. (re-installation required after firmware update)

     

    4. Update the the firmware back to 5.3.1

    Now that the Kindle is successfully jailbroken the firmware can be updated back to the latest version (currently 5.3.3). The process is the same as for downgrading.

    Download version 5.3.3 software: Download firmware version 5.3.3

    2. Transfer software to your Kindle: Turn your Kindle on and connect it to your computer using the USB cable. Drag and drop the new update file from your computer onto the Kindle drive. Do not drop the file into one of the folders within the Kindle drive.

    3. Monitor file transfer and disconnect: Check your file transfer progress to ensure file transfer to your Kindle is complete before disconnecting. After the file has transferred successfully, eject the Kindle to safely disconnect your Kindle from your computer. Disconnect the USB cable from your Kindle and your computer.

    4. Start the software update: From Home, tap Menu, then Settings. Tap Menu, then Update Your Kindle. (This option will be greyed out if the most recent update has already been installed or if the file transfer was not successful.) Tap Ok if you want to perform an update. You will see Your Kindle is Updating.

    5. Once the update is complete: Your Kindle will automatically restart.

     

    5. Reinstall the Kindle developer certificates and the rescue pack.

    Reinstalling the developer certificates: Upload the update_combined-dev-certs-20121002_install.bin file to the root directory of your Kindle. Now, eject your Kindle, and from Home, tap Menu, then Settings. Tap Menu, then Update Your Kindle. It should take a couple dozen of seconds.

    Reinstalling the rescue pack: Upload the update_rescue_pack.bin file to the root directory of your Kindle. Now, eject your Kindle, and from Home, tap Menu, then Settings. Tap Menu, then Update Your Kindle.

     

    6. Install the screen saver hack

    (Original thread here)

    To install the screen saver hack you’ll firstly need to install python for kindle and then the screen saver hack itself.

    Installing Kindle Python

    Upload the update_python_0.3.N_install.bin file to the root directory of your Kindle. Now, eject your Kindle, and from Home, tap Menu, then Settings. Tap Menu, then Update Your Kindle.

    Installing the screen saver hack

    Upload the update_linkss_0.7.N_install.bin file to the root directory of your Kindle. Now, eject your Kindle, and from Home, tap Menu, then Settings. Tap Menu, then Update Your Kindle.

    Once this has installed,  again connect your Kindle with the sync cable. The root directory should have a folder labeled /linkss/.

    2010-12-06_141212

    If you don’t see this folder that doesn’t mean the screensaver hack failed to install. You may need to do a hard reboot. Reboot your Kindle by navigating from Home, tap Menu, then Settings. Tap Menu, then Restart. Reconnect your Kindle and check the root directory once the restart is complete.

    The inside of the /linkss/ looks like below. The /backups/ folder contains the original screensavers from the default screensaver pack.

    The /screensavers/ folder is where you’ll upload your new screensaver images. The screensaver hack provides several options for shuffling and randomizing screensavers. Read the readme.txt documentation in the screensaver hack for full details.

    2010-12-06_141625

     

    7. Create a screen saver

    Kindle Paperwhite screen savers are 758x1024. When creating images for either device you want to work in 8-bit grayscale and save the images as .PNG files.

    8. Upload your screensaver

    Once you’re with your custom screensaver simply add it to the  /linkss/screensavers/ folder. That’s it! Enjoy your custom screensaver and be the envy of your friends :-)

  • What is Deft Industries?

    3/17/2013 8:43:31 PM by tristan

    Founded in September 2011 Deft Industries is the name of my limited company of which I am the sole director. Deft Industries provides software consulting and development services to companies requiring software solutions.

    Why Deft Industries?

    My name’s Tristan. Back in the day I used to DJ Hip Hop… Def T, DefT seemed like a natural choice of handle.

    Having settled on Deft I needed a descriptor. I considered “Deft Consulting”, “Deft Technologies” and “Deft Workshop” but none of these quite I had the ring I was looking for. I settled on “Industries”

    in·dus·try [in-duh-stree]

    noun, plural in·dus·tries

    1.the aggregate of manufacturing or technically productive enterprises in a particular field, often named after its principal product: the software industry
    2.any general business activity; commercial enterprise: the Italian tourist industry.
    3.trade or manufacture in general: the rise of industry in Detroit.
    4.the ownership and management of companies, factories, etc.: friction between labor and industry.
    5.systematic work or labor.

    Word History: Coming from the Latin word industria, meaning "diligent activity directed to some purpose," and its descendant, Old French industrie, with the senses "activity," "ability," and "a trade or occupation,"

    "diligent activity directed to some purpose" Bingo. So at this point, I had settled on the name, Deft Industries

    What about the logo?

    DTO01248 Visiting Detroit for the first time in Autumn 2011 I kept noticing the “Made In Detroit” logo. I really liked the design of the logo (left) with it’s heavy cog and image of a worker paying respect to the Detroit’s industrial origins.

    Some research on “Made In Detroit” uncovered further information on the origins of the logo “It was hatched in 1991 as a spark for a city that'd long been left for dead. It was born of a nod to the backbone that made this place unlike any other. It was built with a forearm, a hammer and a shop hat on a silhouette that stood ready to strike. It wasn't just a logo. It was a piece that paid a bit of respect to any industry that made America great and a direct link back to the city that fuelled it. It's not a logo that was made in a minute. It's not a mark that was made overseas. It's not a brand that was made in jest.” [ http://www.madeindetroit.com/pages/about-us ]

     

    warmth-logo6001Whilst in Detroit I also visited a number of record shops specialising in electronic music and noticed that a lot of them were selling merchandise bearing the name and logo “W.A.R.M.T.H.”

    Founded in October 2009 by the late Aaaron Carl, “W.A.R.M.T.H. (We Are Revolutionising the Movement of House and Techno) is a network of dedicated individuals, united to preserve the integrity of Detroit Electronic Music.” [http://www.facebook.com/warmth313/info] founded .

    The W.A.R.M.T.H. logo consists of two key elements, a clenched fist surrounded by a cog. The cog again referencing Detroit’s heritage in a similar manner to the Made In Detroit logo whilst the clenched fist has long been used as a symbol of solidarity and support. [http://en.wikipedia.org/wiki/Raised_fist]

     

    Creating the DefT Industries logo.

    Drawing on these two logos as inspiration I set about designing the logo for Deft Industries.

     cog

     

    When considering the cog used in the two reference logos, I got to thinking how a cog is in some ways binary in it’s nature, that the presence of a tooth represents a bit that is on, whilst it’s absence would represent a bit that is off. With this in mind I realised that I could, and would encode a hidden message in the cog of the Deft Industries Logo.. Starting at 12'o clock reading clockwise, we have 01000100011001010110011001010100, breaking this into bytes gives 01000100 01100101 01100110 01010100 which in ASCII spells DefT.

    cogwithfist

     

    Next I wanted to add the clenched fist, to symbolise solidarity and unity.

    As Brian from Spaced said, "What truer expression is there than the purity of a clenched fist?"

    cogwithfistandmouse

     

    At this stage I had the cog and I had the fist, but I still needed to add an element that would bring the concepts of technology and computing into the mix. In the same way that the Detroit worker held a tool of his trade I wanted an element that represented a tool of the software engineering profession. The addition of a mouse dangling from the the clenched fist seemed like a natural addition. The clenched fist radiating a sense of mastery over the captive mouse. Technology tamed.

    cogwithfistandmouseandtext

     

    Finally I wanted to add the name, “Deft Industries” and the tagline “Technology Tamed”. The /* */ was used to bring a direct reference to computer code in so far as the /* */ syntax is used to block comment out code in many programming languages such as C, C++, C#, Java, JavaScript, Objective-C and CSS. Block comments are generally those that use a delimiter to indicate the beginning of a comment, and another delimiter to indicate the end of a comment.

    The font choice was easy. Nothing speaks more loudly than Futura Condensed Extra Bold.

    So there we have it Ladies and Gentleman, I give you Deft Industries, Technology Tamed.

      Signature logo 2