20130801

Firefox Feedly RSS option

If you use Firefox with a RSS button and want the default RSS page to offer a Feedly option here is what you need to do:
  • go to the about:config page
  • search "browser.content" without the quotes
  • replace one of the options you never use with feedly by
    • changing the title
    • changing the uri to
      • http://cloud.feedly.com/#subscription%2Ffeed%2F%s

It should look something like this:

Firefox Feedly Config

20130217

How you tell a good IT job from a bad one

Anybody in the IT industry eventually hears about the Joel Test.

I don't think that all of those things always apply to all IT jobs, but if you don't have most of them it is a pretty good sign there might be something wrong there.

There used to be an even better resource on a post on Stack Exchange that went about it from the other way, a list of red flags called the Anti Joel Test (don't bother to click, like a lot of things these days Stack Exchange mod farmers have removed it after over a year of upvotes).

You can find some of the original contents in the internet archive if you care to look.  The least difficult to read version seems to be the 2010 crawl.

Since I was using this like periodically in discussions and it is effectively dead, I thought it might be useful to preserve the main points here.  This is more or less in the order it was in the archived version skipping some of the responses that were effectively jokes:

  • Does the company insist on being very process heavy?
  • Do you do your development work on the live production server?
  • Do web filters block out forums making it difficult to research online?
  • Is the work environment noisy making it difficult to concentrate?
  • Is the work schedule an inflexible 8-5?
  • Do they expect tier 1 support in addition to your programming duties?
  • Does management have no true understanding of development?
  • Despite this, does management "think" they know development?
  • Do they fail to provide an outlet for being creative?
  • Do they fail to provide adequate development hard/software?
  • Do they deny developers admin rights to their own box?
  • Is there a dress code which includes a suit and tie? (or other customer facing dress code req's)
  • Is the chief technology officer an accountant?
  • Do developers have to account for their time in small increments?
  • Is refactoring discouraged?
  • Is the development team driven and controlled by sales people?
  • Do you usually promise to create the documentation after the software is finished?
  • Do you hire cheap people because they cost less?
  • Do you let inexperienced people create new products, but experienced people finish and maintain whatever is created?
  • Are strategic alliances (instead of technical merits) the main argument for resp. against the use of a technology?
  • Does your source control consist of physically backing up your source tree into a source.backup.n directory every time you want to make too many changes?
  • Does management think that paying a consultant to teach on-site classes is the most effective way for developers to learn a new technology?
  • Is there at least one case where a single person unilaterally makes software architecture decisions for more than three simultaneous, ongoing, non-trivial projects?
  • Is the coding standard an inviolable straitjacket that serves to hinder rather than inform?
  • Is StackOverflow blocked at work?
  • Would management view time off to speak at a conference or other technical gathering relevant to your work as suspicious and/or unconditionally refuse it?
  • Do developers feel frustrated or stymied by managerial/organizational problems more often than technical ones?
  • You're required to use IE6 at work. And you do web development.
  • Did the last developer you hired leave quickly? Usually high turnaround in IT means at least one of two things: A) The code is wretched and unmaintainable, and/or B) Management has highly unrealistic expectations about programmers.
  • Also: Does the team not care about learning new things, experimenting with new technologies and at the very least check out what's "new" in their programming world? If they are like this then it means the team is a bunch of incompetent Morts and are mediocre at best.
  • Is the primary development language an in-house only product?
  • Do I need to work weekends just before a big release?
  • Is access to the internet blocked at work?
  • Are they inflexible about letting you work from home occasionally?
  • Does the management do task effort estimation?
  • Was it too easy for you to get an offer from the company? (All you had to do during the interview was to explain quicksort)
  • Does the average developer have more than 3 hours of meetings a week?
  • Are working hours strictly enforced? Am I supposed to work 9-5 daily with no exceptions?
  • Do you only release a product if there aren't any more known bugs?
  • Is my manager non-technical?
  • Are there more than 3 people who can assign work to me without any approval?
  • Is the coding standard an inch thick?
  • no coffee or crappy coffee indicates a lot. It says to me that a company would rather do the bare minimum to pacify employees than to spend a bit more and make them happy
  • Do you expect developers to serve support requests while doing project work?( Do you let the urgent override the important?)(without accounting for the time lost to project work)
  • Are your developers unhappy?
  • Do they hire developers primarily based on academic degrees?
  • unpaid overtime a regular occurrence, and nothing is being done to change that
  • rules set in stone, even if the programmer have a good reason to break them
  • Do employees from multiple departments without an ownership stake in technology make suggestions about programming techniques or implementation details and expect to be taken seriously
  • management judges projects by their costs only and are unable to judge them by their value earned
  • Are developers regularly asked to complete numerous training courses prescribed by management to tick some bigger company-wide goal that is completely irrelevant to what developer is paid for
