Amazon Web Services, Development comments edit

Sometimes you need a microsite with no server-side code. All you need is to display a pretty-looking entry page. In such scenarios you don’t need to use your own servers and use your precious resources on such trivial sites. The 2 ways to achieve this (that I know about) are:

  • Using Amazon Web Services S3
  • Using GitHub Pages

Both methods are very well documented. You can find the links to the official tutorials.

AWS S3

First, my favourite IT company: Amazon! S3 method requires to create a bucket with the name of your domain or subdomain. In the properties enable Static Website Hosting and point to your index document. In order for this to work, you have to use AWS Route 53 as your DNS provider. In Route 53, all you have to do is define an A record as an alias and select the S3 bucket that contains your site. If you have multiple accounts make sure that Route 53 DNS records and S3 bucket are under the same account. Otherwise you cannot point to the bucket as en endpoint.

GitHub Pages

GitHub method is also quite easy. All it takes is create a public repository, create a branch called “gh-pages” and check in your source code. To let GitHub know that you want to host a site there, you have to create a file called CNAME which includes the domain name. And in your DNS settings you have to point your site to GitHub’s IP address. The downside of this method is, obviously, your site will stop working if GitHub decides to change their IP address.

Resources

Electronics comments edit

Playing around with the development boards and gadgets I was wondering about the differences between Microcontrollers (MCU) and Microprocessors (MPU). I found a nice concise and informative article (link in the resources section). For me the highlights of the document and the comparison drawn bettern MCU and MPU are:

  • MCU uses on-chip embedded memory, this leads way to a short start-up period. Downside of embedded memory is that there is limited space. MPUs use external memory.
  • MCUs need one single power rail whereas MPUs need several (for core, DDR etc.)
  • MPUs have much more processing power than MCUs. A full operating system’s requirements are more likely to be met by MPUs.
  • For numeric-based (number-crunching scientific type) applications and heavy user interfaces MPUs are more suitable
  • MCUs consume far less power than MPUs

So in a nutshell, MCUs are generally a better choice for low-cost, low-power projects. For example, for small devices like remote controls, smart meters MCUs are preferred.MPUs perform much better in more resource-demanding systems.

Resources

Gadget comments edit

If you like playing with gadgets like me you will love this one. It’s very tiny (as the name implies) and as of version 3.0 it is Arduino-compliant. If you install Teensyduino addon on top of Arduino IDE you can compile and upload your sketches to Teensy just like Arduino. This tiny things rocks a 32-bit ARM Cortex-M4 processor.

Teensy30

Also it is quite cheap and it’s size allows it to be used in a variety of projects. Strongly recommended for gadget-lovers.

Teensyduino

Resources

Heavy Metal comments edit

After attending to both festivals this year I decided to make a list of what I liked and disliked about both of them.

Bloodstock

Bloodstock Logo

Pros

  • More friendly: Bloodstock being a small festival I find it cosier and people seem to be more friendly.
  • Cheaper: The tickets are almost 2/3 the price. Also the beer in the arena is cheaper. And best of all you have the chance to buy crates of beer inside the festival area (24 for £40 and 12 for £20).
  • Closer to London: Considering the time spent on the road is just wasted it is good that it takes less.

Cons

  • Coach on Thursday: Not a flaw of the festival but since that’s my means on transportation, I have to chalk it up on festivals cons.

Download

Download Logo

Pros

  • More bands: There are more top level bands. Of course the downside of it is that you have to choose because of the time conflicts.
  • Internet connection: A huge plus. Not very fast but still good enough to read Tweets and some newspapers

Cons

  • Too big to walk around: It took me 30 minutes to walk from the camping site to the arena. Although it’s a good exercise, I hated walking all day long on my vacation!
  • Too crowded: Even in the afternoon, there were thousand and thousands of people in front of the main stages. I watched most shows from the giant screen.
  • Logistics: There are so many people that there were queues everywhere. Want to buy a beer? Wait in line. Wanna go to toilet? Wait in line. Wanna buy food? Wait in line! If there is one thing that I hate more than walking all day on my vacation is that waiting in lines all day on my vacation.

