Bill Morefield My thoughts, discoveries, and occasional rambiings.

August 13, 2013

Managing Time Machine Backups to Windows Server Continued

Filed under: osx — Tags: , — Bill Morefield @ 10:13 am

Back in June I posted my experience getting Time Machine backups to work with a Windows Server as my main storage. It worked well, but had three problems. First I’d often get an error as it tried to connect to my server when I was away from my home network. I also had to manually mount the drive before the backups would run. Third, I sometimes found issues if I put the computer to sleep in the middle of a backup and woke it up off the home network.

To fix these issues I came up with a few scripts to address those. This first pair are designed to run when I come to my home network and consists of an Apple Script and a shell script.

I’d started these over a year ago, but never perfected them and lived with the limitations. I’d worked on them off an on, but didn’t complete them until I had to recreate my backup system around the time of that last post. The code for starting and stopping Time Machine came from http://apple.stackexchange.com/questions/11177/quicksilver-accessible-script-for-disabling-and-enabling-time-machine and the other code came from places now lost.

First the Apple Script to start Time Machine backups:

   1:  tell application "System Preferences" to activate
   2:  tell application "System Events"
   3:      tell process "System Preferences"
   4:              click menu item "Time Machine" of menu "View" of menu bar 1
   5:              tell button "ON" of window 1 to click
   6:      end tell
   7:  end tell
   8:  tell application "System Preferences" to quit
   9:   
  10:  tell Application "Finder"
  11:  Mount volume "cifs://<SERVER>/<SHARE>"
  12:  end tell

Lines 1 – 8 simply start Time Machine by in effect going into preferences and turning it on. Lines 10 – 12 then use mount the server share containing the disk image.

Next I need to mount the disk image. This is trickier than it might seem in my case as I had encrypted the image. I didn’t want to have to type the password each time since I’d already saved it in my Keychain. So I combined a script to pull the password for the disk image named MacBook-Backup.sparsebundle. This would need to change to the name of your disk image if running the script. I then pipe the output of that command to the mount command to mount the disk image. This in effects types in the password read from the Keychain to the prompt when I mount the drive. The path (here /Volumes/TimeMachine/MacBook-Backup.sparsebundle) would need to be changed if you use this script.

security find-generic-password -w -D "disk image password" -l "MacBook-Backup.sparsebundle" | hdiutil attach /Volumes/TimeMachine/MacBook-Backup.sparsebundle

Finally a script to turn off Time Machine.

   1:  tell application "System Preferences" to activate
   2:  tell application "System Events"
   3:      tell process "System Preferences"
   4:              click menu item "Time Machine" of menu "View" of menu bar 1
   5:              tell button "OFF" of window 1 to click
   6:      end tell
   7:  end tell
   8:  tell application "System Preferences" to quit

There are several ways to use these. I initially ran them manually when needed. For automation the best method I found was to use Keyboard Maestro’s ability to run scripts when a wireless network was either connected to or disconnected from. I ran the first two scripts when I connected to my home wireless network and the last when I disconnected from it. I used that process for about a week and a half and found it worked very well.

Since then though I’ve moved from the Windows Home Server to a new Synology NAS. This new NAS supports native Time Machine backups using AFS so I no longer need the disk image process I detailed here. It worked for me well over a year with only one problem and the scripts worked for about a month so I’d feel comfortable going back to them if the need arises.

July 29, 2013

Running 3.1 Miles (Or My First 5K)

Filed under: health — Tags: , , — Bill Morefield @ 9:23 am

I used to have a motto that it was pointless to run unless being chased. Thankfully I’ve rarely found myself in a position where I needed to run for safety and therefore rarely ran unless caught in the rain.

I’ve already noted the weight and exercise changes I’ve made over the last couple of years, but running is a pretty new experience. I spent most of the spring training for a backpacking trip planned for June out west. That meant lots of long hikes in hilly terrain worried about distance and not time. I did several hikes of as much as ten miles, but rarely worried about a pace greater than a steady walk.

The backpacking trip didn’t quite go as planned and now will take place in early November. Shortly before that fell apart though I had decided I needed something to work toward once I came back. I was looking at coming back in mid June with the main goal I’d held for my spring gone.

Why I decided to try running I do not know, but somehow it felt like a change of pace. Shorter distances in faster time which sort of flipped what I’d been doing. I figured given the condition I was in I could train about six weeks and have a decent result so I looked for something around the end of July and found it in the Bele Chere 5K in Asheville, NC.

