Category Archives: Jeremy

Remote Blood Sugar Monitoring

With Samantha about to start in the competitive gymnastics program, we really needed to have a better way to monitor her blood sugar.  In the recreational program which she has been a part of until now, Cynthia or I would sit in the waiting room.  She would stop by and let us test her if she felt low.  With the activity, she did tend to drop during her gymnastics classes.

But for the competitive program, the coaches really do not want the parents sitting in the waiting area and potentially distracting the girls.  I am sure they would make an exception for us but we wanted to give Samantha some more space.  At the same time, we knew that gymnastics was one of those times that her blood sugar needed to be watched closely.

We decided to get a continuous glucose monitor for Samantha.  There is a sensor which is inserted into her skin and replaced every several days.  A transmitter sits on top of the sensor and send the readings every five minutes to a receiver wirelessly.  The receiver has a screen and you can look at recent readings and trend arrows that tell you how her sugar is changing.

The receiver needs to be within about 20 feet or so though.  To make the next jump, we used something called NightScout.  NightScout is a project by several people online to piece together a way to monitor blood sugar remotely.  You connect the receiver to a cell phone using a USB cable.  The cell phone runs a special app which reads the blood sugar readings from the receiver and sends them out to a database you setup on the Internet.  You also setup a web server on the Internet which reads the database and presents the readings to a web browser.  Then, there are apps for the iPhone and other devices which display the data.

The NightScout setup instructions describe how to setup a database and a web server on two different hosting platforms.  Initially, I setup services on these other hosting platforms.  I did this so I could at least test everything and ensure it was all working.  Easiest to follow the instructions exactly the first time.  Once I saw how it actually worked, I was ready to do it my way.

I have had my web hosting with Dreamhost for years and I really didn’t want to suddenly use a bunch of other services.  First, I needed to move my existing web sites (including this one) from their shared servers to a VPS (virtual private server).  The web server for NightScout is node.js based and will not work from a shared server.  Dreamhost moved my existing websites to the VPS without a hitch.

Next, I setup the NightScout database on my new VPS.  I redirected the cell phone to send the readings to my new database and sure enough, I started getting data.  I changed the web server (still at the non-Dreamhost server) to get its data from my VPS hosted database and that worked.  Now I needed to move the web server.

I grabbed a copy of the Javascript source for the node.js server and poked around for bit.  The instructions have you use these other hosting services partly because they are cheap but also they have nice interfaces for configuring everything.  I was working from a command line into my VPS and trying to figure out how to configure things.  When the instructions said to set a field in a form to X, what do I need to do in order to accomplish the same thing.

After browsing the code for the server a bit, I wrote a simple script to setup some config options and launch the server.  After a couple of tries, I got the script right and the server started working.

With that up, I changed Cynthia’s and my phone to pull data from the server running on our VPS.  I decommissioned the services I setup with the other providers.  The entire solution was now running through a VPS I managed.  I wrote a backup script to make sure all of this configuration was backed up every night.  The backups go back to our computer at home.

We even bought a Pebble watch for Cynthia which lets you have the blood sugar readings right on the screen of the watch.  So, here is the sequence of events to get blood sugar readings to us:

  1. The sensor takes a blood sugar reading.
  2. The transmitted connected to the sensor sends that reading to the CGM receiver wirelessly.
  3. The cell phone pulls that reading from the CGM receiver through a short USB cable.
  4. The cell phone uploads the reading to the database running in our VPS.
  5. The web server on our VPS provides that reading and all other data to any client which requests it.
  6. Our iPhones have apps on them which will communicate with the web server on the VPS and display the blood sugar values and trends in real time.

The only requirement is that the receiver/cell phone stay within about 20 feet of Samantha and that the cell phone has a good Wifi or cell signal so it can upload the data.  This will be how we give Samantha more independence while also continue to be able to manage her blood sugar.

Infiniti Q50

I bought a new car.  And not just new to me.  An actual, for real, new car.

When we moved to California, we had to buy cars for both Cynthia and I.  Importing our existing vehicles was more trouble than it was worth.  We both bought used cars.  Cynthia got a 2007 Toyota Matrix and I got a 2005 Infiniti G35.

I have always been happy with the G35 but it was now ten years old and it was time for something new.  That something new was the Infiniti Q50.  It is essentially the successor of the G35 I was driving but in some ways, it is an entirely new car.

