Friday, September 04, 2015

Remote Editing of Files with Emacs Through a Proxy on Windows 7

I've always loved emacs for editing files on remote machines.  I started with Ange-ftp, then tramp,  and then plink.  Now with blocked ports and a proxy to navigate, I've upgrade to plinkx.
With plinkx you can fiddle with the setting in PuTTY to get everything perfect and then use the PuTTY saved session in Emacs.
This is much easier than trying to set all the communication protocols in lisp.
Here's some setup code from my .emacs file.  The tricky part is that the tramp-default-host is the name of your saved session.

             (require 'tramp)
             (setq tramp-default-method "plinkx")
             (setq tramp-default-user "myUserName")
             (setq tramp-default-host "f");;the Saved Session from PuTTY.  See below.
             (setq tramp-verbose 10)
             (setq tramp-debug-buffer t)
             (setq password-cache-expiry nil)

Now it works great!

Thursday, July 23, 2015

WebDAV error "HTTP Error 405.0 - Method Not Allowed" using WebAPI

This morning I ran into this error on our .Net WebAPI project:

 "HTTP Error 405.0 - Method Not Allowed. The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used."
"This error means that the request sent to the Web server contained an HTTP verb that is not allowed by the configured module handler for the request."

This is after we did the excellent fix suggested at

The problem turned out not to be that the handler was not configured to handle a GET, but that my routing was ambiguous. I edited WebApiConfig.cs and modified the routing to be more specific. Now it works like magic.

(Note to Microsoft: Not to be whiny, but would it be so hard to give us an error like, "ambiguous route"?).

Monday, July 13, 2015

Photos from Austin .Net Users Group July 13, 2015

David McCarter talked to 55 people about 10 things to do to improve your code. David has many years of experience so it was interesting to hear his thoughts.
His contacts:: website:, email:, twitter: @realdonetdave

His tips for writing good code:
* Layer your code. Typical layers: Data, Business, Communications, UI
* Design for occasional internet connection. Why can't I post on Facebook when I don't have a connection?
* Make your app faster. Cache long running reports, use cloud based region data centers. Make "chunky not chatty" calls over the net. (Visual Studio 2015 will make performance issue better)
* Most of your code should be in portable dlls. Only code in client app loads data and interacts with the user.
* Check out IntelliTests in VS 2015.
* 3 Pillars of Object Oriented Programming: Encapsulation, Inheritance, Polymorphism
* Only application should log errors, not the dlls.
* Exceptions and Event Logging. His open source logging utility to fix the problems in .Net's trace logging: dotNetTips.Utility.Logging. Log Severity, Category, CLR version, free physical memory, virtual, OS.
* Internationalization string birthDate = p1.BirthDate.ToString(CultureInfo.CurrentCulture);
* Introduction to Localization and Globalization in .NET by Jeremy Clark on
* Store format string in Properties.Resources.UserInfoFormat "birthday:{0}, name: {1}"
* Use Strong Naming to prevent spoofing
* David Recommends CodeItRight which finds and fixes errors.
* Use code obsfication, but not the free microsoft one, but buy a commercial obsficator.
* Stop the copy and paste nightmare
* Use code analysis e.g., FXCop
* Use application profiling for memory and performance

Tuesday, June 09, 2015

Austin .Net User Group Pictures from June 8, 2015

Chander Dhall spoke to the Austin .Net Users Group last night about JavaScript. Here's two pics. The room actually filled up after I took the first one so it was Standing Room Only. Chander was an entertaining speaker and really showed how JavaScript is really weird. My cryptic notes for the evening:
Use Xamarin tools for coding Android and iOS apps in C# has lots of tech videos.
Chander had no powerpoint, just raw code.
JavaScript is not going anywhere.
Angularjs is having problems, so reactive is getting some traction to replace angular.
You really need to understand the weirdness of JavaScript - frameworks are not going to solve your problem.
The answer is IIFE.

How to remove Perforce from the right-click context menu in Windows 7

When I right-clicked on a file in Windows Explorer it took an agonizing 8 seconds for the context menu to appear. I noticed that "Perforce" was in the context menu.

 I tried to go to the control panel and modify the P4V installation to remove it, but windows whined about not being able to find a log file. No dice.

So I did the next best thing. I renamed the actual program from P4EXP.dll to something else in C:\Program Files\Perforce\P4EXP. My context menu now appears in under a second.

I'll let you know if this causes downstream perforce weirdness, like files with two heads or three arms.

Wednesday, May 20, 2015

Windows 7 Outlook issue: "ost is in use and cannot be accessed".

I got to work early today, ready to get to work, and was greeted with this cheery note from my Windows 7 box when opening Outlook:

"The file C:\Users\username\AppData\Local\Microsoft\Outlook\username.ost is in use and cannot be accessed. Close any application that is using this file, and then try again. You might need to restart your computer."

Restarting the box did not help. I had to open the "Windows Task Manager" (Ctrl-Shift-Esc), select "Lync.exe" and kill it (you might also need to kill "Communicator", "ucmapi", or "Outlook" itself). Then Outlook was happy and I could start my day.

This morning's ambush reminds me of Cato hiding in wait for Inspector Clouseau to return so Cato can attack him, just to keep Clouseau sharp.

Friday, May 15, 2015

Testing .Net C# WebAPI methods with NUnit and HttpResponseMessage

I recently wrote my first NUnit test for a .Net WebAPI controller. I learned two interesting things. (The code has been simplified to be more explicit).

1. When you create your controller, set a value for it's "Request" object.

//helper function to create testable "projects" controller
private ProjectsController GetTestProjectsController()
    ProjectsController controller = 
         new ProjectsController(logger, new ProjectRepository())
        Request = new HttpRequestMessage()
            Properties = { { HttpPropertyKeys.HttpConfigurationKey, 
                 new HttpConfiguration() } }
    return controller;

2. When retrieving an object use the TryGetContentValue() method to extract the returned value as a C# object. Notice on line 18 we free the C# object from the clutches of the evil HttpResponseMessage object.

public void GetTestWithExistingProjectName()
    string projectName = "GetTestWithProjectName";
    var projectRepository = new ProjectRepository();

    // Arrange
    DeleteProjectIfItExists(projectRepository, projectName);
    var newTestProject = CreateNewTestProjectAndWriteToRepository(projectName,projectRepository);
    var controller = GetTestProjectsController();

    // Act
    HttpResponseMessage httpResponseMessage = controller.Get(projectName);

    // Assert
    Project project = null;
    httpResponseMessage.TryGetContentValue(out project);
    Assert.AreEqual(projectName, project.Name);

    DeleteProjectIfItExists(projectRepository, projectName);

This is the code for the api GET.

public HttpResponseMessage Get(string name)
    var project = _projectRepository.GetProjectByName(name);
    if (project != null)
        return Request.CreateResponse(HttpStatusCode.OK, project);
    return Request.CreateErrorResponse(HttpStatusCode.NotFound, 
            "Sorry, the project '" + name + "' could not be found.");

Special thanks to the folks at for their awesome code highlighter site.