Then shortly afterward June happened. The trip fell apart on me at the last minute. And shortly after I got back from it my father had an accident at work breaking his hip. Several weeks of hospital and rehab for him followed and my training time was the victim. I trained, but not as many days as I’d hoped. I got what I could in, but my goal went to simply finishing. I felt I could walk ten miles without a break still, I worried about being the last person to finish just over three.

Bele Chere was a festival held in downtown Asheville at the end of July that everyone in the city seems to either love or hate. No, the locals I know mostly either hated or ignored it. I use the past tense as it appears this year’s was the last one. I heard more love than most years this time perhaps for that reason. Interestingly I’ve been in the city the last three years during the festival, but this was my only time actually going to it.

I get downtown early. It’s early morning in Asheville and I’m walking around Pack Square park warming up mostly by just walking. My test 5K shortly before the race had been run when I was really tired and a bit under the weather, but my time had been terrible. My goal as I walk around the park next to the start and finish areas is to finish at a pace of twelve minutes per mile or a bit over 37 minutes for the race.

It’s been a cloudy morning and drizzly. The night before had scattered some rain around the city. The calls are for us to start to gather around the start/finish line. I settl toward the back of the middle of the pack figuring it’s about the right spot for me on my pace. Shortly after getting there a noticeable flash occurs in the sky. A lot of cameras have been in use, but this ain’t that. The thunder a bit later confirms this. I take a moment to enjoy the irony that coming over the speakers is AC/DC’s Thunderstruck before wondering how they handle thunderstorms.

Lightning flashes a couple more times in the ten minutes or so before the start. Only the last is close enough to be concerning, but it’s not repeated. What does follow though is a downpour of rain a couple of minutes before the 7:30 A.M. start time.

There are almost 1,200 people there at the race start. I work through the largely empty streets of downtown. I’d had the luck and foresight to wear a cap, but even before I cross the start line it, along with my pants and shirt, are soaked to the skin. It’s a cool morning for July, but the movement means I never feel chilled.

The rain last probably the first five minutes of the race. Water runs down the street and there are puddles everywhere the asphalt dips even slightly. My socks get soaked along the way and I’ve no idea if the splash that did it came from me or another running hitting a puddle.

At the same time the race feels like it takes forever, and seems over in minutes. I cross the finish line 37:03 after the starting gun putting me 941 out of 1,177 people listed on the results site this evening. My official time from start line to finish lines of 36:32 matches my own tracking pretty closely for a pace of 11:56 per mile.

I’m not happy with the time, but already see how to improve. More training of course would have helped, I had to walk an uphill section around the two mile mark that likely cost me at least a minute off my time and I lost probably another minute dealing with my shoe laces. I’d not tired them well and had to stop and retie both along the way.

So the question then is will I do it again? Probably so. I’m looking to train better now that life has gotten a bit less crazy and would like to hit something around thirty minutes for a time. When I don’t know, but I’ll probably start looking at area races toward end of August or into September. Be interesting to see what progress I can make in between.

July 9, 2013

My Simple, But Not Easy Weight Loss Plan

Filed under: health — Tags: , — Bill Morefield @ 9:12 am

When you lose over 100 pounds of weight people notice. Especially over the last few months as I’ve moved to pretty close to a normal, healthy weight. Up until a couple months ago when asked I pretty much gave the rather boring answer of “I ate less and exercised more.” That’s really true, but misses a lot of the details. Everyone know that you have to eat less and exercise more to lose weight, but most people, including myself many times, fail to do it.

So what did I do differently this time? A few months ago I wrote a bit about the process, but now let me describe a bit of the daily things I did that worked for me. These I think are the things that I did to lose weight and feel that I’ll keep it off going forward. I’m a lot of things, but not a doctor, trainer, or nutritionist or any other professional at this so take this advice as just what worked for me. I’m not trying to sell you anything, but some of the links to products below might be affiliate links, but they’re the things I’ve used myself.

Exercise feels lousy when you first start, but eventually you do start to actually enjoy it and feel better afterward. Even now though when I’d consider myself in the best shape of my life, I still often feel that nagging laziness when it comes time to work out. At some point just telling yourself to do it and doing so really is everything. I’d developed an enjoyment of hiking early in my weight loss process, partly tying into an interest in outdoor photography, and did a lot of that over the last couple of years. Late last fall I started training for my backpacking trip this summer that didn’t quite work out as planned and will now take place in the fall, but the process meant three to six mile hike much of the winter and spring. Together these meant I spent much more time outdoors and active. After getting past the initial “I hate exercise” adjustment I did also found it burned off stress nicely. I’ve had a few rather stressful periods in the last year and I found that going for a hike or getting onto the elliptical during the dreary weather days when getting outside didn’t seem a great plan worked wonders for my stress and at the same time helped me lose weight and feel better. Gradually exercise stopped always feeling like a chore or work. So I found a way to make exercise, while not always enjoyable, at least not something to dread. I always enjoyed getting outdoors for a hike, but when not I was at least able to remember that while the first few minutes on an elliptical were rough, I’d feel better at the end.