None of that list is really my ideas, but this is something I think about on and off since the unnecessary death spiral experience of one of my previous employers and enough time has passed I think I should be able to look at it a bit more objectively and learn something.

20120609

Generic Windows Service Host

Windows services are pretty useful, but debugging them from visual studio can be kind of a pain and repeating all the service and installer guts in every one gets a little old if you have to do very many of them.

Below is a console app that hosts a library as a service.  It can also run the service as a console app so you can F5 debug straight from studio and it has the ability to install and uninstall the service.

using System;
using System.ComponentModel;
using System.Configuration.Install;
using System.IO;
using System.Linq;
using System.Reflection;
using System.ServiceProcess;
using thisproject.Host;
using System.Diagnostics;
 
namespace ConsoleServiceBase
{
 
    //this file is in the order it is to prevent you from using the designer.  do not reorder.  C# insits this is a designer file incorrectly, but it wasn't worth switching to VB to correct that
 
    /// 
    /// Static class that allows the executable to locate the library to run that is a descendant of ConsoleServiceLibrary
    /// 
    internal static class ServiceWorkLibraryFinder
    {
        private static Type LibraryType;
 
        internal static Type FindWork()
        {
            if (LibraryType == null)
            {
                foreach (FileInfo f in (new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory)).GetFiles("*.dll"))
                {
                    var a = Assembly.LoadFrom(f.FullName);
                    LibraryType = a.GetTypes().FirstOrDefault(x => x.IsSubclassOf(typeof(ConsoleServiceLibrary)));
                    if (LibraryType != nullbreak;
                }
            }
            return LibraryType;
        }
    }
 
    //do not move this class to the top of the file - the designer is not to be used on this class
 
    /// 
    /// Service Installer class for the /install /uninstall command line options of the ServiceConsole
    /// 
    [RunInstaller(true)]
    public class CustomServiceInstaller : Installer
    {
        public CustomServiceInstaller()
        {
            var WorkType = ServiceWorkLibraryFinder.FindWork();
 
            ServiceProcessInstaller serviceProcessInstaller = new ServiceProcessInstaller();
            ServiceInstaller serviceInstaller = new ServiceInstaller();
 
            //# Service Account Information
            serviceProcessInstaller.Account = ServiceAccount.LocalSystem;
            serviceProcessInstaller.Username = null;
            serviceProcessInstaller.Password = null;
 
            //# Service Information
            serviceInstaller.DisplayName = WorkType.FullName;
            serviceInstaller.StartType = ServiceStartMode.Automatic;
            serviceInstaller.ServicesDependedOn = ((ConsoleServiceLibrary)Activator.CreateInstance(WorkType)).ServicesDependedOn;
            serviceInstaller.ServiceName = WorkType.FullName;
 
            this.Installers.Add(serviceProcessInstaller);
            this.Installers.Add(serviceInstaller);
        }
    }
 
 
    /// 
    /// ServiceConsole is a console app that can also run as a windows service.  It does no meaningful work on its own but will run the first library that is a descendant of ConsoleServiceLibrary in its filesystem path when run.
    /// 
    class ServiceConsole : ServiceBase
    {
        private static Type WorkType = ServiceWorkLibraryFinder.FindWork();
        private static ConsoleServiceLibrary WorkInstance;
 
        public ServiceConsole()
        {
            this.ServiceName = WorkType.FullName;
            this.AutoLog = true;
            WorkInstance = (ConsoleServiceLibrary)Activator.CreateInstance(WorkType);
        }
 
        protected override void OnStart(string[] args)
        {
            WorkInstance.NonBlockingStart();
            base.OnStart(args);
        }
 
        protected override void OnStop()
        {
            WorkInstance.BlockingStop();
            base.OnStop();
        }
 
