tip of the day, aws s3, windows powershell comments edit

Cloud computing is a relatively new concept, especially when compared to FTP which dates back to 70s (History of FTP server). So not every device supports S3 uploads. If you cannot force a device to upload directly to S3 and have control over the FTP server machine (and assuming it’s running Windows) you can create a simple PowerShell script to upload files to S3.

FTP to S3

First you need to install AWS Tools for Windows. I tested on a couple of machines and the results were dramatically different. My main development machine is running Windows 8.1 and has PowerShell v4 on it. I had no issues with using AWS commandlets in this environment. The VM I tested has PS v2 on it and I had to make some changes first.

v2 vs. v4

The problem is AWS module is not loaded and you have to do it yourself with this command

import-module "C:\Program Files (x86)\AWS Tools\PowerShell\AWSPowerShell\AWSPowerShell.psd1"

After this command you can use AWS commandlets but when you close and open another shell it will be completely oblivious and will deny knowing what you’re talking about! To automate this process you need to add it to your profile. AWS documentation tells you to edit your profile straight away but the profile did not exist in my case. So first check if the profile exists:

Test-Path $profile

If you get “False” like I did then you need to create a new profile first.

To create the profile run the following command:

New-Item -path $profile -type file –force

then you can edit the profile by simply running

notepad $profile

Add the import-module command above and save the file. From now on every time you run PowerShell it will be ready to run AWS commandlets.

Time to upload

Now that we got over with troubleshooting we can finally upload our files. The commandlet we need is called Write-S3Object. The parameters it requires are the target bucket name, source file, target path, and the credentials.

Write-S3Object -BucketName my-bucket -File file.txt -Key subfolder/remote-file.txt -CannedACLName Private -AccessKey accesskey -SecretKey secretKey

Most likely you would like to upload a bunch of files under a folder. In order to accomplish that you can create a simple PowerShell script like this one:

