Wednesday, June 25, 2014

Notepad++ Save As Admin Plugin

I’ve used Notepad++ for a while now, but only recently started exploring all the various plugins that are available. One very helpful plugin is called “Save as Admin”, which can overcome a common issue when trying to edit files for which the local Users group does not have modify permissions. This often happens with web.config files, which by default live in a folder that only Administrators can modify. Even if you are a member of the Administrators group, you will still receive a “Save Failed” error message asking “Please check if this file is open in another program.” when you try and save any changes:

Please check if this file is opened in another program

If you check the permissions of the file, you will see the Users group only has read & execute, and does not have modify permission:

image

To fix this you have a few options:

  1. Close Notepad++ and re-open it as an administrator.
  2. Use the edit button on the security tab of the file properties to give the Users group or your individual user modify permissions.
  3. Save the file to another location like your desktop, and then copy from there into the destination folder. This will cause Explorer to display a “You must be an administrator to perform this action” window, but it will allow you to use your Administrator role to complete the action.
  4. Use the “Save as Admin” plugin in Notepad++ to elevate to the Administrator role and save the file.

If you have already made changes to the file and do not have the plugin installed, option 2 or 3 is the only way to keep those changes (the others require closing and reopening Notepad++). Once you install the “Save as Admin” plugin you can then use that to overcome any permissions issues.

To install the plugin open the Plugin Manager:

image

Type the letter S to find “Save as Admin” and check the box. You can install multiple plugins at once, and I recommend also adding “Compare”, “Reload"Button”, and “XML Tools”.

Save as admin plugin

Once you have selected the plugins you want press the Install button. It will download and install the plugins, most of which show up under the Plugins folder. When finished it will prompt you to restart Notepad++

image

NOTE: if you had pending changes to a file you may see the following:

image

There are actually two dialogs here, and the second one is hidden. You will need to click the grey bar behind the blue bar (or just click on Notepad++ in your task bar) to display the hidden window:

image

Here you should press no (loosing any changes) or yes and save to another location. Notepad++ should then restart. Now when you try to save a file that requires Administrator privileges you will get a UAC prompt:

image

Pressing Yes will allow Notepad++ to save the file using your administrator role.

Monday, January 6, 2014

Tx.Windows Parsing WC3 IIS Log files in LINQPad and PowerShell

I saw a tweet today from the @ReactiveX account about a new release called Tx (LINQ to Logs and Traces). It appears to have a lot of plumbing to use the Reactive Extensions (Rx) to parse through Event Logs and Event Tracing files. One of the slides on the Tx Codeplex site also mentioned parsing IIS W3C Logs, which is something I spend a fair amount of time doing.

Even better Tx has a custom LINQPad Driver, which is one of my favorite tools for playing around with LINQ and Rx. I downloaded the sample traces and was able to view low level event tracing details from the HTTP.sys driver used by IIS, but I didn’t immediately see how to parse the IIS log files using Tx. After downloading the source I found a W3CTest.cs file that showed how to parse log files using the Tx.Windows.W3CEnumerable.FromFile or FromFiles methods.

To use this in LINQPad you do NOT need the Tx Driver, but instead you use F4 to add a reference to the Tx.Windows Nuget package:

image

image

Once the reference is added to your LINQPad query, you may also want to add the following additional namespace imports:

image

This gives you access to the common LINQ functions used in the Tx samples. Now I can write a query in LINQPad that uses the W3CEnumerable to parse the log files. You can write complex LINQ queries or use the toDataGrid parameter of the Dump method to display the data in a grid format:

image

After I had it working in LINQPad, I next thought: “Why can’t I use this in Powershell?”. The Tx library targets .NET 4.0 and 4.5, so as long as you have PS 3.0 or later you can add a reference to the Tx.Windows.dll and then use the W3CEnumerable class to work with Log files.