And that’s the first element, just deciding to do it and sticking to it. It’s not easy to make time, but in the end I valued it enough to do so. You don’t get more time, just allocate what you have differently. I found that audio books and podcasts worked well for me while exercising giving my mind something to focus on when on the elliptical other than somewhat dull routine. A nice pair of headphones for some of the less wild and more boring trails in the area also let me take those same things with me on hikes.

The second element really comes down to awareness. I started paying attention to how much I ate and what I ate. I paid attention to how much activity I did and what type of activity I did. When I decided to make a good final push last fall and get beyond the slow weight loss I’d seen to that point, I started tracking things. Doing this can be a nuisance, and it’s easy to get bogged down to a level where you want to give up in frustration.

I began tracking everything I ate and it’s nutritional value. For packaged foods this is simply on the label. Many larger or chain restaurants provide nutritional info on their web sites. And sometimes you just have to guess based on that you had a salad with Italian dressing and grilled fish. Doing this made me think a bit more about what I ate before I ate. It’s one thing to overindulge on cookies, but another to then look at what you ate and see the effect they had on your diet. Seeing I’d had a hamburger at lunch made me a little more likely to pick something healthier at dinner. So I became more aware of what I ate. Reading the nutritional info for restaurants was very eye opening. I was especially surprised how often the healthier looking or sounding option at a restaurant wasn’t any less caloric or more nutritious than the hamburger.

There are web sites that can do this or simply paper and pen, but I mostly used apps on my iPhone to track my food. I started with using Lose It! on my iPhone, but ended up using the app from Fitbit since it tied into the activity tracker I’ll mention in a moment. I still use Lose It! for the ability to build custom recipes for meals that I create when cooking at home and it ties into Fitbit so anything I enter in Lose It! shows in Fitbit.

For tracking my activity I started with a now discontinued Fitbit. It worked pretty well, but after a couple months I sold it on eBay and bought the newer Fitbit One Wireless Activity Plus Sleep Tracker. I loved this thing so much that when I lost mine on my trip to Arizona in early June I ordered a replacement the same day. The small size is nice in that it’s pretty discreet while being worn, but it is easily lost, especially as the case become more lose over time. I lost mine while clipped to my belt as I worked to get myself and too much luggage from the rental car center to the airport in Phoenix before returning home. I now wear it clipped in a pocket most of the time so if it does fall out it’s not lost, something I wish I’d started a bit sooner. This device tracks steps taken and floors climbed during the day. I can also monitor how well I sleep. It’s not perfect, but does give a decent determination of how many calories I burn and how active I am during the day. I found that knowing how many steps I took helped me realize what led to me being less active (see winter weekends) and adapt for them.

In December I also added in a heart rate monitor for exercise. The Fitbit does well with walking based activities such as walking, running, and hiking, but doesn’t work as well with stationary activities like weight lifting, the elliptical, and cycling. For those I found the heart rate monitor gave me a more accurate number. I ended up using a Wahoo Fitness Blue HR Heart Rate Strap for iPod/iPhone that connects to my phone using Bluetooth. I’ve tried a number of apps, but settled on the Digifit iCardio to use while indoors on the elliptical or any other inside workout. I found it less useful for outdoor exercise as the GPS seems unreliable. For tracking outdoors I use RunKeeper which tracks and maps my hikes. I also like MotionX GPS, but find it more useful for hiking than as exercise tracking. I’ve mostly use RunKeeper for anything outdoors.

None of these are perfect. That’s not a problem. I really don’t worry about getting every calorie to the exact amount or exercise to the exact calorie matters. The key is that these tools made me more aware of what I did and that seemed to be enough for me. There were days I went for a walk in the evening just to get a few more steps onto the counter before bed. There were many days I’d have a salad for lunch so I could feel better about the hamburger I’d be eating for dinner at a cookout. I tracked as close as I could and tried to keep a steady deficit between what I ate and what I burned.

June 30, 2013

A Last Word on Google Reader

Filed under: Uncategorized — Tags: , — Bill Morefield @ 2:00 pm

