Friday, May 01, 2015

Review : Fitbit Charge HR

Even though I don't always get 10,000 steps a day I love my Fitbit One. I'm a firm believer in the psychology of "if you measure something, you will naturally be motivated to improve your score."  My biggest problem with the Fitbit One is that it goes in my pocket, and then I forget about it for the day until I take it out at night. I never stop during the day to wonder how many steps I'm at. If it gets to be 11pm and I take it out for the night and I'm at 8000 steps, I don't really have an option.

What I *do* do is spend the day wondering if I've accidentally lost it.  If I've got my car keys or something in my pocket, then every time I take my keys out I'm wondering if my One came out with them and fell on the ground. That's annoying.

The other problem with the One is that there's plenty of activity beyond just steps. You start to feel like you're cheating yourself when you realize you're not getting credit for stuff like pushups, situps, various other cardio exercises that aren't distance related.

So when Fitbit announced the Charge HR I knew I wanted one. The Charge HR has two things going for it right out of the box. First it goes around your wrist, so that takes care of my "never look at it" and "afraid I'm going to lose it" worried.  I have no interest or plans in getting an Apple Watch anytime soon so that's not a consideration at all.   Second, the watch actually has a pulse monitor built in so, at least in theory, not only are you tracking your steps during the day but you're tracking your activity level. So if you're not walking anywhere but you're still getting your heart rate up where it needs to be, you get credit for that.

Mine arrived last week.  Here's my review.

Right off the bat, don't make the same mistake we did - this device comes in sizes.  Don't just walk into the store and grab one off the shelf like my wife did, you'll end up with a Small that will barely fit your kid.  We had to return mine (a birthday present), only to discover that the Large size was sold out. Had to get it online.  When the Large arrived I'm still pretty close to the end of the band, but it's not worth the effort to go get an XL (not even sure if it comes in an XL).

The band takes some getting used to. It's rubber, not leather, so not only will there be no "It starts to wear down into a groove where I keep it buckled," but there's a texture there that's actively working against you when you try to wrap it around your wrist. Since it's a device you'll be taking off every time you shower, you're going to have to get used to that.

The standard functions are all there - steps, distance, calories. I'm not even going to bother reviewing those, because they work the same as the rest of the Fitbit devices. What's interesting to me is what else it does.

The pulse monitor works by this LED technique that apparently is measuring the constriction of blood vessels. Pretty cool. I was worried about the accuracy, though, based on what I'd read ahead of time. The instructions for properly positioning the device are a little off putting as well -- you're told to keep the band loose, but to wear it several finger lengths above your wrist bone. Do they not realize that, since the natural position of your arms is straight down, that gravity is going to pull the band down to your wrist bone most of the time?  The good news, though, is that I have access to actual medical devices to measure my pulse, so I did a side by side comparison. I'm happy to report that I got a perfect 1:1 match.

An interesting side effect to this feature is that you've got a pulsing LED on your wrist, which means that in a dark room if you bend your wrist the right way and the sensor does not sit flat against your skin, suddenly you're Cyclops when somebody rips off his visor, with laser beams shooting in random directions.

The device has a few interesting features as well. It vibrates, which turns out to be quite useful. When you hit your step goal for the day, it'll vibrate to let you know. You can also, with the help of the dashboard, use it as a silent alarm.  I'm not sure if I trust a little buzzing on my wrist to be my primary alarm, but it works very well for my particularly situation. My wife and I wake up at 5:30am during school days, and then watch the news for about half an hour until we have to get the kids up. And depending on how sleepy we are, afraid that we'll fall back to sleep, I end up having to turn over to look at the clock every 5 minutes to make sure that we're not oversleeping.  Well, not anymore. My Fitbit is set to buzz Mon-Fri at 6am. Done.

Which brings up a good point that I haven't mentioned, there's an actual clock/calendar in the thing too. So it doesn't just look like a watch, it's an actual watch.

Apparently it will also do caller ID, though I have not yet tested that feature. Perhaps as a way to keep a little more competitive with the encroaching smart watch market, the device is already synced to your phone so why not take advantage? When someone calls, your fitbit will tell you who it is. You can't answer/deny the call, but at least you can decide whether to take it.