#Load Tx.Windows.dll from current user’s LINQPad nuget local cache
[Reflection.Assembly]::LoadFile("C:\Users\$($env:username)\AppData\Local\LINQPad\NuGet\Tx.Windows\Tx.Windows.1.0.31229\lib\Net40\Tx.Windows.dll")

#Load log file and sent output to screen
$log = [Tx.Windows.W3CEnumerable]::FromFile("C:\inetpub\logs\LogFiles\W3SVC1\u_ex131230.log")
$log | select -Last 10 |  ft dateTime,cs_method,cs_uri_stem,cs_uri_query,cs_username,sc_status,time_taken

#Sent log to gridview
$log | out-gridview

image

The Gridview is very helpful since you can add filters to target specific entries similar to a LINQ query

image

All this in the first hour of playing with Tx! I am really excited to see if we can use Tx with IIS Failed Request Tracing or ASP.NET Tracing to track down issues in our .NET web apps.

Tuesday, February 12, 2013

Samsung Epic 4G CyanogenMod Notes and Links

Up until a few months ago I very much enjoyed having the Samsung Epic 4G as my personal phone. It is the best Android phone with full QWERTY keyboard that I have ever used, but the hardware is a bit dated and the WiMax speeds were not as fast as LTE, so I decided to upgrade to the Galaxy Note II on Verizon. Samsung stopped updating the software on the Epic 4G a while ago, but the CyanogenMod community has done a great job at supporting the phone and even has Android Jelly Bean 4.1 ROMs with full functionality. I still have friends with the Epic 4G so I thought I would post all the links I used for loading custom ROMs.
Most recent versions (As of January 2013)

Sprint has Steps to activate phone, which includes instructions for activating a used phone. These may not work in CM 10, but I usually put a temporary boot ROM on the SD card that will boot into the stock FC09 ROM
Temporary Stock Boot Instructions:
  1. Boot into CWM5 on your Epic 4G
  2. Install zip from sdcard > choose zip from sdcard > multiboot > FC09 > boot_FC09.zip
  3. WAIT.  It will take a while to boot.  You might see a "com.android.phone is not responding", do not worry, it is harmless.  Wait until Media Scanning is complete before doing anything.
  4. Follow instructions for activating phone or calibrating tilt sensor
You can also revert the Epic 4G to original locked boot loader and stock ROM if you have any issues with the custom ROMs or have to take it in for service/support.
Hope this helps any Epic 4G users out there. If Samsung ever decides to make another Galaxy S phone with a keyboard definitely will consider buying it, but for now I am enjoying the Galaxy Note II with flygrip.

Wednesday, May 25, 2011

Looking for a .NET programmer in Salt Lake City, Utah? You should hire me!



UPDATE 6/01/2011: I have accepted a great position at GE healthcare that interestingly has very little to do with .NET and everything to do with making better software. I look forward to diving back into Linux and BASH scripting and am already having nightmares about Oracle!

UPDATE 5/15/2013: Although I am still working for GE (Now part of a joint venture with Microsoft) I am also actively looking for new challenges in Software Engineering or Developer Operations.

UPDATE 8/01/2013: No longer active on the job market. I have accepted a position with 3M Health Information System and am excited to bring some DevOps to a company most known for making office products :-P

UPDATE 7/14/2014: The examples in this post are a bit dated now (see full resume instead), but I occasional still get emails about job opportunities. I am happy at 3M but am always open to new opportunities involving .NET/SQL/Powershell. If the word Help Desk or Phone Support is in the job description though I will probably ignore any emails you send.