Verdict

To me Bloodstock is definitely the better choice and if I’m around this time next year I’ll most certainly be attending to it. I’m glad I had the chance to see Download but probably that was my first and last time.

Heavy Metal comments edit

2nd Bloodstock in a row is over. I liked the line-up mostly because it had 2 big metal names: Lamb of God and Slayer. I missed some of the bands I wanted to see but overall it was great to attend this year too.

Notes from the festival

  • For the first time in a festival I met with my neighbours! Both next door tents had two friendly guys. Even though, while leaving we just ignored each other (as you might expect) it was nice.
  • I loved my tent. It takes seconds to setup. The only issue was it had black ropes which made it hard for people to see and people kept tripping to them causing me lose 4-5 metal pins.
  • There were some issues with the sound on Friday which caused some explosion-like sounds during the shows.
  • The layout of arena and festival area was the same as last year, including the foot stands which made it easy to find what I was looking for.
  • There was a tent from Wacken Foundation! I don’t know what they are doing but they had a stationary bike for people to ride. Some charity work I guess but I couldn’t find it in myself to go and ask!
  • Best food of the festival: Delikate! Next year I’m planning to eat only from them no matter how long the queue they have
  • Best new bands (for me ) of the festival: Ex-Deo and Hell. Especially Hell put up an excellent show. Hope I can make it to their show in London this November
  • Worst band: Voivod! Extremely boring and completely meaningless
  • Band with worst frontman: Amorphis. The last scrap of my love against Amorphis was destroyed after this show.
  • It felt like the number of Galaxy S phones surpassed iPhones
  • Avantasia’s female vocals looked familiar. Then I realized I saw her in Epica DVD long time ago. She is still pretty!
  • Beholder singer announced next year’s headliner (Emperor)  and he also appeared in the after party with the 4 DJs of the apocalypse.
  • To me the only conflicts were Wolfsbane vs. Anthrax and Accept vs. Scar Symmetry
  • The barrier broke during Lamb of God set. One funny remark from the show was Randy saying he calls himself Roger Brilliant in England.
  • Cursing is still not allowed on the set
  • Everybody who saw Evil Scarecrow said they were great. I wish I didn’t miss that one.
  • During Exodus show the singer started a Wall of Death and how he did it was interesting. He looks at one side and said I want this side to kill that side and looks at the other side and says the same thing to them. Sounded more violent than we generally hear on the shows.
  • Scar Symmetry guitarists looked like twins but apparently they are not related.
  • Looks like my new favourite band Ex-deo’s vocals and Kataklysm vocals are the same guy. The guy knows how to make good music.
  • The vamp girls from the after aprty and Fozzy looked like the same but couldn’t verify it yet! (Check out the videos below to compare them yourself)
  • I wonder who the old presenter who was preaching for worshipping Satan was!

Anthrax Beholder Amorphis Avantasia Accept Dark Funeral Kataklysm Fozzy Gama Bomb Hell Ex Deo King Diamond Lamb of God Ex Deo White Chapel Sabaton Scar Symmetry Municipal Waste




Heavy Metal comments edit

Wow, it’s been a year already? It’s time for another Bloodstock mayhem! This year it’s even stronger and faster: Lamb of God and Slayer are two of the headliners. ‘Nuff said!

Bloodstock 2013

I checked my notes from last year while preparing for the next one. I wrote to buy the same tent but I think I have now a better solution:

Tent

which can be bought from here: http://www.amazon.co.uk/gp/product/B00BW3XB0K

The best thing about it is it can be setup in seconds. Just open the zipper and it pops up instantly and you’re done. I had a good deal and got it for £20. At the time of this writing it is £35 on Amazon so I guess I was just lucky to seal the deal back then.

Apart from that, I’ll stick to the plan. I’m packing both suntan cream and poncho as this British weather is completely unpredictable.

