Tuesday, December 31, 2013

Raspberry Pi -- First Impressions

Overview

I recently purchased a Raspberry Pi board to play around with its capabilities.  I've used the Arduino boards before and I think they serve a purpose but I wanted something with a little more horsepower that could run apps as well.

Setup

When the Pi arrived I had some initial problems but nothing too major.  When I plugged in the Pi nothing happened even with the SD card installed.  I was confused on this and there was no clear answers online.

It turns out that the installer I downloaded for Fedora Remix was old and I ended up having to download the new installer and newest builder of Fedora Remix.  The newly installed image worked great and the Pi started right up.

I was impressed as well that a Gear Head USB keyboard and a USB mouse I had laying around worked instantly without any setup.  It launched me into the GUI (Xfce) and walked me thought some basic install steps.

Impressions

Running via the GUI is a little sluggish.  I found that browsing the web was a little slower than I would have preferred.  I'm not sure if overclocking from 700mhz to 1Ghz will make a big difference in that regard or not.

I wanted to see if the Pi could render video and attempted to launch some type of streaming video.  Netflix didn't work through Midori.  Amazon wanted to download the Flash player which I started to do but didn't seem to finish.  I will investigate these more.  I will also attempt to run YouTue.

Next Steps

I want to try and get Spotify to stream from the Pi along with testing the GPIO.  I'll see if I can get Netflix or Amazon Instant Video to run and see if it runs well.  Eventually as well I want to use this to stream media from other computers in my household.

Friday, October 25, 2013

Card Shuffling

I was playing around with building a card game engine and ran across something interesting.  My solution as I found all over the internet was to use Random() to generate a random number and use that to "order" the list (array) representing the deck.

My "test" game was basically high card where each player had a deck and drew a card.  The person with the highest card won the hand.  As I ran the test either Player 1 won or the game was a draw.  Player 2 never won.

As it turns out Random is not very good at generating random numbers. It uses a fixed algorithm such that the result are very predictable.  Also, it is an expensive operation as it is not very efficient.

A sort is actually a better solution and using sometime to generate random unique values works better.  I don't take credit for this code but here is an example of the better implementation:

var cards = Enumerable.Range(0, 51);
var shuffledcards = cards.OrderBy(a => Guid.NewGuid());

Monday, September 23, 2013

WebBrowser Control: Password Field Won't Populate

I ran into this issue between version of IE.  On IE10 on a password field using the WebBrower's SetAttribute method works to set the "Value" field of a password field.  This does not work on IE 8 or 9.  Instead, you have to use the "InnerText" attribute.  To make sure 10 still works I have to set both the Value in addition to the InnerText value for the older browsers.

Friday, January 18, 2013

Using Silverlight Toolkits

Quick tip:  When using the Silverlight Toolkits keep in mind they typically target a specific version of Silverlight.

I recently installed Silverlight 5 and the Silverlight 5 toolkit.  I added a reference to a v5 component and it appeared in my designer but my code behind gave an error it couldn't find the reference to the control.

As it turns out someone else on my team using TFS didn't have Silverlight 5 installed (only 4) and checked in to TFS with the project target as v4.  Switching it back to v5 fixed the issue.

So be sure to check the target version if you're having trouble with a control from one of the toolkits!