The Q50 has “drive by wire”.  The steering wheel has a mechanical connection to the wheel but that is a backup.  With the Q50, when you turn the steering wheel, software responds to that and makes the appropriate change to the direction of the front tires.  Feedback goes both ways so you still get a feel for the car through corners.  This also allows you to select the kind of handling you want.  Do you want loose casual handling?  Do you want tight control in “sport mode”?

It has a pile of safety features.  It has blind spot detection so small lights on either side come on if there is a vehicle in a blind spot.  If you try to turn towards a car which is in your blind spot, it sends an audible alarm.  It will even take temporary control and stop you from steering into the other car.  Again, because it is “drive by wire”, it can do these kinds of things in software.  The Q50 even tries to detect the lanes and it will warn you if you are drifting out of your lane.  Again, if you ignore the alert, it will take over and put you back in your lane.

The Q50 is monitoring the distance between you and the car in front of you.  If that car brakes quickly, the Q50 will brake for you in order to try to avoid an accident.  Even more, the Q50 is monitoring the distance between the car in front of you and the next one ahead.  If the car in front of you is closing quickly on the next car, then chances are the driver ahead of you is going to slam on the brakes.  Again, the Q50 will brake preemptively.  I have seen this come on at times and it feels strange to suddenly be slowing when maybe you still have your foot on the gas.  But there is evidence that features like this really do reduce the chance of collisions, so I am willing to put up with that odd feeling the very few times it happens.

But the feature I like the most is the adaptive cruise control.  We drove to Toronto recently and it was my first chance to really try it.  Basically, you set a target speed and the Q50 tries to go that fast.  But if you are approaching someone going slower, the car automatically slows down to keep a safe distance.  You have some control over what that safe distance is.  I think I took cruise control off three times in the whole trip to Toronto.  I had cruise control on through Toronto highway traffic!  As you approach someone going slower, you just signal and switch to the right lane.  The Q50 detects that the lane is clear and goes back to the target speed.  No need to turn off cruise control.  Normally, you have to make decisions.  Can I leave cruise on?  How close will I get to this guy in front of me before I can get to the right and pass him?  And you are always tempted to get too close.  Now, I just don’t worry about it.  The car is managing my speed.  I am just making decisions about which lane to travel in and when it is safe to switch.  The stress level for the trip was definitely lower.

I am very happy with my new car.  And it is definitely an intermediate point along the way to truly self-driving cars.  I like to drive but if I could have let the car drive us to Toronto on our recent trip, I would have.

Spring Finally Arrives

IMG_0671It has been a very long winter this year.  But this past weekend, we had our first real spring day.  Saturday was a bit cool but by no means cold.  It was windy so we took one of our kites to the park.  Samantha spun all the line out and flew the kite for quite a while.  If you look at the pictures, you will see her holding an umbrella between her legs just in case the weather changes.  I guess after that winter, she has come to expect the worst but the umbrella wasn’t needed.

After several minutes, she was done flying the kite and passed it over to me.  She ran to the swings while I flew the kite for a while and slowly wound it up.

IMG_0669A bit later, Matthew and his friend Ryan came home from their curling practice.  Ryan had never flown a kite so we set it up again and they both passed the kite back and forth between them for a while longer.  Before we knew it, we had spent the entire afternoon at the park and it was time to head home and prepare some dinner.

Sunday was even better.  It wasn’t windy so we left the kite at home.  We spent a couple hours setting up the patio furniture and just cleaning up the lawn.  With our chores done for the day, it was back to the park for a few hours before dinner.  After dinner, we spent another hour at the park.

Something tells me that we were suffering a bit of cabin fever from the long, cold winter.  But it seems that is well and truly behind us now.  On to BBQs, kite flying, park visits, walks through the neighbourhood, bike rides and lots of other outdoor activities.

 

Christmas 2014

This year, we attended the Alcatel-Lucent Christmas party as we normally do.  Matthew and Samantha sat on Santa’s lap and passed along their wishes for Christmas Day.  Samantha got her face painted to look like a cat and really enjoyed the magic show.  Matthew is getting a bit old for this event but he was fairly patient.

A few days later, we got our tree.  Joey didn’t know what to make of it and spent a fair bit of time under it, batting at the lower branches and ornaments within reach.

On Christmas Day, Matthew and Samantha found that Santa had come.  He left some wireless headphones for Matthew.  I guess Santa was as worried as I was that Matthew would eventually walk away from an iPad which he was tethered to with his old wired headphones.  Samantha got an iPhone 5 which she will be using as an iPod Touch (i.e. no cell service).  Again, Santa seems to think the same way as I do that a used iPhone 5 is a better deal than a new iPod Touch today.