$results = Get-ChildItem .\path\to\files -Recurse -Include "*.pdf" 
foreach ($path in $results) {
	Write-Host $path
	$filename = [System.IO.Path]::GetFileName($path)
	Write-S3Object -BucketName my-bucket -File $path -Key subfolder/$filename -CannedACLName Private -AccessKey accessKey -SecretKey secretKey


jekyll, site news comments edit

As you probably know I’ve migrated to GitHub Pages from WordPress as I blogged here.

It was a fairly easy migration but migrating the actual content proved to be trickier. There are lots of resources on using Jekyll’s importers. I found this one useful. Just export everything to an XML and run the converter to get the posts in markdown. The problem is the YAML Front Matter it generates is a bit messy:

layout: post
title: Blind Password Masking
date: 2011-06-14 03:46:18.000000000 +00:00
- Off the Top of My Head
tags: []
status: publish
type: post
published: true
  _edit_last: '1'
  login: blogadmin
  email: admin@myvirtualhome.net
  display_name: Volkan
  first_name: ''
  last_name: ''

I don’t want or need most of this stuff anyway!. Also I had two main issues:

  • Images didn’t work as it didn’t get the full path. I use S3 to host all images but the imported posts were converted to use a local assets folder. There may be a configuration setting for that but in my case I decided to convert all my posts to markdown from HTML anyway (which was a great way to practice Markdown)
  • Main issue was with Disqus. It’s not like people are racing to submit comments to my ramblings but still I’d like to have Disqus enabled on all my posts. Apparently to enable comments you need to specify it in the front matter like this:
comments: true

Manual vs. programmatical

First I resisted the temptation to write a small application to convert the layouts but manual conversion soon proved to be very time consuming even with 100+ posts. So I developed the simple console application below. It scans the folder you specify (filters *.markdown files) and reads the existing layout and converts it to the format I wanted:

layout: post
title: @TITLE
date: @DATE
categories: [@CATEGORIES]
comments: true

I wanted to keep it simple and clean. Also as all my posts are now in pure markdown I can easily loop through and update the elements (like converting H3 to H2 or adding tags to layout etc)

Source Code


It probably won’t apply to most situations but helped me out so why not publish it just in case, right? To use it you have to change the ROOT_FOLDER value in Program class at the bottom (Do NOT forget to backup your posts first!)

As I wanted to revisit all my posts I wanted to mark them instead of replacing automatically with the original one. So when you run the program it deletes the original post and creates the updated one with “.output” appended. So you can easily find which files are modified by checking the extension. If you want it to replace the original post you can uncomment this line at the end of the ConvertFile method

 // File.Move(outputFilePath, inputFilePath);


leisure, travel comments edit

Last Saturday, I went to Palace of Westminster for the first time. I had been around it a lot of times while playing Ingress and chasing portals but never been inside it.

I bought an audio tour ticket here and it did not disappoint.

Palace of Westminster

The building looks glorious from the outside but from the inside it’s absolutely amazing. Definitely the most beautiful and impressive building I have ever seen in my life.


Events comments edit

On Wednesday I attended this meetup. It was fairly informative. There is a bit uncertainty about the new features of Windows 10, Visual Studio 2015 and C# 6.0 but it was still good to cover most of them in a few hours.

It was divided into two main sections: Windows 10 and VS 2015/C# 6.0. I’m planning to review these myself and blog about them separately but here are the highlights of the events:

Windows 10

When they first announced the name I immediately thought about Winamp skipping version 4. We all know how that story ended so I hope Windows 10 fares better than that!

A few items discussed in the event about Windows 10:

  • First demonstration was sending a feedback which was painfully slow and it took forever to send a simple feedback message.
  • Some enterprise features are coming like like having store and custom company portals
  • There was a rather long discussion about what the 4 device from the left was in the image below: One Windows

I don’t think it makes any difference though but the idea is having one code base and one store to deploy apps to various devices with different form factors. Sounds cool but I’m a bit cautious about it for the time being. If it sounds to good to be true, it generally isn’t!

  • Looks like they are going to use hamburger icons everywhere which they initially opposed to.
  • There seems to be back buttons in a few screens which is a bit unusual so they may have to deal with some lash back from people like they did for their brilliant(!) charms invention.

Visual Studio 2015

Preparing for Windows 10 Event

  • There will be a free version of VS 2015 and there is already a free version for VS 2013 called “Community Edition”. It’s said to be Professional equivalent so it sounds cool to have it for free.
  • Like all Microsoft products versioning is a bit off and confusing here as well. There was a discussion about the version number vs. release year. So VS 2013 actually is version 12 but VS 2015 is version 14 even though there is no other VS in the middle!
  • A research project called Pex used to generate unit tests made its way to VS 2015 under Smart Unit Tests. It should help to create a lot boilerplate test code.

C# 6.0

  • Not a C# feature but one of the most impressive developments nowadays is that .NET Framework has become open source.
  • New version is coming with a much faster 64-bit compiler called .net RyuJIT
  • .net Native Project N is coming which is supposedly make the applications run faster
  • The compiler has been completely rewritten and its name is now Roslyn. It’s open sources and it exposes APIs that can be consumed by any application. So the compiler doesn’t have be a black box anymore.


A lot of exciting and revolutionary developments are going on in the .NET world these days. Taking a more open-source and multi-platform based approach will definitely help the platform in the future. It’s thrilling to be a developer and experience them first hand as these news come along. I have my virtual machine running Windows 10 and VS 2015 so I’ll play around more and blog about these specific features in detail in the near future.


Site news comments edit

On the road again…

Using WordPress for my blog had been bugging me for quite some time. So I’ve started using the popular static site generator Jekyll and host my blog on GitHub pages. Main reasons for this were:

  • Security: Over time you install a lot of plugins and any number of them can come with vulnerabilities. Granted they are optional and they are installed because they provide nice functionality but it would be much better to delegate the security of the system to GitHub.
  • Maintenance: I used to host my blog on AWS which is relatively easy to maintain but still I was responsible for keeping that machine up and running at all times.
  • Database: Using a database is overkill when all I’m doing is generating some static content. Database comes with performance impact, maintenance and backup requirements.
  • Scalability: No need to worry about scaling as GitHub takes care of it all for free!
  • Versioning: Just like any project on GitHub you have full control over the content and you can rollback to a previous version anytime.
  • Performance: All content is served in static pages. So compared to retrieving it from the database and generating the page on the fly it’s obviously much faster and scalable.

Beautifying the content

Compared to HTML, markdown is so elegant and concise. No more pesky attributes and ugly tags mingled with text. Granted WordPress has plugins for writing posts in Markdown but in GitHub it’s a first-class citizen and supported from the get-go.


  • WordPress has its own merits like having a gazillion of plugins and themes. GitHub Pages supports a limited number of plugins due to security reasons.
  • SEO must be taken care of manually whereas WordPress already has lots of plugins for that purpose too


csharp comments edit

yield keyword has been added to C# long time ago but I never made a habit of using it. Basically what it does is create an iterator and allows you to return an IEnumerable one item at a time.

For example in the example below (from MSDN) Power returns a single int. But the return type of the method is IEnumerable. This is because of the _yield_ usage. Every time it's called it returns the next value it calculates.

public class PowersOf2
    static void Main()
        // Display powers of 2 up to the exponent of 8: 
        foreach (int i in Power(2, 8))
            Console.Write("{0} ", i);

    public static IEnumerable<int> Power(int number, int exponent)
        int result = 1;

        for (int i = 0; i < exponent; i++)
            result = result * number;
            yield return result;

    // Output: 2 4 8 16 32 64 128 256

I developed a small Fibonacci calculator using yield.

Notice the first two occurences:

yield return f0;
yield return f1;

When it’s first called it returns f0 (0) and on second call it omits that return and returns f1 (1) and on subsequent calls it loops until the desired numbers and returns the series up until that point.

And the output looks like this:

Fibonacci console output


  • [MSDN Reference] (http://msdn.microsoft.com/en-us/library/9k7k7cf0.aspx)

Site news comments edit

I know I’m late to the game but better late than never, right? Right? Anyway, I’ve decided to use markdown syntax in my blog from now on. So if I migrate it some day it would be easier as Markdown’s supported in many platforms.

I know at the end of the day it all boils down to HTML but I think it’s about time to force myself practice more Markdown and integrate it into my daily routines. Let’s see how it goes with the next posts!


Gadget Raspberry Pi comments edit

I never cared for building a media centre before as I’m front of my desktop computer all day long and it has everything I need! But I was always curious about what the whole thing is about. As I was already looking for an excuse to buy myself one of those new Raspberry Pi B+ models it didn’t take too long before I decided to build a shiny little media centre for myself!


First of all before I engaged with this world they’ve already changed the name of the software! What’s formerly known as XBMC is now called Kodi. It has releases for Windows, Mac, Linux, Raspberry Pi etc. so no wonder why it’s so ubiquitous. For Raspberry Pi there are two popular distros: Raspbmc and OpeElec. When you are a complete noob choosing the right distro might be a hassle. After a quick search I found a a nice comparison here. Turns out Raspbmc comes with a full OS and running XBMC on top of it. That’s why I decided to go with it as it would give me full control over the Raspberry Pi and I could use it for other purposes as well.


Raspberry Pi B+

I mentioned the Raspberry Pi already but I needed a few accessories too.

Component Price Where to buy?
Raspberry Pi + Case £31 Amazon
32GB microSD Card £13 Amazon
Power adaptor £5 Amazon
Remote control £4 eBay
Audio splitter £8 Amazon
Monitor / TV £0  
Keyboard & Mouse £0  
Wi-Fi Adaptor £0  
Wireless headphones £0  
Speakers £0  

£0 doesn’t, unfortunately, mean they were free. It just means I used my existing gadgets lying around idly so it’s a win-win situation anyway. It felt good to utilize them even though that meant spending extra 60 quids!


Alright, now that we know what to install and where to install, let’s get cracking! Installation is dead simple as with all Raspberry Pi projects. All we have to do is download the latest build from Raspbmc website and prepare an SD card using a tool like Win32 Disk Imager. Insert it into the Pi and you’re good to go. When you plug in the pi and connect to your monitor/TV you get to the home screen:

XBMC Home screen


So it’s almost ready to kick back and enjoy podcasts, TV shows and movies but we need to tweak it a little first.


If you can use wired network, do so as it would be much faster. Unfortunately I have to use a wireless adaptor because of the location of my switch and me not wanting a long Ethernet cable crossing the room! To switch to Wi-Fi go to Program –> Raspbmc Settings. In the Network Configuration tab change  Network Mode to “Wireless (WIFI) Network”

XBMC Network Settings


For audio I use my speakers and wireless headset which are both connected via 3.5mm audio jack. The default audio output is HDMI so I needed to change it to Analogue in System –> System Settings –> System –> Audio Output

XBMC Audio Settings

Stuff to watch!

Almost there! Now we need to add stuff. To add an online source just hover Videos and select “Add ons”. Then you can install scripts for your favourite video/audio sources. My all-time favourite podcast network is TWiT so I was relieved to see there was an add-on for it.

XBMC Video AddOn

Also it is possible to add RSS feeds manually as explained in this nice article.

What’s Missing

  • I added sources from my desktop computer for TV shows and movies but ideally they should be put on a NAS on the network so it doesn’t rely on desktop up and running all the time (even though it is!)
  • To enjoy it fully it would be nice to plug it to a nice big TV. An 18.5” monitor is barely good enough for video podcasts but definitely not a viable option to watch movies.


It feels nice to watch my favourite podcast shows on a cheap, remote-controlled small computer. It was absolutely hassle free to build it which left more time to play with fun stuff, like installing a Twitter add-on (which unfortunately failed to run because of incompatibility issues!) I’ll definitely keep on playing with it. After adding more stuff and streamlining the process (like adding new favourite feeds to a playlist automatically) I’m sure I’ll enjoy it a lot more.


Off the Top of My Head, Site news, Tip of the Day, Tips & Tricks comments edit

One of the sites I like is Coderwall. It’s a nice place to check out quick tips from different developers. Also it has a voting system which you feel a bit validated when people find your tips helpful. I have 6 “protips” in their site and some of them had a few upvotes. I was motivated to post more tips which are especially too short for a blog post.

Your upvotes are no good here!

A few backs I logged in to check if I had any new upvotes. To my surprise, not only I didn’t get anything new, all my previous hard-earned upvotes were deleted as well! I contacted their support and 2 weeks later they said they could have been deleted because of spam concerns. If a tip is online for about a year and it was viewed by hundreds of people and got 3-4 upvotes in the process I think it’s safe to think that there’s not a scam going on here. Even if you think something is fishy you should give them benefit of the doubt just because the numbers are very small and very plausible. Luckily, I have better things to do than scam Coderwall and a few measly upvotes have no meaning at all.

Time to pack and leave

A week later I decided to publish all my posts n my blog. I went to my account to list my tips but the link wasn’t working. So I couldn’t even get the tips I had created. At least they provide a way to search by username. That’s how I could find my own tips. That was the straw that broke the camel’s back! So the lesson learned here is that always take control of your own content. Publish it on your own site/blog or whatever platform you control then propagate your content elsewhere if you choose to do so.

Goodbye, Coderwall!

I know this idea sounds very natural and obvious to some people. I think I should have thought of it before this incident but at least I recovered my content without any loss and learned a valuable lesson. I may still post to Coderwall but after deleting my votes and treating me like a scammer I’ve lost interest to their site. Looking at the quality of their support I don’t think they will be around for a long time anyway!

From now on I will post suck quick tips on this blog under “Tip of the Day” category.

Tip of the Day, Tips & Tricks comments edit

In some cases you may want objects in a bucket be deleted automatically, for example for log files or surveillance footage you may want to keep only latest n days. You can run scripts to delete them manually but it can also be done by setting the expiration date on the bucket.

AWS S3 Object Lifecycle

Tip of the Day, Tips & Tricks comments edit

Recently I had this problem and was surprised by this limitation. The problem is wildcard SSL certificates only support one level of subdomains, i.e *.a.com matches foo.a.com but not bar.foo.a.com (taken from RFC2818, see link below). To support all subdomains beyond foo you would need a wildcard certificate for *.foo.a.com


Tip of the Day, Tips & Tricks comments edit

To capitalize all words in a string you can use the function built-in the .NET framework ToTitleCase function in System.Globalization.TextInfo class

Here is a sample (taken from MSDN link below):

using System;
using System.Globalization;

public class Example
   public static void Main()
      string[] values = { "a tale of two cities", "gROWL to the rescue",
                          "inside the US government", "sports and MLB baseball",
                          "The Return of Sherlock Holmes", "UNICEF and children"};

      TextInfo ti = CultureInfo.CurrentCulture.TextInfo;
      foreach (var value in values)
         Console.WriteLine("{0} --> {1}", value, ti.ToTitleCase(value));
// The example displays the following output: 
//    a tale of two cities --> A Tale Of Two Cities 
//    gROWL to the rescue --> Growl To The Rescue 
//    inside the US government --> Inside The US Government 
//    sports and MLB baseball --> Sports And MLB Baseball 
//    The Return of Sherlock Holmes --> The Return Of Sherlock Holmes 
//    UNICEF and children --> UNICEF And Children


Tip of the Day, Tips & Tricks comments edit

AWS is a very critical service for businesses and enabling a 2nd factor authentication would be very helpful to increase security.

Step 0: Install Google Authenticator or a similar OTP generator tool on your mobile device.

Step 1: Logon to your account and select Security Credentials from the menu on the upper right corner. Then click on Activate MFA button. AWS MFA Step 1

Here you have two options. You can choose to use a hardware device if you choose to purchase one from Amazon. At the time of this writing the price on Amazon was $12.99 so it’s also an affordable option. I decided to use Google Authenticator because it was already installed and active on my phone and I didn’t want to manage another piece of hardware.

Step 2: It will display a QR code which you can scan using Google Authenticator. Once the scan is completed you will need to enter 2 consecutive numbers the device generates. Once the device is synchronized it will be ready to use. You can verify it by checking its status:

AWS MFA Step 2

Step 3: Log out and log back in to see the results. After the password screen you should see an additional screen asking for the authentication code.

AWS MFA Step 3


Tip of the Day, Tips & Tricks comments edit

If you are working with large files, transferring them to S3 correctly might be an issue. To ensure data integrity you can send the MD5 hash of the file in Content-MD5 header.

After the transfer S3 compares the MD5 value of the transferred file with the value you provided. If they don’t match it returns an error. This is an easy and great way to ensure the file has been uploaded safe and sound.


Tip of the Day, Tips & Tricks comments edit

The feature exists but a bit buried away. To create insert statements for table(s):

  1. Right click on the database and go to Tasks -> Generate Scripts
  2. Select the tables that you want to generate the script
  3. In “Set scripting options” page click on the Advanced button
  4. Under the General category, locate “Types of data to script”. It contains 3 options: Data Only, Schema and Data, and Schema Only. Default is Schema only,if you select an option with data in it you can get the data with the insert statements.

Generating Insert Scripts With SSMS

Automation, System Administration comments edit

When moving to a new machine, re-installing all the applications is sounds a very daunting task. Linux distros have been enjoying the ease of package repositories for quite a long time and users can install almost everything they need by package manager applications like apt-get and yum. Chocolatey aims to bring the same convenience to Windows.

Easy Install Indeed!

Installation is a breeze as shown in their website. By using some Powershell and NuGet magic you download a script which then downloads Chocolatey package from the repository. You may have noticed the URL is very similar to nuget.org’s package path. That’s simply because it uses NuGet under the hood. Even the user interface is just a skinned version of NuGet Gallery (which is open source and can be downloaded from GitHub).


Automate all installations

After Chocolatey is installed all you have to do is browse the packages and select the ones you want to install with an easy command such as:

choco install atom

And after a bunch of colourful messages you’re good to go.


Are we done?

Most core tools for development and everyday use (SysInternals, Fiddler, Chrome, FireFox, NodeJS, Python, VLC, Paint.NET etc.) can be installed automatically using Chocolatey. The major applications such as Visual Studio and SQL Server still need some love and your caring hands but I think automating installation of tens of applications in such an easy way is priceless.


software review comments edit

Many times I used file hashes to verify that it’s been correctly downloaded or uploaded. It’s especially useful with large files where things are more likely to go wrong. That’s why most MD5 or SHA1 hashes provided with many large file downloads such Linux distros.

Ubuntu MD5 Hashes

Best shell extension ever: HashTab!

This is a just quick plug about one of my favourite tools in Windows: HashTab. The best thing about it is that it’s a shell extension. So to find out the hash values of a file is simple as right-clicking and selecting File Hashes tab. So, using the MD5 has example above, if you have downloaded ubuntu-14.04.1-server-amd64.iso all you have to do is check it’s properties.

File Hashes

HahsTab also monitors the clipboard. So if you copy the MD5 value from Ubuntu’s site it automatically compares it with the calculated hash values and confirms file integrity with a large shiny green check!

Out of the box it displays most common 3 hash algorithms but if you need more supported algorithms.

HashTab Settings


Development comments edit


In almost all projects I’ve worked there was always a need for scheduled background jobs. Windows Services are well-suited for the job but when it comes to deployment and debugging they fall short. This is where TopShelf comes to rescue!

TopShelf in action

With TopShelf all you need to do is create a Console Application as your Windows Service and initialize TopShelf in the Main method:


Configuring it is quite easy and straightforward. It also has a nice comprehensive documentation on its official site. You can define all the parameters like the account that will run the service, the recovery policy and start-up type.

What about scheduling

Scheduling is also a crucial feature in background services. TopShelf doesn’t help with that but that’s easy to fix with FluentScheduler.


FluentScheduler is yet another great library available at NuGet which makes scheduling a breeze. No need to fiddle with timers, it can be defined very easily.

And here is the sample code:


Development comments edit

If you have multiple accounts for git providers (i.e multiple accounts on Github and/or Bitbucket) then you’d need to update your SSH configuration to be able to access all your repositories seamlessly. Of course you can use HTTPS but then you’d have to enter username and password every time.

If you don’t specify which key to use for each account SSH agent will try the default key if there is one (id_rsa) and will most likely fail if you didn’t grant access to that key in your git provider settings.

SSH Access Denied

To resolve the issue you need to create a config file under .ssh folder that looks like this:

SSH Config

If you are just using one account per provider you don’t need to create multiple keys, you can just use id_rsa for both accounts. But if you have multiple accounts for a provider you’d need a key for each account. In the example configuration above I used a new key for BitBucket anyway. After creating the config file and adding the keys to your accounts you can start cloning repositories from various sources.

Final step to accomplish this is to use the hostname you set in the config file when cloning the repository. For example when you copy the SSL clone URL it looks something like this: git@github.com:{account name}/{repository name}.git. So let’s say it’s a repository from the corporate account in my sample config file then I’d have to modify the URL as follows: git@github-corporate:{account name}/{repository name}.git so that the correct host name and RSA file can be used.

SSH Success


Development, Lego, Mindstorms, EV3 comments edit

I had my eye on the new Lego Mindstorms set for a while. Finally I decided to order it from Amazon. It’s still a bit pricey but I think it’s worth it. I read nice review of EV3 here which also includes comparisons to the previous generation of the Mindstorms kit.

Lego Mindstorms EV3

Programming EV3: The Official Way

Programming the kit is very easy using Lego’s official graphical programming tool6. You just have to drag and drop the components and fiddle with the parameters. Check out the following very basic application:

Lego Mindstorms EV3

It powers the motors connected to ports B and C. It keeps doing that in a loop as long as the value read from Infrared Sensor is larger than 20. If there is an object closer to 20 centimetres it breaks and ends the program. And here’s the output in action:

###Programming EV3: The .NET Way The .NET API is an open-source project and code can be found on CodePlex. I recommend watching the introductory video which shows the basics. It shows how to move the robot by sending direct commands to turn the motors and how to read values from the sensors. The following part the test application shows the event handlers for the direction buttons and setup code to connect to the brick.

Lego Mindstorms EV3

I also added a similar implementation of the NXT-G program above. It’s a while loop which breaks when the value from the IR sensor is lower than 10.

Lego Mindstorms EV3

And voila! Here is a clever robot that senses the object in front of it and avoids the collision by stopping!

You can find the source code for the test application on GitHub

Tips & Tricks

  • When I first implemented the NXT-G equivalent version the sensor value wasn’t updating properly. I checked the discussion forums in the CodePlex project page and found out that other people were having a similar issue. A workaround was adding the Thread.Sleep(10) line. After that I could read the updated sensor values without any problems. Although it doesn’t feel like the right solution it works fine as a temporary workaround.

  • During the testing and debugging I managed to crash the Lego brick a few times. First I feared I actually “bricked” the brick but luckily a reset resolved it. Resetting the brick is not obvious though, I had to check the manual for that. So in case you need to reset it you have to hold down Back, Center and Left buttons. Then release the Back button when the screen goes blank and release the other two when the screen says “Starting” as shown in EV3 User Guide


  1. Lego EV3 review and comparison to NXT 2.0
  2. API code on CodePlex
  3. Channel9 video on programming EV3 with .NET API
  4. Sample Track3r robot project and building instructions
  5. EV3 User Guide
  6. Lego software
  7. Codeplex discussion on IR sensor not updating values
  8. Source code for the test application