Wednesday, October 10, 2012

Solved: Difficulty Pairing Apple Wireless Keyboard

I have an Apple MacBook Pro, and an Apple Wireless Keyboard.  From the very first day the keyboard has been difficult to pair with things.  Changing it from the computer to an iPad, or iPhone was always a confusing hassle.  The keyboard has only has one button and one status light, and gives almost no feedback.  I am surprised at the trouble it has given me as this is not an inexpensive keyboard.  Lately this hasn't been a problem as I have just left it paired with the MacBook Pro

Recently I paired it with an Android phone.  When I tried to unpair it from the phone, and repair it with my MacBook Pro, nothing worked.  I tried holding down the button, pressing the button and different key combinations, etc.  Most of the time the MacBook couldn't even find it, and if it did, the pairing would fail.

Then I tried to repair it to my Android phone, that didn't work either.  I tried pairing it to another Android phone.  Nothing.  I changed the batteries for new ones (twice).  Most of the time the green light would come on for about two seconds, and then turn off.  This was all very aggravating, since pairing is the must fundamental thing that the keyboard needs to do.  It is unusuable if you can't get it to pair.

Finally I found a good idea online.  I am documenting it here so that if I ever have this problem again, I will remember the steps that I had to take to repair.  I have tried this with both the Android phone, and the MacBook Pro, and it seemed to work with both.


  1. Turn on Bluetooth (if it isn't already turned on).
  2. Begin scanning for devices.
    • In Mac OSX, click on the little Bluetooth icon at the top of the screen.  Click "Setup Bluetooth Device...".
  3. After the computer or phone begins scanning, press and hold the power button on the wireless keyboard.  This is important.  When I tried pressing button first, then scan, nothing happened.  You have start the scan first, then press and hold the button.
  4. At some point the green light usually starts flashing (although not always.  weird).
  5. After a few seconds, it will (finally) notice the keyboard.  You may have to click on the keyboard to tell it to pair.
  6. It will ask you to type a few numbers to verify the pair.  At this point you can release the power button.
  7. Type in the requested numbers.
  8. The pairing should complete.
Hope this helps someone else out there.  I know that at some point in the future I will need to know this information again.


 

Wednesday, February 29, 2012

Identifying data type in literals without casting

Learning c#. When declaring literals, it turns out there is are some special suffix characters you can use to declare data type. They are:

• M (deciMal)
• D (Double)
• F (Float)
•L (Long)

So, for example, if you do the following:

decimal salesTaxRate = 6.5;

The compiler will interpret the literal "6.5" as a double, and you're going to have problems. But, just append a"D" and you're good. Like so:

decimal salesTaxRate = 6.5M;

Now the compiler interprets 6.5 as a fixed-point decimal, instead of a floating point double.

Why the compiler can't just assume that the double literal needs to be cast to a decimal, I can't say. Maybe one of the C# experts out there can say?