Samantha also got an American Girl doll and some accessories which she was very excited about.  Matthew got a fair bit of Lego for Christmas also.  You can see a picture of Matthew working on assembling one of his new Lego sets while Joey sits on his shelf wondering what is going on.

After Christmas, we are headed to London and Toronto to visit my brother and his family and Cynthia’s dad.  We will be back home in time to ring in the New Year and before you know it, we will need to be back to work/school.

Christmas with Friends

The weekend before Christmas, we had Natalie, Louie and their kids over for a Christmas/Hannuka dinner.  I was roasting a turkey, the kids were playing the basement and the adults were relaxing in the living room.  Suddenly, all the kids came running up the stairs saying that water was pouring out of the ceiling.

We all went downstairs and a section of the basement ceiling was definitely wet.  It wasn’t clear where the water was coming from though.  The water wasn’t pouring from the ceiling any more so whatever the kids say was probably a pool of water which suddenly found a path out and emptied.  But water was definitely collecting in the ceiling.

Figuring that all the drywall would have to be replaced anyway, I started to cut away pieces to try to find the leak.  Eventually, I found a copper elbow which seemed a likely candidate.  Sure enough, it was wet.  With it exposed and a bucket under it, we could hear a slow drip.  This is the second time we have had a bad elbow in the plumbing in the basement.  The first time, I had to remove and replace about a one foot square section of drywall.  This one is much worse and the cleanup job will take longer.  The leak has since been repaired but we still have a hole in the ceiling.  It will eventually need attention.

The excitement kept me from checking the turkey but everything ended up working out OK.  Shortly after that, we served dinner without any more hitches.  However, Natalie did pull a knife on Louie for some reason just before dessert.

Tobogganing with James

Steve, Katherine and James came to visit us this winter and we spent much of the time at the local tobogganing hill.  I grabbed some video of the kids as they enjoyed the day with their sleds.

KansasFest 2012

IMG_0210This story begins early in 2012. I was listening to the latest episode of Retro Computing Roundtable, a podcast about old computers, when they started talking about KansasFest. KansasFest is a gathering of Apple // enthusiasts which has been happening yearly for many years. The 2012 event would be their 24th and the hosts of the Retro Computing Roundtable announced on their podcast that they would all be attending.

Among the hosts is Earl Evans who had often talked about wanting to attend KansasFest the same way that I had over the years. In university, I just didn’t have the money. After university, I was focused on my BeBox and BeOS. And then I was married and Matthew and Samantha arrived. There always seemed to be a good reason why I couldn’t go.

But Earl and the rest of the hosts found a way. I literally paused the podcast and started thinking “why couldn’t I go this year”. Maybe it would be too costly? But I have lots of air miles – enough to get me a flight there for free. And the cost of the event itself is cheap considering that meals and lodging is included. Would my family be OK with me going on a “vacation” by myself? And there is the problem that our wedding anniversary happens during KansasFest.

So, I asked the boss and after a bit of negotiating, I had my OK. I booked my flight and registered. I was going to KansasFest!

I subscribed to the KansasFest mailing list and as the date drew closer, the traffic on the list increased along with my excitement. At one point, someone sent an email asking who was going to be bringing real Apple //’s to the event. I was surprised to see how many people were bringing their old computers. I really wanted to bring my Replica One or my Apple //e but I didn’t trust the airline to treat them properly. I was only planning to bring my MacBook and an iPad.

But everyone seemed to be bringing a pile of cool old hardware. I needed to bring something so I looked around my room and saw my Curta mechanical calculator. That was something I could easily transport and people should be interested in that. So, I replied to the mailing list that I wasn’t bringing any of my Apple //’s but I would have my Curta.

Soon enough, I was in Kansas City and meeting people who I had heard of by watching the Apple // community. People like Ken Gagne, Tony Diaz, Geoff Weiss and more. I listened to John Romero describe the early days of game programming on the Apple // and the strange characters who wrote some of those classics. Randy Brandt talked about Beagle Bros. and the story of AppleWorks. Randy is a Canadian originally from Manitoba and we chatted for a short time about that. I met Vince Briel who created the Replica One which I built. I demonstrated the Curta to many people and it was definitely a unique bit of hardware at KansasFest.

At meals, people would often ask if I was working on a HackFest entry. HackFest is a programming competition where you create something during KansasFest and on the last day, everyone demonstrates their program. They are judged and winners are selected. I had a big project I was working on before KansasFest which was not eligible under HackFest rules and I planned to continue working on it throughout KansasFest. But everyone was encouraging me to do something for HackFest.