        // The serviceinstaller is missing the bit to set recovery options, this does it through sc.exe.  It will always restart on fail after 60 seconds.
        static void SetRecoveryOptions(string serviceName)
        {
            int xCode;
            using (var process = new Process())
            {
                var startInfo = process.StartInfo;
                startInfo.FileName = "sc";
                startInfo.WindowStyle = ProcessWindowStyle.Hidden;
 
                // tell Windows that the service should restart if it fails
                startInfo.Arguments = string.Format("failure {0} reset= 0 actions= restart/60000", serviceName);
 
                process.Start();
                process.WaitForExit();
 
                xCode = process.ExitCode;
 
                process.Close();
            }
 
            if (xCode != 0)
                throw new InvalidOperationException();
        }
 
 
        static void Main(string[] args)
        {
            if (Environment.UserInteractive)
            {
                if (args.Contains("/install"))
                {
                    (new AssemblyInstaller(Assembly.GetExecutingAssembly(), new string[] { AppDomain.CurrentDomain.BaseDirectory })).Install(null);
                    SetRecoveryOptions(WorkType.FullName);
                    (new ServiceController(WorkType.FullName)).Start(new string[] { });
                }
                else if (args.Contains("/uninstall"))
                {
                    try
                    {
                        (new ServiceController(WorkType.FullName)).Stop();
                    }
                    catch (Exception)
                    {
                    }
 
                    (new AssemblyInstaller(Assembly.GetExecutingAssembly(), new string[] { AppDomain.CurrentDomain.BaseDirectory })).Uninstall(null);
                }
                else
                {
                    //be a debuggable console app
                    Console.WriteLine("add /install to the command line to install and run as a service");
                    Console.WriteLine("add /uninstall to the command line to stop the service and uninstall");
                    Console.WriteLine("");
                    var p = new ServiceConsole();
                    p.OnStart(null);
                    Console.WriteLine("running - press enter to kill...");
                    Console.ReadLine();
                    p.OnStop();
                }
            }
            else
            {
                //be the service
                ServiceBase.Run(new ServiceConsole());
            }
        }
    }
}

If you compile and run the executable it will detect that you are in userspace and run as a console app.  If you run it with the /install flag it will set itself up to run as a service.  The /uninstall removes the service.  The easiest way to set this up in studio is to make a console project then replace the main program class with the code above IMHO.

This by itself doesn't really do anything,but the first code references a class called ConsoleServiceLibrary which looks like this:


namespace thisproject.Host
{
    /// 
    /// Inherit this class to create a library that can be run by the ConsoleServiceHost
    /// 
    public abstract class ConsoleServiceLibrary
    {
        /// 
        /// override this method with something that starts the process and immediately returns control to the host
        /// 
        public abstract void NonBlockingStart();
 
        /// 
        /// override this method with something that signals the worker process to stop then does not return until stoppage is complete
        /// 
        public abstract void BlockingStop();
 
        /// 
        /// override this to return an array of services this service depends on.  Names must be ServiceNames not the friendly DisplayNames
        /// 
        public abstract string[] ServicesDependedOn { get; }
    }
}


This class also goes in the consoleproject.  Once you have built the console project you can set it as an external reference to separate projects (I usually use dll projects for the descendants) then inherit and implement the abstract class.  When the secondary project is built you just run the console executable that gets put in the bin directory and it will pick up and run the first dll that has a ConsoleServiceLibrary implementation in the same directory.  For the F5 goodness you need to set the dll project to start the console app out of bin\debug manually.

There are a couple limitations in this version that I do not mind, but you may:
  • there can only be one service dll in the folder with the host exe
  • the descendant dll doesn't end up being able to use a normal app.config easily because of the names and the path issues services bring.
  • the descendant type name will be the service name
  • the service always installs to run as system
This approach is something I needed  to be able to debug easily, deploy with simple scripts and file copy, hide the service weirdness from some of my coworkers who are really more asp devs than internals devs, and to make a big set of services quickly that all behave the exact same way from the servicehost side of things.  I mostly worked this out through trial and error and reading the msdn docs and code blogs over the years so there are probably better ways of doing some of these things.

20120425

simple js geolocation test

Nothing really special here, js Geolocation pulling a static google map image as a very simple example to test some browser settings.  See the code below or run the example here.

You Are Here:<br />
<img id='gmpsimg' />

<script type="text/javascript">
 if (navigator.geolocation) {
  var timeoutVal = 10 * 1000 * 1000;
  navigator.geolocation.getCurrentPosition(
    gmp, 
    showerror,
    { enableHighAccuracy: true, timeout: timeoutVal, maximumAge: 0 }
  );
 }
 else {
  alert("Geolocation is not supported by this browser");
 }

 function gmp(position) {
  document.getElementById('gmpsimg').src = 
  'http://maps.googleapis.com/maps/api/staticmap?markers=color:blue%7Clabel:X%7C'
  + position.coords.latitude + ',' + position.coords.longitude +
  '&zoom=17&size=400x400&sensor=true&maptype=hybrid';
 }

 function showerror(error) {
  var errors = { 
    1: 'Permission denied',
    2: 'Position unavailable',
    3: 'Request timeout'
  };
  alert("Error: " + errors[error.code]);
 }
</script>

20110611

New Job

Monday I start at Excellence in Motivation. They make marketing and performance improvement programs.  They seem to be headed in a good direction and are much closer to home.  More than 50 miles closer, so I really couldn't turn that combo down now that my son is old enough to start asking where I am all the time.  There is also a pretty good chance at this place I can keep what most people would consider a normal schedule for the first time in my career.

Thanks to everyone that was sending leads, and if any of you are currently looking I have a few I didn't even get a chance to interview for I can pass along.