I’d originally planned this to be published a few days ago and to be much more comprehensive on what I chose to replace Google Reader and how I’d arrived at that decision. Simply put, life, and a failed hard drive, got in the way. So instead here’s the shorter version.

I’ve used Google Reader for a long time, first to sync, and then as my main reader, then again to sync. And I was not happy to see it go away, and so soon after the announcement, but expected that several alternatives would appear to try to fill the void. They have. More than twenty are listed on ReplaceReader, a site listing all the alternatives. Some existed before the announcement, but have either arrived or been reinvigorated afterward.

Google Reader won because it was frankly better than the alternatives when it came out. There were other services that synced news, but frankly they didn’t work as well. I know because my primary method at the time was a series of batch files that copied my sync state to and from a USB thumb drive.

From the start I planned to wait until about mid June to really begin testing alternatives. I’d play with a few before then, but I expected a couple of months would be needed for the new candidates to arrive. An early month vacation that wasn’t quite as restful as expected had me starting a bit earlier, but I really didn’t make my final choice until earlier this week.

I’m currently using NewsBlur. It was the first alternative I tried and the one I kept coming back to. Overall it feels the most polished web version at this point and the native iOS apps work well. In addition it feels the most stable and reliable as it was around before the shutdown announcement. The intelligent features for news feeds I’m still playing with, but look promising so far.

The other service I’m keeping an eye on is Feed Wrangler. It still feels just a bit too rough for me to use daily, but it might be the one that I’ll be using six months from now. The flexibility of the smart streams could be a wonderful way to manage the heavier traffic sites I follow while highlighting what I want to read.

Overall none of the programs really seem to completely replicate Google Reader. There are a lot of new programs coming out, many in just the last few days, and this is changing quickly. I expect many of them won’t be around a year from now. What I’d look for now is what works best for you and make sure you have a way to export your data so there’s a way out if your chosen service closes down in the future.

June 19, 2013

Time Machine Backups to a Windows Server in Mountain Lion

Filed under: apple,osx — Tags: , , — Bill Morefield @ 9:54 am

Since I moved to a MacBook as my laptop a couple of years ago, I’ve had one continuing problem with backups.  In my mixed Windows/mac environment I’ve used an HP MediaSmart Windows Home Server as my file storage solution for both systems and mostly that’s worked well.

At first Time Machine backups from Snow Leopard to this server worked fine as the HP server included software that allowed it to function as a native Time Machine destination.  That stopped working with the changes that Apple made to Time Machine in Lion.  HP being HP, they never updated their tools to work with Lion.  Once I upgraded to Lion I found no good alternative so I changed to the use of an external USB drive to store my backups.  I never really liked this solution since it required me to remember to plug in the drive on a regular basis. It also ran slowly at times and I didn’t like that it put part of my backups in a different place than the rest of them.

I finally found a solution that is not perfect, but is as close I’ve gotten.  Recently I had to redo this when the disk that held the backups had some issues because of a bad hard drive on my server and thought it worth documenting. It’s been more than a year since I set this up so I can’t provide the links to the blog post that got me thinking this direction so unfortunately I can’t credit them.  Still this is how to create a pretty good TimeMachine backup destination for a Lion or Mountain Lion Mac to a Windows Server.  In fact it should work with any storage that is network accessible and doesn’t natively support updated Apple’s AFP protocol.

This works by creating an Apple disk image on a server share.  This is the same concept used by VMWare and Parallels to create disk images for virtual machines.  Here though we’ll set up a disk image that we can later mount from our Apple that works as a destination for our backups.

  1. Start the Apple Disk Utility.  Easiest way is to bring up Spotlight and start typing in Disk Utility.
  2. Make sure that you do not have a drive selected and click New Image…
  3. I had problems creating the disk image directly on the external storage. When I tried creating the image on the remote storage it would never mount correctly. Instead I created the disk image on a local drive and then moved it to the server share.  This would normally be a problem since we want our disk image to be large enough for our backups and therefore want it at least as large as our hard disk.  To work around this, and save storage space until it’s needed, we’ll create a sparse bundle disk image.  This type of disk only allocates space when it’s needed.  It will run slower than a preallocated image, but I’ve found the difference isn’t noticeable.
  4. Now give the image a name.  I used MacBook-Backup for mine.  You will need this name later, so make sure it’s easy to type.
  5. Next skip ahead in the dialog and change the Image Format to sparse bundle disk image. This lets us create a disk image that will grow over time so we do not need to allocate all the space at once. It also let’s me allocate a 1 TB backup disk and still create it on the 500 GB SSD in my MacBook.
  6. You’ll want to size the image based on how much you have to backup and how long you want to be able to go back to retrieve data. Since I’d been using a 1 TB USB drive I decided to create the image the same size and found that’s worked well for me. Under the Size dropdown select Custom… to enter any size that you’d like.
  7. For format the default Mac OS Extended (Journaled) works fine so leave it.
  8. Encryption is optional.  For an actual portable disk like the USB drive I’d consider encryption a necessity.  With a network stored file the question is how much you trust the other people who may have access to your server.  If you want to be safe, 128 bit encryption works well.  I’m using it on my backup.
  9. You can create the image anywhere on your computer.  I gave it the name MacBook-Backup.sparsebundle to make it clear what it was.  Again since it’s a sparse bundle it will only initially use a small amount of disk space regardless of the size of the disk image.
  10. Once Disk Utility finishes creating the image, unmount it, and move it to your remote storage.  In my case I created a new share on my server and gave my account read/write access to that share.  I then moved the file into the share.