Walking back to the dorms afterwards, I started to think what I might do for HackFest if I was going to enter. Then I realized that what I should do is write a simulator of a Curta calculator for the Apple //. The Curta has a crank as its primary interface and I could simulate a crank using the joystick. With a bit of graphics and sound, I could make a pretty good simulation of a Cuta.

I started working on it right away. I used my MacBook and coded it in C using the cc65 cross compiler. I tested it using the Virtual ][ emulator. First, I got a basic simulation of the Curta working. I controlled the calculator using the keyboard on the first version and the output was just text. But that was the basics. I had something which worked and if all else failed, this could be my HackFest entry.

CurtaSimNext, I added graphics. I used the 280×150 resolution Apple // hi-res screen. The bottom of the screen has four lines of text which I used to display the output of the calculator. The graphical display allowed you to see the settings of the dials on the Curta. I coded this between sessions or in the evenings. While waiting for another session to start, I would open up my MacBook and code a bit more. Soon enough, I had graphics working.

But the controls were still through the keyboard. I really wanted it to be fully controlled using the joystick. So, I started coding those interfaces. I could adjust the dials. I could crank the calculator. Soon enough, I only used the keyboard to signal the program to quit. Everything else was controlled using the joystick which was kind of similar to the real Curta.

CurtaSimIt still wasn’t quite enough. It didn’t make any of the grinding and clicking sounds of a real Curta doing calculations. The Apple // is actually pretty good at making grinding sounds. A bit more work and I had something approximating the sound of a Curta coming out of the speakers. I pretty much built the application I envisioned while walking back from breakfast a couple of days before.

On the final day, I sat nervously in my room waiting for the judges to come and see my entry. Before the public demonstration, the judges spent some time looking at the entrants. Once they arrived, I announced that “Lots of effort had been put into emulating the Apple // on newer platforms but I thought it was time that the Apple // emulate an older computing machine”. I gave a demo of the simulator and answered a few questions about how I coded it. They seemed impressed and I thought I did well.

CurtaSimA little while later, I had to demonstrate my simulator to all of the attendees. I was the first entrant to demonstrate and I did calculations on the real Curta and on my simulation. Then, I watched as people demonstrated their entries. There was a cool lo-res game. There were a couple of entries on the Apple /// demonstrating graphics and sound. There was a great modification to Applesoft Basic which allowed you to jump to subroutines by name instead of by line number. And many more great programs.

The winners were announced and I thought I might place. Third place when to the named subroutine utility. And second place was the lo-res game. And then they said that I had won first place! I was really taken aback. While still trying to absorb that I had won, I was asked which of several prizes I would like. I opted for a $50 gift certificate to Think Geek but I am not sure I really knew what my options were. I was still kind of shocked I had won. Since then, I used that gift certificate to pick up a couple shirts and some new puzzles like a 7x7x7 Rubik’s cube (not solved, yet).

Since then, I have published the source code to my program on github, was a guest on the Open Apple Podcast talking about my experience at KansasFest. I even wrote an article for JuicedGS about my HackFest entry. JuicedGS is the longest running Apple // publication and is still in print (I am ashamed to admit I only became a subscriber after KansasFest). I even was mentioned online in more mainstream computer news. There is an article at ComputerWorld about KansasFest and HackFest where my CurtaSim is among those featured.

Will I be going to KansasFest 2013? I sure hope so.

Tic-Tac-Toe

Tic-Tac-ToeAt work one day, I walked past my director’s desk and noticed he had an editor open and was typing some C code. That was strange (not as strange as it might be in other companies – our director definitely is capable of coding but generally doesn’t). So I asked him what he was up to.

We were looking to grow the team and he was considering asking candidates to code up an implementation of tic-tac-toe as a test. That way, we can see how they approach problems and their coding style. But he wanted to see how difficult the task was before asking anyone to do it so he was trying it out.

Intrigued, I went home that night planning to write my own. I decided to do my implementation in Perl. I didn’t want to write any code for data structures so I just wanted to use a language which had basic arrays and hashes built in. After a short time, I had an implementation which worked and would never lose. It computed all possible moves and scored them. If you weren’t careful, it would beat you. But it was pretty slow. The first move took a couple of minutes on my iMac which is a pretty fast machine.

The other feature of my implementation was that the size of the board was configurable. I decided to try a 4×4 game and it was unplayable. After a couple hours, it still hadn’t made a move.

But, that was enough of a proof of concept. At work though, others started talking about writing their own implementations. People were going to try Python, or C++ or raw C. People said they were going to make an implementation which was faster than mine and still search all possible moves. I needed to do better before I was beaten.

So, I tried again. I ported my implementation to C. And I started adding more smarts. I noticed that I could skip several board configurations. Perhaps the board is a mirror image of one I have already looked at. Or maybe a rotation of one already investigated. So, I added a cache to keep the best move given a board configuration and added code to recognize that one board state is symmetrical with another. That significantly shrunk the space of moves to search.

Then, I added “Grand Central Dispatch” support. On the Mac, this allows you to schedule tasks to multiple cores on the processor. That way, I could investigate multiple board configurations concurrently. With these changes, a 4×4 game became playable. It took my Mac a couple of minutes to make the first move but once it had pre-calculated everything, it was fast.

And as a challenge, I decided I would see if I could get the 3×3 game working well enough on some of my older machines. I have a C cross compiler for my Apple //e and my Replica One. I ripped out the “Grand Central Dispatch” code because that would never work on these old machines. I shrunk the data structures and did a bit of math in my head to see if they would fit. I needed to store enough state for all possible games on my Replica One which had 32K of memory. After a bit of optimization, I decided it would fit.

I compiled the program for the //e and the Replica One and they worked. Again, it took a couple of minutes to make the first move as it investigated all possible games but after that it was fast. And this was on a 8-bit processor running at 1MHz with as little as 32K of memory. I figured I had done enough to defend my reputation since I had a usable version working on nearly 40 year old hardware. More than that, I had a version of tic tac toe running on hardware nearly 40 years old which I assembled myself with a soldering iron. I win the title of “king of the geeks” and none shall challenge me.

And to this day, I don’t think anyone has even attempted their own implementations. If anyone does come to challenge me, I think I will learn OpenCL which will let me put the game search on the GPU in my iMac and then I can get a huge amount of parallelism. Maybe 5×5 becomes playable that way. Maybe…

Matthew Learns to Type

Matthew’s handwriting leaves something to be desired. So does mine for that matter but it was becoming a problem at school. It was slowing him down and keeping him from getting his work done. The school suggested that he could have access to a laptop so he could type some of his work instead of writing it if only he could type quickly. Matthew needed to learn to type.

My first stop was the Mac App store. I searched for a good typing tutor and started with “UltraKey”. It seemed to be well reviewed so we tried that. He worked with that for a bit but he quickly got bored. UltraKey was definitely targeting an older user and Matthew wanted something more dynamic.

So, I picked up “Typing Tournament”. This was highly graphical with little games you play by being able to press the right key in time. It was definitely a good program for him and he started improving when using it.

But after a while, it seemed like his biggest problem was the keyboard. We have a wired Apple keyboard hooked up to our iMac. The keyboard actually is very much like a laptop keyboard. The keys are very shallow and one false move and you will type the wrong key. I figured Matthew might need to practice on an easier keyboard.

I have no shortage of computers and keyboard handy and the first one I thought of was the Apple //e I have. I have an old typing tutor on a 5 1/4″ disk and I pulled it out and booted up the machine. Matthew tried typing on the Apple //e for a short time and he did seem better. But then he moved to the machine to his left and just tried that keyboard. He said he really liked that keyboard and would like to use a typing tutor on that one.

Well, that was my Replica One which is a reproduction of an Apple 1 from the mid 1970’s. As far as I knew, there never was a typing tutor written for the Apple 1. But Matthew insisted that he liked that keyboard best. What should I do?

What I did is I wrote a typing tutor for the Apple 1. I had a C compiler working for that computer so I quickly coded something in C. It starts with a menu. One item on the menu allows you to select the set of keys you want to work with. You can focus on the home row, all letters, letters and numbers or all keys. Then you can either do a typing drill or the typing game.

The drill gives you eight characters randomly from the set of keys you are working with for you to type back. You type them and it tells you how many you got right and then gives you eight more until you decide to quit and press escape.

The game just prints a random character from the set you have selected over and over again until you press it. Once you press it, it prints a new random character. The goal is to press the key as quickly as you can and get as few characters printed as possible.

Matthew used the program a few times but he gravitated back to the Typing Tournament on the Mac. I guess the simple text based output couldn’t compete with the colourful graphics in that program. But Samantha liked using my typing tutor and probably used it more than Matthew.

I posted my program online for other people with a Replica One or maybe even a real Apple 1. According to the forums, my program has been downloaded 38 times which is pretty good I think.