Hope everything goes well and I can have a good time at BOA 2013 just like I did last year. I’ll post my reviews after the festival.

Programming comments edit

I need a large dataset to practice on SQL server while preparing to exams. One idea is to generate random data but there is no fun in that. Because it is hard to create real-life scenarios but gibberish data. Then I found out that IMDB actually releases all their data and allows usage for non-commercial applications.

Data Analysis

Unfortunately, IMDB data doesn’t come in a very structured format. You have to deal with the exceptional cases and create your own data structures. I found some nice info in a Github repo called imdb-blaster (link in the resources section).

I started with the main file to parse: Movies.lst. This file contains movies, TV shows and their episodes. I want to store these in separate tables so I wanted to treat them separately. What they look like in a nutshell is as follows:

  • Movies: The Lord of the Rings: The Return of the King (2003)    2003
  • TV Shows: “Seinfeld” (1990)                    1990-1998
  • Episodes: “Seinfeld” (1990) {Male Unbonding (#1.4)}        1990

All TV Shows are enclosed with double-quotes. There are also some other optional attributes that need to be taken into account. Such as deleted items are marked with like “Seinfeld” (1990) {Good News, Bad News (#1.0)}     1989

Start parsing

I don’t like regular expressions too much as they are very hard to read. But they are very helpful and powerful in scenarios like this. The goal is validating and parsing it to groups so that it can be inserted easily to a relational database. So I developed 3 regular expression patterns for the type of data in the file. One thing I learned about regular expressions is that you can group parts by using parenthesises. This creates an unnamed group. If you want to name them you can use angle brackets and assign a name to group such as: (subexpression)

Parsing movies

As most regular expressions tend to wind up with hard-to-read complex queries this was no exception! Even if the structure is simple because of the optional parameters and exceptional cases it became very complex very soon. Here’s the sample code to run in LINQPad to parse a sample line for a movie:

string line = @"America the Punchline (2009) 		2009";
string pattern = @"(^.*)\((\d{4}|\?{4})(/I|II|III)?\)([ ]?)()(\(V\)|\(TV\))?\t*(\d{4})$";
Console.WriteLine(Regex.IsMatch(line, pattern));

MatchCollection matches = Regex.Matches(line, pattern);
foreach (Match match in matches)
{
	Console.WriteLine("Group count: {0}", match.Groups.Count);
	foreach (Group matchGroup in match.Groups)
	{
		Console.WriteLine("{0}", matchGroup.Value);
	}
}

And the output is:

True
Group count: 8
America the Punchline (2009)     2009
America the Punchline
2009

2009

The first group is the whole string. The second one is the title, the third is the year. There is an optional group because some titles come with I, II or III after the release date. I have no idea what that means but had to break it into a group to avoid an unmatch. The last two parameters are the type (V: Video, TV: Television, VG: Video game) and another date. I don’t know why the movies have two dates and they almost always match so I’ll ignore one of them. So the actual code is very simple:

if (regexMovie.IsMatch(line))
{
	Match match = regexMovie.Match(line);

	commandMovie.Parameters.Clear();
	commandMovie.Parameters.AddWithValue("@Name", match.Groups[1].Value);
	commandMovie.Parameters.AddWithValue("@ProductionYear", match.Groups[2].Value);
	commandMovie.Parameters.AddWithValue("@IsDeleted", (match.Groups[5].Value == ""));
	commandMovie.Parameters.AddWithValue("@ReleasedFor", match.Groups[6].Value);
	commandMovie.ExecuteNonQuery();
}

All the hard work is done by regular expressions already. All we have to do is to check is a line matches a movie definition and if it does just insert the data that is already broken up into groups.

Parsing the rest

I’ll publish the full source code in a Github repository and will update this post with the link. But I guess to start parsing the movies file the other two patterns suffice for now: TV Show Pattern: (^””.””) (((\d{4}|\?{4})(/I|II|III)?))\t.(\d{4}-\d{4}|\?{4})$ Episode Pattern: (^””.””) ((\d{4}|\?{4})(/I|II|III)?) {(.?)(#(\d).(\d))}\t*(\d{4}|\?{4})$

Resources

Game comments edit

I’ve been playing this game for months now and I believe it’s time to move on. I think it is safe to say that I finished the game already. I bought all the buildings that don’t require donuts. I haven’t spent one penny playing this game so this is as far as a freeloader like me can get! No, just kidding. The prices they set are preposterous and I would never spend that much money on some imaginary donuts. Actually Leo Laporte said in one of his shows that he spend over $300 for this game! That’s how much you can spend if you want to buy all premium items.

TSTO

I’m happy with the Springfield I built. As you can see in the images below, I unlocked all the lands, bought all the buildings money can buy including the million dollar buildings. The problem with the game is there is no challenge. You just tap on buildings when they have signs on top of them and tap on characters when there is a exclamation mark on top. If this wasn’t about Simpsons I wouldn’t be playing it at all

TSTO

The beginning of the end: Krustyland!

The worst part is they started to repeat themselves. After the last update they introduced a new place called Krustyland. It is exactly like the first level of the game. A blank field and you clean up the place and build some buildings. Only this time you earn Krustyland tickets instead of money. It’s like the mini version of the same game inside it.

TSTO

So.. I’m calling it off. I don’t mind wasting a little time on games to blow off steam but not with this one anymore. Maybe I can move on to something more challenging like MindCraft.

Electronics comments edit

I was trying to avoid soldering but looks like at some point it is mandatory to learn how to do it. Got myself a basic toolkit:

Soldering Tools

There are plenty of tutorials around. I enojyed Iyaz Akhtar’s KnowHow episode dedicated to soldering and EEVBlog’s tutorial. After spending some time around here’s the fruits of my efforts:

Soldered Circuit

Of course the components soldered on this board are meaningless and they don’t do anything. But it was a good practice.

I was surprised to find out that desoldering was an easy process. All you have to do is heat the iron, touch the solder and liquify it and then vacuum it using the desoldering pump.

Desoldered Resistor

Resources

Arduino, Gadget comments edit

Basically the fun with playing gadgets such as Arduino, Gadgeteer and others comes from sensors. Because they are how your system interacts with the real world. And writing code that acts upon some readings from the real world is fascinating!

So let’s get started with using the motion sensor. I have a very generic sensor from Parallax and fortunate enough to find an article that explains exactly what I needed: Using motion sensor with Arduino. Check out the resources section down below to access the original article. Unlike the LCD, it’s quite simple to connect the motion sensor to Arduino. The sample code lights the onboard LED when the motion sensor detects a motion. Check out the video for a short demo. When the sensor “senses” motion, it goes red and the LED starts blinking.

I think the next step would be to connect both LCD and motion sensor to display the alarms on the display. Hope I can make that project happen without too much delay.

Resources

Arduino, Gadget comments edit

I’ve been looking for a good tutorial to connect the LCD screen to Arduino. There are a lot of tutorials everywhere but Interestingly most of them just show the final version with all the cables jumbled up. After a lot of looking around I finally found a simple, step-by-step tutorial with clear illustrations: http://www.codingcolor.com/microcontrollers/connecting-a-lcd-to-arduino/

This is a great tutorial and I recommend it to anyone who wants how to connect LCD to an Arduino.

Arduino with LCD

Resources

Arduino, Gadget comments edit

The most popular development boards is without a doubt Arduino. It is open-source and it’s been around since 2005. There are lots of different models and libraries. My goal for now is just get started and see it in action. To achieve this, first stop is the official site where you can download the drivers and IDE. After download simply unzip the contents to a folder.

A great place to start playing with it is Adafruit. You can find the link for Arduino tutorials in the resources section below. I simply started with Lesson 1 and changed the speed of the onboard LED.

Arduino

So it takes minutes to get started with it and comes loaded with a bunch of examples so they made it very easy for beginners.

Troubleshooting

Error: stk500_getsync() not in sync resp=0x00 This error means that Arduino couldn’t be found in the COM port. To resolve the issue:

  • Use Device Manager and make sure Arduino is connected. It should be listed under Ports node. Note the COM port number
  • Then from Tools –> Serial Port make sure the correct port is selected.

Resources

Development, Game comments edit

Kodu is basically a tool for kids to develop games without writing code. You can select form a bunch of items to place in your “world” and use the visual programming language to program the actions. The best part is you don’t have to start from scratch. You can browse the existing worlds play with it and start editing it right away. For example below is a screenshot of a game developed by California Institute of Technology:

Kodu Mars Rover

You can download any game, play and modify to your liking. It’s very easy and fun way to build games. Especially if you have young children or you are one!

Resources

.NET Gadgeteer comments edit

Soon after I started playing with Gadgeteer it became a bit messy. Components were dangling by the cables and there was no way of keeping them steady. But it is about to change as I have discovered the Tamiya Universal Plate.

Although it’s main purpose is not for Gadgeteer it works great with it. I bought mine from Proto-Pic for around £10 so it’s a small price to pay to keep my design tidy.

Here’s the link for it: http://proto-pic.co.uk/tamiya-70172-universal-plate-l-210x160mm/?gclid=CLT44pym1bgCFbHKtAoddxEAjw

And here’s how I can organize my Gadgeteer designs:

Gadgeteer_Board_01

Gadgeteer_Board_02

I bought 3mm screws and nuts to pin the components but saw some plastic long pins that can be used for the same purpose and would work better as screwing all components is a bit tedious. I’ll update the post if I find those pins.

Development, Networking, Security comments edit

HSTS (HTTP Strict Transport Security) is a security policy where a web server instructs the client that the website they are calling can be used with HTTPS only. By using tools like Wi-Fi PineApple and sslstrip a man-in-the-middle attack can be carried out easily. The attacker can redirect the victim to HTTP version of the site they are connecting to and after the login info is submitted in clear-text and captured the victim is redirected back to HTTPS. By using HSTS the client browser always makes the calls over HTTPS hence reducing the risk of MitM attack. It’s not bullet-proof but still an improvement over not using it.

Implementation

HSTS is basically a response header. In an ASP.NET application it can be added in the web.config file as below:

  <system.webserver>
    <httpprotocol>
      <customheaders>
        <add name="Strict-Transport-Security" value="max-age=31536000" />
      </customheaders>
    </httpprotocol>
  </system.webserver>

And when you visit this site over HTTPS response looks like:

HSTS

This header tells the browser to use only HTTPS from now on for 1 year. Also, the response header can be added in the BeginRequest event handler:

protected void Application_BeginRequest(object sender, EventArgs e)
{
	protected void Application_BeginRequest(object sender, EventArgs e)
	{
		switch (Request.Url.Scheme)
		{
			case "https":
				Response.AddHeader("Strict-Transport-Security", "max-age=31536000");
				break;
			case "http":
				var path = "https://" + Request.Url.Host + Request.Url.PathAndQuery;
				Response.Status = "301 Moved Permanently";
				Response.AddHeader("Location", path);
				break;
		}
	}
}

HSTS header only works with HTTPS. So you can not observe it HTTP responses. That’s why redirecting to HTTPS is required. Because if the client uses HTTP all the time and if there is nothing forcing the user to use HTTPS, even if you have HSTS turned on, the client will never receive those responses. So at this point even if an attacker is redirecting the user to HTTP, the browser will always make the requests over HTTPS.

Shortcomings

  • Not all browsers support it. It works with Chrome and Firefox but not with IE and Safari
  • Cannot protect for the first call: If the user is making a call to a site for the first time and there is an attacker in between it wouldn’t work. At least it would start working after the attacker is finished with the attack and redirected the user back to HTTPS.

Resources

Electronics comments edit

If you’re going to do something you need the right tools. The last time I was dabbling with I didn’t quite enjoy it but that was mostly because I didn’t have the right tools. The most daunting part for me was cabling. With the jumper cable set I had it was just too painful.

Get your cables right

This time I’m prepared for all occasions: I have Male – Male, Male – Female and Female – Females cables which cover all combinations.

Cables

Essentials

Multimeter: I realized a multimeter is an essential tool if you want to build your own circuits. I added a reference for an excellent tutorial which teaches you how to use one in a few minutes. By using it, I was able to measure voltage and resistor values in no time.

LCD Display: Also, I think it’s almost impossible to build a cool project without a display. It can be used for debugging and informing the user so very helpful to have it in the mix. They are so cheap that I ordered 5 of them for about £7 on eBay. So I guess there is no excuse for not buying one!

Resistors: Real resistors! I hated my old blue resistors with 5 bands. I couldn’t read the values. Colors were not clear. But now finally I got a bunch of standard 3-band yellow ones which make it easier to read. (Actually I have a multimeter now, so I can just use it to measure the resistance anyway.)

Breadboards: I had a big nice one but I think in order to run things in parallel I’ll need a few more of the smaller ones. Also I’m trying to learn how to solder so I now have a couple of solder boards to practice. Push buttons: I think to control the flow they are definitely needed.

New Components

Let’s get crackin’

I just built a simple circuit to light a LED when the push button is pressed. I know it’s not impressive by any means but I enjoyed building something from scratch. Familiarized myself with my tool shed and looking forward to build more complicated things.

Resources

Gadget comments edit

Yes!!! Finally it arrived. It looks very tiny and elegant. This is what the package and contents look like:

Leap Motion

Installation

Good thing it comes with 2 USB cables of different lengths. One is bout half a meter, probably for laptop users and the other is about 2 meters, better suited for desktop users like myself. It doesn’t come with any instructions or user guide but a card that tells you to go to leapmotion.com/setup. And that’s where I went.

The setup file is about 56MB. As this is a new file, Norton 360 didn’t like it and issued a warning. Another interesting note is right after I plugged it in Skype icon started blinking. I checked the window and it was saying “Your video works fine”.  as I don’t normally keep my webcam plugged in, the video doesn’t work. But it became happy to detect a camera! I’m not sure if it would work with Skype though. Probably not.

App Store

After the installation you have to login to Airspace which is the app store for Leap Motion. I logged in with my LeapMotion account. It comes with a few free apps. Cut the Rope didn’t run unfortunately. Didn’t bother to give an error message either. So I tried the others. Lotus looks like a weird psychedelic app. As far as I could understand you make music with your fingers. Here’s a little demo of how it looks:

Development

What’s more interesting than downloading and using apps is developing one on my own! In order to do this you have to sign up for a developer account at: http://developer.leapmotion.com After the sign up you download their SDK. So far I managed to install the drivers, tried a few apps and downloaded the SDK and I’ll post the development experience in another post.

Final words

I’m not so sure if this gizmo will take off but as long as it’s an interface for the OS, not some custom apps, I don’t see much use for it. Keeping hands in the air for long tasks is tiring. I think it only might make some games more fun but that’s a very small market.

Hardware, Mobile comments edit

If you have an Android phone that supports NFC, you can save and change some settings very easily based on your location. All you need is some blank NFC tags like shown below, which are very cheap and a free app called NFC Task Launcher.

NFC Tags

NFC for the uninitiated

NFC stands for Near Field Communication. It’s a set of standards build on RFID that allows wireless communication between devices in a close proximity. It is commonly used in contactless payment systems.

Manage tasks with the task launcher

It’s a very intuitive and easy to use app. First, you select an action group (like WiFi On/Off, BlueTooth On/Off).

NFC Task Launcher

Then you configure the action (like Enable/Disable) and finally you touch to your tag to associate the task with it.

Secure your phone outside the house

After playing around with tools like WiFi PineApple I’m now even more afraid of wireless networks than ever. Thinking about it, I don’t connect to open networks on purpose and if my phone connects to one of them that means something fishy is going on. So why should I have WiFi when I’m not using my own? But of course turning it on and off every time I enter/leave the house is cumbersome. My solution is: doing it with NFC. Although it’s not completely automated, I just touch my phone to the red tag I stuck to my door when I leave the house and the WiFi is turned off. When I enter the house, I touch on the green one it is turned back on. Simple as that!

NFC Task Launcher

Resources

Fitness, Gadget comments edit

Although that’s a great song from Iron Maiden, the topic of this post is different. The topic is my new running gadget Garmin ForeRunner 10:

Garmin Forerunner

It is a simple and basic device but has all the functionality I need: Measure distance and time. In addition to that it comes with a software that allows you to upload your run info to Garmin Connect and you can keep track of your progress.

Once you install the software all you need to do is connect the device to your computer with the provided USB adapter and click Upload on the UI. It scans the device and uploads the new activities.

Garmin

Then you can go to Analyze –> Activities where you can analyze individual runs or you can go to your Dashboard to view your current status like your records etc.

Garmin

I’m definitely delighted with this gadget. It currently costs £84 on Amazon. Not the cheapest gadget and also there are free alternatives like RunKeeper app but it is still well worth the money. The only problem was it cannot determine the position very easily. I had a warm up walk for about 5 minutes and during this time it couldn’t pinpoint my location. Before I could start running I had to stand still for about a minute but once it finds it I didn’t have any problems during my run. Granted that I used it only one time as it came yesterday but my initial impression is that it is a great tool and very motivating for running. So highly recommended.

Gadget comments edit

I know they are about to release XBox One and they have already released Kinect for Windows but I still only have a Kinect for XBox for 360. I’m hoping to create a quick and sample application to test my Kinect and discover what’s in Kinect SDK so that I can remove it for a while from my gadgets-pending-to-be-tested-and-played-with list.

Until I buy a better and more recent hardware I just decided to utilise my existing sensor. I followed Channel9’s video tutorials and here is the code to display a video output of the sensor on the screen:

Xbox-360-Kinect-Standalone

Source code:

using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Microsoft.Kinect;

namespace KinectDemo
{
	public partial class MainWindow : Window
	{
		KinectSensor _sensor;

		public MainWindow()
		{
			InitializeComponent();
		}

		private void Button_Click(object sender, RoutedEventArgs e)
		{
			
		}

		private void Window_Loaded(object sender, RoutedEventArgs e)
		{
			if (KinectSensor.KinectSensors.Count > 0)
			{
				_sensor = KinectSensor.KinectSensors[0];

				if (_sensor.Status == KinectStatus.Connected)
				{
					_sensor.ColorStream.Enable();
					_sensor.DepthStream.Enable();
					_sensor.SkeletonStream.Enable();
					_sensor.AllFramesReady += _sensor_AllFramesReady;
					_sensor.Start();
				}
			}
		}

		void _sensor_AllFramesReady(object sender, AllFramesReadyEventArgs e)
		{
			using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
			{
				if (colorFrame == null)
				{
					return;
				}

				byte[] pixels = new byte[colorFrame.PixelDataLength];
				colorFrame.CopyPixelDataTo(pixels);

				int stride = colorFrame.Width * 4;
				image1.Source = BitmapSource.Create(colorFrame.Width, colorFrame.Height, 96, 96, PixelFormats.Bgr32, null, pixels, stride);
			}
		}

		void StopKinect(KinectSensor sensor)
		{
			if (sensor != null)
			{
				sensor.Stop();
				sensor.AudioSource.Stop();
			}
		}

		private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			StopKinect(_sensor);
		}
	}
}

I think for this amount of code and the simplicity it is a pretty good result:

Video:

Probably I will continue my conquest of Kinect after I get the latest one, but for now I’ll just call it.

Resources