With the image file now on my storage, I next had to tell my Mac where this file was and to use it as the Time  Machine destination.  If you try to do this through the GUI as normal you’ll see that only external drives and AFP supporting devices (generally either a Time Capsule, Airport Base Station, or NAS with the necessary support) show.  Instead we need to use the tmutil command to tell Lion where this image file is

To do this I found the easiest approach to first mount the image to your computer.  To do this connect to your external storage where you placed the file.  In my case this was a cifs share and I mounted it using the Go -> Connect to Server… option in Finder.  Once I did this it and I entered my login credentials I could see the disk image.  To mount the image double click on it.  If you created an encrypted image you will be asked for the password.  You can choose to store the password in your keychain so you will not need to enter it each time.  Once the image is mounted, you will see it in Finder under Devices much as you would an external drive.  The name will be the image name you entered in step 4 above.

If you want to move any existing Time Machine backup you can do so.  Apple provides instructions to do this at https://support.apple.com/kb/HT5096.  In this case the disk image functions just as an external drive would.  It takes time, but allows you to keep your existing backup data.

Next start Terminal.  At the prompt enter the following command to tell Apple where our Time Machine destination will reside:

sudo tmutil setdestination /Volumes/Mounted Image

Change Mounted Image to the name of the device in Finder after you mounted it.  In my case since I gave it the name MacBook Backup in step 4, my command is:

sudo tmutil setdestination /Volumes/MacBook-Backup

Try running a backup now by going to the TimeMachine icon and select Backup Now.  Depending on how much data you have on your Mac and the speed of your network it might take a while.  If you have a lot to backup the first time doing so with a network cable instead of wireless can speed it up significantly.  If you have an existing backup it may be faster to transfer it to the new image which will allow the backup to pick up from there.

After a few days this is working well.  I’m now getting regular backups instead of only when I remember to plug in the USB drive and have the time to let the backup run.  I’ve found the backups over my wireless to be much faster than over the USB 2 in my MacBook.  I also feel more confident my backup is up to date and will cover if something happens to my laptop or hard drive.

It’s not perfect though.  Since this is for all purposes an external drive it functions much as connecting a physical drive and not as a network destination.  To kick off the backup, you must manually attach to the server and mount the drive. I’ve also found that when networks other than my home, I get errors about not being able to connect to the storage when the Mac attempts to start the backup. I’ve generally just ignored these since there seems to be no problem other than the error message.

June 13, 2013

Thoughts on iOS 7

Filed under: ios,iPhone — Tags: — Bill Morefield @ 6:05 pm

Earlier this week Apple demonstrated the new version of iOS 7. I watched part of the keynote live and the rest while travelling later in the week. So what I’m putting here is based just on that along with what I’ve seen and read publically and not actually using the beta myself. I do have a test device for that, but won’t be doing that until home later this week. Also since I’ve been on vacation and not following the news out of WWDC in depth I might have missed something and will update/correct this as needed. These are what stood out when watching the keynote and reading a few online items off that.

What I liked

The overall look. I’m odd in that I like Windows 8 overall. And iOS 7 really reminds me of Windows 8. It’s not a clone or copy, but it’s inspired by the same design principles that inspired that system. And I like it. The icons aren’t all perfect, but this is a beta and I wouldn’t be surprised to see them polished a bit before the final release. I do think the overall look answers the concerns about the outdated look to the interface, but of course actually using it will do much to see how well it works.

The control center is a great feature and one that excites me from an ease of use view. The toggles for things like Wi-Fi and flight mode are great when travelling. My recent vacation reminded me how long it takes to hop into settings and turn on airplane mode when getting ready to get onto a plane or when going somewhere with little or no cell reception that drains the battery so fast you can almost watch it count down. I do hope that those quick access links at the bottom can be customized, but I doubt it given’s Apple’s past track record.

