Recently I found a nice use for Proxies when writing tests however the nodeunit runner doesn't support the --harmony-proxies parameter a small runner was created to allow us to run tests with working Proxy support. Just create a small script that looks something like this.
And invoke it using: node --harmony-proxies runtests.js $(find ./tests -name \*.js)
A while back i got a Yubikey Neo and a Neo-n they are cool little devices that can work as the second part of a 2 factor authentication. The Neo apart from usb also supports Nfc so it can be used with most modern Android phones. So here's a short summary of how to get it all working. To get everything to work you need to install the KeeChallenge plugin in KeePass, I used the latest version (2.29) when setting everything up. The trick is to put the password file on something shared that everything can read usb stick, Dropbox or similar.
To log status for my home server running ubuntu I modified my status script, this is logged every 5 minutes.
Ping & packet loss is logged with a simple ping script, right now it only pings googles public dns but is should be extended to ping multiple things (isp dns server etc) currently this script runs every minute
I plan to add more fun sensors that work with Tellstick, things like rain and wind sensors. Something that logs how bright the sun is would be cool to. At some point when I have more info it will be fun to do some 'big data' stuff using the data set I have, right now it's been running for about 6 months so next year it's possible to graph current vs last year for many values.
So when using AutoMapper after step one I ended up with something like this
Some background, for the destination SomeSource I needed to Deserialize the value as it was currently stored as Json in my database.
Make it pretty
While it works it looks rather horrible, so I started looking into something that allowed me to get a ISerializer from AutoFac (my IoC of choice) instead.
So, first I added a custom ValueResolver that looked like this
Next was to connect AutoMapper with AutoFac and to register the ValueResolver:
Once that is done the last thing to change is to modify the ForMember call to use the new ValueResolver instead
Looks a lot cleaner and follows the flow that you would expect when using a IoC container.
If you don't want to have calls to the static Mapper.Map<> all over your code, it is possible to register the IMappingEngine in AutoMapper in you IoC container and have that as an dependency for you class too. For AutoFac the registration looks like this
The important thing is to register it as a singelton. Once that is done just add IMappingEngine mappingEngine to the constructors of those classes that use AutomMapper.