My 30 second over-hyped elevator pitch:
The most hirable man in the worldMost people don’t have the time to read through a full resume nowadays, so I’ll keep things short and to the point. You should hire me! Why? Because I am smart and I get things done. The last time I was in the job market I turned a 3 week software testing project into a 6 year pursuit helping to convert a small ISV into a cloud driven heavyweight. I don’t always code in .NET, but it is definitely my platform of choice. Life is too short to worry about pointers and memory leaks. If I wanted to do that I’d go back to working in assembly language on an 8086 like God intended. I can automate just about anything using a combination of BASH, PowerShell, AutoIT, VBA, WatiN, MSAA, a bunch of HWNDs, a packet sniffer, a few servos, and a roll of duct tape. I work well as part of the A-Team or sent out solo in the wild like Rambo. In short: I am the most hirable man in the world! :-P Keep coding my friends!

I live my life like an open book, indexed by Google. I have a thirst for knowledge and a passion for technology. I pay great attention to detail and strive for nothing less than perfection. A lot of my past projects are internal or backend systems, but below is a sample of what has kept me busy over the last decade or so.



Personal Coding projects:
PhraseMeme Scanner, WinFone Alpha (Windows Phone, 2010-2011)
Silverlight port of ZXing Barcode Scanning library (Silverlight, C#, 2010-2011)
Texas Holdem Monte Carlo Simulator (Silverlight, Windows Mobile, 2009)
Resolver one: Texas Holdem, Pivot Charts/Auto filter, Web page automation, WPF Charts, Mad Lib generator (IronPython spreadsheet, 2009)
GnuMap P2P Mapping project (Visual Basic, Web Spider, aiSee, 2002)




Samples of documents I have created:
High level overview graph (Visio 2007)
Detailed technical overview chart (Visio 2009)
In depth technical documentation (Word 2008)
Short section of web based training material (PowerPoint 2010)
Samples of feedback reports w/ synopsis (Acrobat 2006)
Memo to customers re: Software Upgrade (Word 2010)
Custom Reporting Tools using SOAP web service (C#, ClickOnce, Access, Excel 2009)
Raw Documentation Files (2006 – 2011, I created the majority of the documents on here)




Screencasts and videos of project I have created:
PhraseMeme scanner demo video (3 mins, Camtasia, PowerPoint 2010)
WinFone Alpha demo video (3 mins, Camtasia, PowerPoint 2010)
Texas Holdem Monte Carlo Simulator (5 mins, Camtasia, PowerPoint 2009)




Coding Competitions:
PhraseMeme Scanner received good rankings in Windows Phone 7 Competition sponsored by Red Gate (2010)
Texas Holdem app received honorable mention in 2009 INETA Code Challenge and 2009 Telerik Silverlight contest
Monte Carlo spreadsheet was the winner of $4,000 prize in April 2009 round of Resolver One Challenge

Monday, January 17, 2011

InvalidOperationException from IsolatedStorageSettings.Save on Windows Phone 7

I just had my first failed test from the marketplace certification for PhraseMeme Scanner v1.2. You can view the full error report here, but the important part is:

Comments: The application terminates unexpectedly when the user turns on/off one of the setting while trying to scroll to

another page.

Steps to reproduce:

1. Launch the application.

2. Scroll over to the setting menu.

3. At the same time, press and scroll on any of the settings.

4. Notice the application terminates unexpectedly when the user turns on/off one of the setting while trying to scroll to

another page.

The settings page uses ToggleSwitches from the Silverlight for Windows Phone Toolkit with a simple two-way binding to a values stored in an IsolatedStorageSettings class, so I was a bit confused where the error was coming from. Using Visual Studio I found that the IsolatedStorageSettings.Save method was throwing an InvalidOperationException whenever the user changed a setting and navigated way from the page at the same time.

The MSDN documentation doesn’t mention that the method can throw this error, but my guess is that either the value is in an indeterminate state or there is a conflict between the save method and the two-way binding. The error could have been there all along, but in this version I had moved all the IO calls to background threads to increase performance where as previously the exception was captured by a try/catch block on the calling method.

Luckily it was an easy fix: I added a try/catch statement to the save code block and inserted a delay to let whatever processing it was conflicting with finish before it tried to save the settings. Below is the new code that can be used for saving settings stored in an IsolatedStorageSettings class:

/// <summary>

/// Save settings to isolated storage. Will run using background thread to prevent blocking UI thread.

/// </summary>

public static void Save()

{

    ThreadPool.QueueUserWorkItem(func => {//Save items using background thread.

        try

        {

            //NOTE: may throw InvalidOperationException exception if user is in process of changing settings and navigating away from page

            System.Threading.Thread.Sleep(200);

            issSettings.Save();

        }

        catch (Exception ex)

        {

            Debug.WriteLine("Error saving settings: " + ex);

        }

    });

}

 

Hope that helps someone prevent a failed submission to the marketplace.

Monday, December 20, 2010

Enable Blogger Mobile Templates Support for WP7 and Opera Mobile

Blogger recently released a new feature to their Blogger in draft platform that allows the website to automatically detect mobile browsers and render the page using a small-screen friendly template. This fixes a HUGE issue I have been working on for the last few weeks ever since I released the PhraseMeme Scanner application, namely publishing content that will be consumed by both large and small screen devices. Previously I was planning on having two version of the website with one being optimized for mobile and one for desktop, but now I can store all the content on Blogger and use the mobile templates to render for small-screen devices.

The Show mobile template currently works with the default iPhone and Android browsers, but it does not work with the Opera Mobile, Pocket IE, or Windows Phone 7 Internet Explorer browsers. I assume there are other mobile browsers that also don’t work, but there is a simple way to add support for any browser by using JavaScript to redirect users.  Here is the code that I wrote to detect mobile browsers and redirect accordingly:

The templates work by appending a m=1 parameter to the blog URL or (m=0 to force full webpage on mobile devices), so all that the above code has to do is look for that parameter and add it if a mobile device is detected. You can add the above script to your blog using either the blog template or the HTML/Javascript Gadget. Adding it to the blog template will cause it to run before the page is fully loaded, but you should save your current template first to make sure you don’t mess anything up;

I added a feature request for Blogger to support more mobile browsers, but for now the above script should let you start using this amazing feature.

Wednesday, December 8, 2010

Windows Phone Barcode Library (Silverlight C# ZXing Port)

I have been working on a Barcode Scanning application for Windows Phone 7 for about 3 months now, but none of my efforts would have been possible without the prior work done by Google on the open source ZXing (“Zebra Crossing”) barcode scanning library. This library is released under the Apache License v2.0 and has spurred development of many different barcode scanners on many different platforms. The idea for PhraseMeme Scanner came when I saw there weren’t any good scanners available for Windows Phone 7 and then stumbled across the partial C# port of ZXing. Through a bit of testing I was able to modify the library to support Silverlight and Window Phone 7, and decided I would help push the library into a well maintained and supported state in the Silverlight world.

While the primary purpose for updating the library is to build the "Best barcode scanning app available" I also want to give back to the community and help others create great windows phone or Silverlight apps. ZXing has their own Google Code project, but that site is mainly devoted to Android or Java development, so I decided to store the code on Codeplex to get it some .Net love. This also means that I can use Mecurial instead of SVN/CVS, which so far has been a great experience and should be very helpful if anyone else decides to contribute patches or new features to the library.

So without further ado, please check out the Windows Phone 7 Silverlight ZXing Barcode Scanning Library based on the csharp ZXing port created by Suraj Supekar at revision 1202 in the SVN repository. Let me know what you think, and happy coding!

Update 3/11/2011: It looks like the project is getting a lot of interest from developers with over 6,000 page views and 750 total downloads in the last few months. This is probably due to the various tweets on twitter and a blog post from Rudi Grobler about reading barcodes on WP7 using the Silverlight ZXing port. That blog post was mentioned on This Week in Channel 9, which totally made my day even if it was only talked about for 40 seconds and never even mentioned my name. Still… pretty wicked cool

Smile with tongue out

Blog.TheG2.Net - Your guide to life in the Internet age.