Better multitasking is finally here too. This was the one of my two biggest hopes that were addressed. Don’t underestimate the ability to start and app and not have to wait for it to update. Compare bringing up a mail app to say bringing up a news reader where it takes a minute to update before you’re done. Background runs are a great feature, and I expect Apple’s implementation will mitigate battery concerns.

Activation lock is a big deal. Working for a company that deals with nearly 1,000 iPads anything to reduce theft makes a big impact. And personally I like the idea that if I lose my iPhone or it’s stolen then it might not be useful to the finder and means I’m more likely to get it back.

Notification Sync. No more clearing the same notification from multiple devices.

I can finally put as many icons in a folder as I want. No more adding numbers to the end of a folder name or jailbreaking for this purpose.

What I’m Not As Excited About

I think that a lot of these features seem interesting, but not there yet or just won’t work for me. I love the idea of a browser integrating secure passwords into the browser, but I’m not sure I feel a lot of trust to iCloud for it at this point. And for me the iCloud, and therefore Apple only, nature of this solution makes it a non-starter for me. I’ll stick with RoboForm, though if I was a developer of a password app I’d be looking into iCloud integration if that’s possible.

AirDrop looks nice, but the rather limited selection of devices it will work on I think means it will be of limited use until older devices cycle out of common use. I know a lot of people still running iPhone 4’s.

The radio service really doesn’t show me anything that would move me from a program I was currently using. I think Pandora might be in the most trouble since it seems the closest to what Apple produced. I’ll play with it, but don’t see it moving me from Slacker. Again the Apple device only likely makes it a non starter for me.

What Disappoints Me

Still doesn’t look like any good inter-application communication. I still have to hope every developer integrates use for the systems I want. My photo site of choice is 500px and I’d love if they could write a 500px share target and then I could send a photo to it from any app. I’ve hoped for this for a while and really though that it might show up this year. I still think we’ll see this feature, but really wonder how much longer Apple can put this off?

Last Thought

There are always software products that look in trouble after the new version appears. This year thought I think the biggest might be the jailbreak community. Each jailbreak version seems to take longer than the last and I’ve noticed each time I’ve missed the jailbreak a little less. A lot of the things I’ve turned to jailbreak apps for now look built in. I’m not sure at this point I’ll be that worried about jail breaking when 7 comes out which will be a first.

April 15, 2013

A Goal Reached

Filed under: health — Tags: , — Bill Morefield @ 2:04 pm

On the morning of April 3, 2013, I stepped onto the scale and it read 189.5. The number may not seem that special on a glance, but to me it’s a big milestone. It marks the conclusion of more than two years of work to drop over 100 pounds. To put the change into a bit more into context in 2010 I wore an extra large shirt and forty four inch waist pants that sometimes felt snug. Today I wear either a a medium shirt or small shirt depending on the type and maker and pants with a thirty four inch waist. That’s a drop of three or so shirt sizes and ten inches off my waist. So forgive me a bit to indulge in a bit of a story of getting from there to here. I’ll have another post in a few days more on what I did so think of this more as the overview.

The highest weight I ever saw on a scale came in late 2010 when I weighed in at 290 pounds. While that was the one measured weight, it probably moved 290 and 300 pounds for much of the late summer and early fall of 2010. There wasn’t any kind of epiphany that day. I never really recall a single moment of “I need to lose weight.” If anything it was just the slow realization that I didn’t like being this heavy. At some level maybe that 300 number I knew I’d reach anytime in my current path started the pressure.

As December arrived I started exercising. Nothing outstanding or grand. Some days I walked, but being winter I I mostly used my elliptical. If I remember right my first exercise session lasted about ten minutes and I felt exhausted. I wanted to avoid gaining weight over the holidays and as I got past Christmas I’d succeeded and still hadn’t hit that 300 pound mark. In January I moved to exercising two or three days a week on an elliptical for about twenty minutes at a time. I didn’t really diet, but became a bit more aware of what I ate. Not cutting out anything, but ordering the small instead of the large when eating out.

And it worked. I don’t remember the exact amount, but maybe ten or fifteen pounds as spring 2011 got here. Whatever the amount a few acquaintances and friends commented on it. That was I think the shift, that I’d not only been able to lose weight, but enough to be noticed by others. Don’t underestimate that feedback that came in being a motivation to keep going.