So far I love it. The HR monitor is working like I expected. It's comfortable. I'm more aware of the device on my wrist, checking it throughout the day, than I ever was with the one I had to pull out of my pocket.

Wednesday, April 29, 2015

Why Does My Google Cloud Print Printer Keep Going Offline?

When we got a Chromebook for the house I had no idea what "Google cloud print" even was.  It's turned out to be more of a pain in the neck than anything else and I'd gladly go back to the old way if I could. I've never had to temporarily share a printer with my neighbor, or print something at home when I was at work, or any of the other situations it is supposed to make easier.

Worst of all, the printer regularly goes "offline".  This is the most frustrating error message in the world, because your printer is on, it is connected, it prints test sheets fine, you may even  have some real computers available that do it the old fashioned way, and those can print fine. But cloud print says it's offline and offers no suggestions for how to fix it, other than to go messing with your firewall  - something that no doubt most of the folks opting for Chromebooks know exactly how to do, right?  This became such a problem that we bought a new, "cloud print ready" printer thinking that it was our old "classic" printer's problem.  Wasn't.

Here's a solution to the problem that may work for you. When you initially register printers with the cloud print service, they are associated with a device. That device has to be online to see the printer!  I learned this the hard way when my daughter got a Chromebook and I registered it using my laptop, which only made sense because that's where I do 99% of my computer work.  The problem was that whenever I closed the laptop and went off to work?  Printer stopped working.

After figuring that out we re-registered the printers using our server (a Mac mini) which is up all the time, and the problem basically went away.

In fact, it went away so well and for so long that when my brand new printer went offline this week (and claimed it had been offline for days) I was furious.  I started the whole process all over again.

Then I remembered that over the weekend my son had friends over and one of them had accidentally unplugged the server.  Even though I'd plugged it back in I had not powered it back up.

Went downstairs, powered it up, and look at that, my printer's back online.

Tuesday, February 17, 2015

Android : File exists but canRead() returns false

I'm working my way through this developer document about capturing and saving photos and ran into a problem. My photo was saved properly, I could call up the ADB shell and verify it. But when I tried to read it back so that I could display it on the screen, this code would fail:

File imgFile = new  File(mCurrentPhotoPath);
if(imgFile.exists()) {
    Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
    ImageButton btn = (ImageButton)findViewById(;

Sound familiar? I had requested the WRITE_EXTERNAL_STORAGE permission properly (which implicitly gets the READ_EXTERNAL_STORAGE permission as well), so that wasn't the problem.

It turns out that the file does indeed exist, but it was failing on canRead().  Since canRead()==false, exists() was also returning false.

Ok, then, why can't I read it?

The problem lies in the photoPath, and whether to use a URI or a regular file path descriptor.  The code that we're talking about ends up structuring a unique image filename that looks like this:


which worked fine to save the file. But on a hunch I tried a pure file path:


and guess what? That worked.

Wednesday, January 07, 2015

Android APK Can Not Press Install Button

There's lots of reasons why you might want to load an APK file directly onto your Android device. In my case I'm developing an app and didn't want to always have a USB connection setup, so instead I save the APK to my Dropbox directory, and then it appears nicely on my device.

But a problem appeared recently. I get a dialog asking to confirm the install, with CANCEL and INSTALL buttons. And the Install button doesn't work.  This is weird.  It's not disabled. It shows no interaction like it even realizes I'm pushing it. The Cancel button continues to work. But Install, no matter what I do, will not work.  I long press it, I do everything I can think of. Nothing.

I do have "Allow unknown sources" checked, of course. Just to get that out of the way.

I google around and find references to disabling any "screen dimmer" apps that might be running. Why? I have no idea. But I do run Twilight, which alters the colors of my screen at night so it doesn't glare in my face.

I turn that app off, and look at that! The install button works all of a sudden.

How To Record XBox 360 HDMI To Composite Video

My 8yr old son currently idolizes somebody named Stampy Longnose, who is a character that makes YouTube videos of himself and his friends wandering around Minecraft. For months my son asked for "recording material" so that he, too, could develop a following like Stampy.  We kept saying "Maybe for Christmas, maybe for Christmas." Well Christmas came, and he did not forget, it was at the top of the list.  So his grandparents got this magical recording material for him. Since they had no idea what it is, of course, now it's up to dear old Dad to make it work.  It took me a lot longer than I thought it would, so I'm documenting the process for those other dads that find themselves in a similar situation.

My son has an XBox 360 E. I can only speak for these instructions relative to that particular console. I discovered that this is a big deal, because it appears that our old pal Microsoft has been changing the video output port pretty much every time.

There are many results on Amazon for xbox recording device (I don't know why my son insists on calling it "recording material"), ranging significantly in price. Although we've got our device connected via HDMI I was not prepared to get what seems like the most popular device, the Elgato HD Capture.  After all I have no idea if he's going to get bored with this in a week once it actually works. Instead we went with the Elgato Video Capture, which is almost half the price. I say we, because although this is the gift my in-laws wanted to give him, they had no idea what it is so I was tasked with doing the research and picking the item :)

Christmas came and went, my boy was excited to finally have the device and we went about setting it up ... and I discovered my first problem.  Our device has an HDMI port.  This recording device has composite cables, otherwise known as the classic Red/Yellow/White combination. Do not confuse this with "component cables", which have 5 separate heads including a green one.

This is not a problem. I get back on Amazon and search for "XBox composite cable", getting plenty of results for around $10 or less.  I bought one. DO NOT DO THIS.  I'm deliberately not linking it.

We wait a few Amazon Prime days, cable arrives and ... it doesn't fit. The particular cable I got has this big fat port on one end, bigger than an HDMI port, and my device simply does not have that.  "Aha," I think, "I must have mistakenly gotten the cable for an older XBox model, not for the 360.  My bad."  I return to Amazon, search for "XBox 360 hdmi composite cable," and thinking I see one that has an HDMI port on the end, get that one instead.

Nope.  Same stupid cable with the big fat end.  Now I'm upset.  My device simply does not have that port.  All I have is an HDMI port, and a little 3.5mm jack next to it that I have assumed is a standard audio-out jack.

It's not.  I finally found this document from Turtle Beach that set me straight:
As you can see above, the trapezoidal A/V (Audio/Visual) port from older Xbox 360 models has been removed and replaced with a single 3.5 mm output jack. The Xbox 360 E includes a 3.5mm Composite A/V Cable (yellow, white, and red), used for connecting to standard-definition TVs.
Oh! That explains both my problems.  First, it is the "E" model that got rid of the older A/V port, which explains why I keep getting the wrong cable.  Second, that 3.5mm jack is actually going to spit out both audio and video.  Nice.

What I needed was this cable . Your XBox came with this cable, but if you're like me and immediately plugged into the HDMI port of your television you may no longer know where you put this original cable.  I actually lucked out, I found it gathering dust in a drawer under our television.

Now we're cooking.  Plug the 3.5mm jack into the Xbox, plug the Red/Yellow/White into the recorder, what.  There's a USB port on the other end of the recorder, so we plug that into my Mac, download the software, and it goes into setup mode asking me to plug in the yellow cable and proceed when I see video.  I don't see video. What's weird is that I'm getting audio.  I wonder what the odds might be that this brand new cable is somehow broken, and decide that can't be the case.

I'll fast forward here. Two things.  First, you can't have your HDMI and your A/V both plugged in at the same time. If you do, the video will only go through HDMI, and go to your television rather than your recorder. So unplug your HDMI.  Yes, this means that when you want to record your Xbox you're going to have to get behind your console, unplug it from the tv, and only watch it on the computer. I did not realize this would be the case and I don't think my son did either, but it's not the end of the world.

Second, you can only do this when the power is off.  If you are looking at the "No Video" screen in the Elgato software and unplug the HDMI cable, nothing will happen. Power cycle your XBox and you should now get your video signal!

Once connected, everything else works identically. My son watched me fire up Minecraft and almost get killed in about 3 seconds before he just grabbed the controller and rescued me. But the important part was that it still works identically to the XBox. Nothing about keyboard controls or anything weird.  You're just playing on the smaller screen.

Almost done. Do you want to play XBox Live?  More specifically, do you have one of those headset microphones that allows you to chat with your friends and basically narrate your game playing experience? My son's got the Turtle Beach XL1 which like much of this other stuff was a good entry level item to see whether he's going to stick with it. Something that might be common in the videogame world, that was completely bizarre to me, is that to get the chat working there's actually a special cable that comes off the headphones - and plugs into the XBox controller. Why? I have no idea. But if you want the other people playing the game to hear you, this is a necessary step.

Did I mention that my son's best friend has a similar setup, along with the recording material? When they learned that we'd gotten one for Christmas, the father told me, "You'll have to let me know if you get the chat working, we can't figure it out."

And there's the problem. How do you get that audio to go through the recorder? Turns out, you don't. Here's the word, straight from Elgato:

All gaming headsets we've encountered so far do not down-mix the live chat from the microphone to the audio output of the PS3 or Xbox 360. 

This means that Game Chat audio from the local gamer will not be recorded by Elgato Game Capture HD. 
You will still hear audio from other players during gameplay, and in your recording. 
You will still hear your voice during gameplay, but not in your recording.
That stinks. That might even be a deal breaker, depending on what you were hoping to accomplish. But! I wasn't done yet.  We've come this far and a father hates to disappoint his son.

Elgato points out that their Elgato - Game Capture HD version (you know, the more expensive one I chose not to get?) comes with a software option to do Live Commentary. I can't really say more about that because I don't have it, but perhaps that alone is enough to make you get the more expensive device, if you haven't already made your purchase. I'm not quite ready to go there.

I had one last option. It's not that hard to add voiceover / narration to videos, especially on a Mac. I tried it briefly with iMovie but didn't like the experience, so I ended up with Wondershare Video Editor. This software seems like the last piece of the puzzle.  My son will make his videos, then when he plays them back he can narrate what he did and why he did it. Might take him a little while to get used to that. And I'm not yet sure how that's going to work when he has other friends playing, because remember - the recorder will pick up *them*, but it won't pick up him.

Anyway, that's what we did to make it work. Hope it helps all you dads out there get the next generation of Stampy Longnoses producing their videos!

Saturday, November 15, 2014

Ready, Aim, Pop! How My Son Built His First iOS App

A few weeks ago my son, who is 8, figured out what I do for a living.  He discovered that I know how to put an app in the iOS App Store.

So naturally he asked, "If I make a game, could you make it so people could get my game on their phones?"  I said sure.

Thus began our father/son project for the next couple of weeks. We decided to go with the programming environment Game Salad, which had one serious advantage over the many others -- it could actually produce appstore-ready code, without really doing any serious programming.

My son had pitched an idea that went something like this : "What if these colored balls were falling down the screen and you had to tap all of them except the white one?"  I suggested, "What if instead of falling down, it was balloons going up the screen? And same thing, you have to tap them before they get to the top? The tapping could be like popping them."  He liked that idea, and we were off. Somewhere along the line the "don't tap the white ones" rule morphed into "the clouds are going to start getting in your way but if you tap on one you lose points".

He did all the graphics (ok, with a little help from his sisters) and played all versions of the game as we improved it.  Too fast.  Too slow.  Too many balloons, not enough balloons.  Balloons are too big, too small. Finally we got it just right.

Getting into the app store has a bunch of baggage that very much does not keep the attention of an excited 8yr old boy, like writing descriptions and filling out legal disclaimers and making screen shots in exactly the right size (seriously - if you're one pixel off, it won't accept you). Luckily I had experience with that, as noted, and cranked through the boring details while he was sleeping.

Try #1 we got rejected, because I'd clicked the "Made for Kids" option.  After all, I had no reason to think that it's not for kids, there's no violence or anything like that and it was in the 4+ age category.  But I hadn't considered ... the basic version of GameSalad that we're using puts in advertisements, and I do not control those. That's what got us rejected, the content of those ads.

Try #2 I turned off that option and held my breath. It takes about a week every time you submit an app for consideration so we were heading into two weeks since the last thing my son could actually help with, and I was afraid he was getting bored.

But, success! I got the note at maybe 9pm a few days ago, shortly after he'd gone to bed. So I went upstairs with the laptop, nudged him back awake, and said "Hey, read this for me."  He read, "The following app has been approved and the app status has changed to Ready for Sale....we got in? It's on the store?" I confirmed that it was indeed on the store and he immediately rolled into, "How many downloads do we have?"

I told him to be patient and go back to sleep. :)

I hope you get a chance to download the game. He asks me every morning what his numbers are (he calls them likes, and I haven't seen the need to tell him different :)).  If you think it's worth the extra time maybe throw him a rating/review. It's great to see how proud he is of his accomplishment, and I want to do everything I can to make this a positive experience for him. Maybe he'll want to make more!

Thursday, September 26, 2013

The Sum of Even Fibonacci Numbers

A co-worker showed me the following problem last night:

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
If you jump too fast to your early CS101 knowledge you might bang out a recursive fibonacci function to get yourself started (using Ruby as an example):

def fib(n)
  return 0 if n==1
  return 1 if n==2
  return fib(n-1)+fib(n-2)

But that's not terribly efficient in this problem, where you'll end up calculating and recalculating the fibs all the way up to 4 million.

If you spot that the recursion will just do an absolute number on your stack management and want to get it out of there you can write the function without it:

def fib(n)

  prev = 0
  curr = 1
  (n - 1).times do
    curr, prev = prev+curr, curr

But you're still going to calculate too many numbers and end up with a solution that is O(N^2) because every time you move to position N your function is going to recalculate everything from 1 to N-1.

Instead, don't abstract the function.  Treat it like the formula that it is, and write it in a single loop.  You are going to be calculating your variable N using the N(x) = N(x-1)+N(x-2) formula, until N>4000000.  Along the way, if N is even, add it to your growing sum:

first = 0
second = 1
sum = 0
while (second < 4000000) do
  sum += second if second.even?
  temp = second
  second = first + second
  first = temp
puts sum

Did you get 4613732?  You could clean up that code a bit and there's tricks to avoid that temp variable but I want to get to a better solution.  The one above calculates all the Fibonacci numbers less than 4 million, which means it goes through the loop 33 times.

We can do better.  If you look closely at the fibonacci sequence you may spot a pattern in the even numbers.  Did you notice that every 3rd number is the even one?  Which makes sense because once you bring even a single odd number into the pattern it's going to go the same way -- even plus odd equals odd, odd plus odd equals even.  So the Fibonacci sequence goes odd even odd odd even odd odd even odd where each even number is wrapped with odd numbers.

How can we use this?  Well this means if we know that fib(N) is even, we want to jump to fib(N+3) without worrying about the two in the middle.  So instead of looping over them why not just calculate them while we're here?  I'm going to use the sequence 5,8,13,21,34 as an example.  If I'm on 8, I want to calculate 34:

Given fib(x)=8
Given fib(x-1)=5
Calculate fib(x+1) = (8+5)
Calculate fib(x+2) = fib(x+1)+fib(x) = (8+5)+8  = (8*2 + 5) = fib(x)*2 + fib(x-1)
Calculate fib(x+3) = fib(x+2)+fib(x+1) = ((8+5)+8)+(8+5) = (3*8 + 2*5) = fib(x)*3 + fib(x-1)*2

Still with me?  So as long as I have fib(x) and fib(x-1) I can jump to fib(x+3) with some multiplication.

So now I can go through the loop like this:

x1 = 1

x  = 2
sum = 0
while (x < 4000000) do
      sum += x
      n = 3*x+2*x1
      x1 = 2*x+x1
      x = n
print "Your total is #{sum}"

Same result, only this time we bounced up to 4 million in just 10 hops.

Again, we could probably make it even more efficient than that by considering the actual cost of each math operation - I added some multiplications but now I'm also no longer testing for even numbers, so maybe it's a wash. I was mostly interested in showing that whole "even numbers every third so only jump by 3s and don't test for even" pattern.

I wanted to document this approach since I haven't seen it yet as one of the standard answers.  Enjoy.

Tuesday, September 17, 2013

Copy And Paste Between Two Devices

If you're a developer, this has probably happened more than once. You're working on two devices that are physically right next to each other, yes? Maybe, like me, you've got your iPad next to your laptop.  And inevitably you find a link on your laptop that you want on your iPad.  Blah.  What's the fastest way to get it from one to the other?

Sure you could mail it to yourself, or drop it in DropBox, or even maybe type it directly into the secondary device.  All too much bother.

Run an instant messaging program of some sort on both devices (like AIM).  IM the message to an understanding friend.  Now go over to your secondary device and fire up the conversation.  Your message, link included, will be there.  

Totally hacky but it's the fastest way I've yet found!