Another incentive with spring coming came from an interest in getting outdoors more for hiking and photography I’d developed the year before. I wanted to be better able to take those hikes without spending as much time resting and recovering as I’d done before. From that first time on the elliptical when ten minutes at a slow pace left me exhausted I could now do thirty minutes at a decent speed. And while I felt tired afterward, I was no longer exhausted. Walking up several flights of stairs into work still left me winded, but not as much as before. I noticed the changes. They were subtle even after a few months, but I had changed.

I again looked at my food intake. I didn’t go onto a real diet and I didn’t stop eating what I wanted. I just ate a little less of it. I’d have a salad on occasion for lunch. I paid attention to portions trying to east smaller ones. No more large fries with lunch and now I’d have one hot dog instead of two or the regular burger and not the double. Not much, but the small things will add up over time. The weight came on over years and it wouldn’t go away overnight. By the end of the summer of 2011 I’d dropped down to about 250 pounds. I exercised pretty regularly now, usually five days a week. The only stretch of any length I missed was after tweaking my back helping a friend move furniture and taking most of a week off to let it heal.

I hit a wall a bit there. I made it to around 245 as September moved to October and really didn’t move much over the rest of 2011. When 2012 began I’d gotten to about 240 pounds. It seemed I’d lost more fat than weight. My health was undeniably better and I had better endurance and strength than probably since I’d been in college. Still I just couldn’t get the weight to budge more. I finally figured out the months of futility came to medicine I took, but whose dosage hadn’t been adjusted for the weight loss. Once I made that change and over the next few months I got my weight down through 230 and to near 225. Then I kind of took the summer of 2012 off a bit and just worked to maintain weight.

By the time I got to fall I was ready for a more serious effort. I wanted rid of the extra weight and back to a normal rate. I was ready to focus and do the work to get there at a faster pace. I set the goal to reach 200 pounds by January 1, 2013.

As September began I started tracking my activity, everything I ate, and my weight daily. Before I’d weighed more sporadically, often just when I remembered to. There are cons to weighing everyday, but overall I think it worked well for me in this case. In September I weighted in at 227. I started a steady drop keeping to a target of dropping a bit over 1.5 pounds per week with the goal of weighing in at 200 pounds on January 1. In the end I missed it by only a few days. I continued the drop through January and took another short break through February. I’m now under the 190 mark that always felt like a big goal to me of getting to 100 pounds below my peak.

I’m not done yet as I have a bit more weight to go. My next target is to get to around 180 and I think I’ll be pretty close to a good weight for me once I get there. In addition to the weight I’d really say the bigger change came in my overall health. I’m probably in better shape now than I’d ever been. I can walk up flights of stairs while having a conversation. I regularly do four mile hikes and while tired, feel quite good after them.

January 15, 2013

Arbitrary Sorting Order in Linq To SQL

Filed under: c#,development — Tags: , , — Bill Morefield @ 3:22 pm

I ran into a situation recently that took me some time to work out and thought I’d document here. I have an older ASP.NET Web Forms application I help maintain. Some upgrades and changes to the workflow used by the customer had meant a few assumptions I’d made no longer applied.

The biggest of these was that a list of values no longer returned from the database the way I’d assumed before. Here is the Linq to Sql that pulled the values to that point.

   1:  var plans = from m in dc.MenuPlans
   2:              where m.client == CurrentClient && m.year == year &&
   3:                  m.month == month && m.day == day
   4:              select m;

As you might guess from this code, it pulls a set of menu plans from a database for a client. Each menu plan is specific to a day. What you can’t see here is that each meal has a meal name that is simply “Breakfast”, “Lunch”, “Dinner”, or “Snack”. Before the meals had been entered in that order and the creation method ensured they showed up in the order being entered.

Now they were being entered in a different order by multiple people and the order of creation no longer worked. The desired order was still breakfast, lunch, dinner, and then snack at the end. Sorting simply by the column wouldn’t work as that would produce an alphabetical order resulting in breakfast, dinner, lunch, and then snack. Close, but not quite.

What I needed was a custom ordering sequence. I could pull the items over in four groups and then append them to a final list, but that seemed messy and slow. I wanted a solution to do so at the database and not have to bring the elements in and sort in memory. I finally worked out a nice solution with this code.

   1:  var plans = from m in dc.MenuPlans
   2:              where m.client == CurrentClient && m.year == year &&
   3:                 m.month == month && m.day == day
   4:              orderby m.mealname == "Breakfast" ? 1 :
   5:                 m.mealname == "Lunch" ? 2 :
   6:                 m.mealname == "Dinner" ? 3 : 4
   7:              select m;

The new code lies on lines 4-6. What I do is compare the element that I want to sort by to the values in the order I wish things to show. I’m using the binary operator here. If you’re not familiar with it, this works like a compact if/then statement. The binary operator:

   1:  return x > 0 ? 0 : 1

Is equivalent to the following if/then statement.

   1:  if(x > 0)
   2:     return 0;
   3:  else
   4:     return 1

So the code lets me map the string values to numeric values arbitrarily. Breakfast maps to 1, Lunch maps to 2, Dinner maps to 3, and any other value to 4. Since the result of this is a set of integers, the ordering works the way I want.

While the code looks a bit messy, it translates nicely to SQL that runs on the database server through a CASE statement and I get the order I want without any extra processing in the web application.

October 1, 2012

Apple Maps and What’s the Problem

Filed under: iPhone — Tags: , , , — Bill Morefield @ 10:09 pm

Every iPhone release seems to bring some kind of debacle varying from real to merely a search for clicks on the web by writers. The commentary usually starts with the normal “Apple is finally losing it” to “Apple can do no wrong” and then somewhat sane reality comes in. The iOS maps debacle, which is an iOS issue and not an iPhone issue, looks to be the most valid and worst of them. I’ve followed this one with some interest as I’ve planned to upgrade to the new iPhone.

The issue was driven home a bit to me over the weekend. I was in the northern part of the Cumberland Plateau in Middle Tennessee Sunday looking for two places. One was a place that I’d last visited in my college days and the other one I’d only read about. Along with me were some directions and notes. Neither was a spot you could just plug into a GPS and get directions which admittedly is my normal way of getting somewhere now.

The first spot I found with no problems between good directions and vague memories. It was in fact a more lovely location than I remembered. The second I never found though I drove within a few miles of it. The reason, my directions left out a single turn, a short trip of less than a quarter mile, that meant I never saw the road I was searching for. As a result eventually we gave up and had to abandon the quest for another day.

While driving back home I thought back to when several years ago I learned that at least one major GPS had a mistake on the addresses on the street where I live. The street is a circle, a short loop of about thirty homes. That brand of GPS, or more exactly the map provider they used, had the addresses backwards so that if you followed them you’d likely end up exactly on the opposite side of the circle from where you actually meant to go.

In the daytime this was a  minor issue since the address numbers on the home would tell you that you were in the wrong spot. At night where these numbers were invisible, it wasn’t so clear. More than once someone I’d provided directions to my house wound up knocking on the wrong door or realizing something didn’t look right and calling me while from the street. It’s how I learned there was a problem and for a while I always added the warning when someone visited the first time.

Both of these had the same basic issue. Bad data. The GPS data was beyond my control and I did the only thing I could do, warn visitors not to trust the address on their GPS. The never found place on Sunday was my largely my fault. I could have checked or verified the directions before I left or at least checked a map well enough to have realized something was off in time to get to the right spot. In both cases though the data I had failed me.

The first time I remember using a computer map system to find directions to a place I’d not visited before it told me to use a bridge that no longer existed to cross a river. On a trip in Kentucky a couple years ago a road under construction and not in my GPS caused it so much confusion my GPS actually crashed and had to be restarted. A construction project I drive through several times almost every day has shifted the entrance and exit patterns to a shopping center, college, and mall several times in less than a year and will do so several more before being complete where the pattern will be completely unrelated to the original one.

And that’s the problem Apple is facing with maps. Map data is often inaccurate. Even good data is often behind. It’s so much easier to travel now with GPS data and maps available on demand on your phone. I’ve learned the art of interpreting the GPS, trusting it enough to get me there, but also expecting it to be wrong at times and using common sense.

The bigger issue is that the overall accuracy of the data doesn’t matter. What matters is how the data is where I want to go. All I know is that one of the two sets of directions I used Sunday was wrong. It doesn’t matter if every other one on the site is perfect, I’ll remember the one that was wrong and never trust them the same way again. Right now that’s what people think about Apple’s maps

It doesn’t really matter where it might be wrong because it will always be a little wrong somewhere and each time I or someone I know gets wrong directions that will be reinforced. I’ll probably take a long time before I trust Apple’s maps to get me there which might be the biggest problem they face now. Apple has to make maps that work not as well as Google, but better and for long enough that everyone forgets how bad a start they got off to.

September 20, 2012

Recent Articles

Filed under: article — Tags: , , — Bill Morefield @ 9:31 pm

Here’s a few articles that I’ve recently had published:

« Newer PostsOlder Posts »

Powered by WordPress