Thursday, April 27, 2017

Don't Give Up

We all have those days. As soon as you arrive at work, you wonder if it is time to go home yet. Days like that remind me of Tuesday Jan 14, 2014.

It was one week before I would arrive at the South Pole. I had got into the routine of taking Sundays as rest days. Every day I was putting in 13+ hours a day of intense work. So it got to the point that I looked forward to Sunday more than a little kid looks forward to Christmas.

On Sunday the 12th I took a nice rest from the weeks work. Then on Tuesday I got another bad whiteout. There was a lot of new soft snow. I could not see where I was going. I had been biking across Antarctica for almost two months, and I had gotten good at just accepting the conditions and continuing on in much worse conditions than this. But this day broke me. After a couple of hours of whiteout conditions I just quit. I wanted it to be Sunday so bad, but it was only Tuesday!

What is the point? I don't know, but yeah Xamarin studio has been getting worse and worse with each new update, and today I just didn't want to deal with it anymore. Oh well, back to work!

Thursday, March 16, 2017

When we were kids we used to like digging big holes in the orchard. The joke was that if you dug deep enough you would come out in China. Of course we never thought we could dig all the way to China. Besides this was during the Cold War so we knew that Americans were not allowed to go to China.

Calvin had his Hobbes, and my son Stephan had Top. Top was a stuffed penguin I bought as a gift for my wife, but when Stephan was just a baby he decided Top was his. Stephan loved Top and thus all penguins. The Pittsburgh Penguins became his favorite sports team.

For some reason my kid’s schools thought the kids should decide what their career will be before they were even teenagers. Stephan was a smart kid and it seemed very likely he could become a scientist. So I pondered the idea of him becoming some kind of researcher going to Antarctica to study penguins. He however went a different direction. Stephan will be getting his PhD in mathematics this spring.

My father was a scientist and was invited to go on a sabbatical to Antarctica with Dr. Wolf Vishniac to do research on detecting life on Mars. However he decided to go on a sabbatical to New England instead.

So the point of all this, I never dreamt of going to Antarctica. It was something someone else might do, but wasn't something I considered doing myself. Fat bikes and the amazing Eric Larsen changes that.

I also never thought I would go to China. My South Pole expedition has changed that also. I have been invited to go to Shanghai to help someone plan for his Antarctic expedition. So I'll see if I can figure out how to add some blog posts while I'm there.

Hmmm, before Antarctica visiting all the continents was not on my list, after China I will only have two more to go.

Thursday, September 01, 2016

Why do you think I want this boat

I love Joe vs the Volcano. It is one of my all time favorite movies. I think the part on the boat expresses a lot of what I like.
J: Are you used to this?
P: What?
J: The ocean, the stars.
P: You never get used to it.  Why do you think I want this boat? All I want to do is sail away.
J: Where would you go
P: Away from the things of man.
...
J:  up till now I've lived on a tiny island called Staten Island, and I've commuted to a job in a shut up room with pumped in air, no sunshine, despicable people, and now that I've got some distance from that situation, that seems pretty unbelievable. Your life seems unbelievable to me.  All this like life, seems unbelievable to me.

I'm in Barcelona. This is about as close to the boat as I have been so far.

Friday, June 17, 2016

Biking to Work is Dangerous

I think biking to work is dangerous, but not for the reasons that just popped into your head.

I was a bit lazy this morning and took a little longer to do those things I do every morning before going to work, like feeding the chickens and the raven (yes. I have a friendly raven). So, after finally getting going on the bike you would think I would choose the fastest, easiest way to get to work to make up for leaving late, but no. You see, it was a perfect morning, cool temperatures, a blue sky, and no wind. So of course I decided to take the river route to work.

Of course I started Strava before heading out, but I'm not a typical Strava user. I really don't care about KOM, PR, or other achievements, sometimes I just like to keep a record of my rides. And like I said, I was feeling lazy this morning so I was just riding and enjoying being out on the bike, and that is where the danger comes in.

I started when my son was in scouts, well that is probably not true as there is no real beginning, but it works for this story. So, it started when my son was in scouts and they were getting ready to do a White Rim biking trip, and I volunteered to go along.


The next year I went on a trip with the scouts doing the Kokopelli trail. The White Rim and the Kokopelli were great multi day trips, but somehow I jumped from that to biking across Antarctica to the South Pole, and that was followed by a couple of bike tours, one from Utah to Oregon, and a second one going down the Oregon coast.


And that is the real danger of biking to work. I start by thinking how nice it would be to just skip going to work and spend the day out on the bike. Then the idea that it would be awesome to just forget everything else and go on a bike tour with no real destination, just each day ride to somewhere new.

Now that wouldn't be so bad, but this leads to fantasies of selling everything and buying a yacht and heading out on an around the world cruise. I imagine starting in California and sailing south along the coast of South America and through the straits of Magellan, and of course stopping in Punta Arenas to visit my friends there. Then continuing up the Atlantic coast to the Caribbean, the Bahamas, maybe up to Greenland, Iceland, Scandinavia, England, through the strait of Gibraltar and into the Mediterranean. Africa scares me, but still I would have to stop somewhere in Africa just to make sure that I get all seven continents marked off the bucket list. (I'm not a bucket list kind of guy, but since I have been to Antarctica now I feel the obligation to visit Africa, Asia, and Australia).

So somewhere I'd visit Africa, and then through the Suez Canal and into the Indian Ocean, India, Indonesia and down to Australia, up along China, Japan Russia and over to Alaska, and back down to the start.

The thing is I have already proven that I am likely to do crazy trips, and so that is why biking to work is dangerous.

Hmm, I think I need to go read Call of the Wild.

Saturday, May 21, 2016

Serving Pages and Mustache with Perfect

Ryan Collins has some great videos on how to use Perfect  to serve web pages and how to use Mustache. These were great for helping me get things going, but I prefer a written format to video, so I am going to repeat a bit of what Ryan has done. Chris Manahan has a good writes up on getting a Perfect project running on how to use MySQL with Perfect so I won't repeat that.

So here we go:

My previous blog post shows how I created classes to serve my MySQL tables as JSON. Here is my
PerfectServerModuleInit Where I  add one route to return JSON from my auto_make table.

public func PerfectServerModuleInit() {
    Routing.Handler.registerGlobally() 
   
    // Create Routes
    Routing.Routes["/auto_make"] = { _ in return AutoMakeRecord() }
}


I'm creating a web service for my app, but I also want to have a web interface that allows me to administer content for the app. So I need to serve some static pages like my stylesheet to give the look and feel of my service and then of course some dynamic pages.

To get static pages I add a route and connect it to the StaticFileHandler that is part of the PerfectLib.

public func PerfectServerModuleInit() {
    Routing.Handler.registerGlobally() 
   
    // Create Routes
    Routing.Routes["/*"] = { _ in return StaticFileHandler() }
    Routing.Routes["/auto_make"] = { _ in return AutoMakeRecord() }
}

Now I need to have a file in the webroot. So in my Xcode project I create a group called webroot and add my .css file and background image:



This is great, but to get the server to find these files we need to have them copied into the webroot in the Products Directory. So I select my CarHealthServer project and the Build Phase. Then click on the "+" and add a "New Copy Files Phase"



Then I will click on the "+" in the copy files phase and add the files that are in my webroot group. Here I have added a couple of extra files, a vehicles.html and a shop messages.mustache. I'll talk about the .mustache file later.


So now when we run our server and go to http://localhost:8181/BackView.css in my browser I get the contents of my .css file.

I want a page that will let me create an html document that will get saved in a MySQL table. So I create a file call shopmessage.mustache:

(Sorry blogger is having problems with this, and I am feeling lazy so you get a picture or this file)
   

The important things here are "{{% handler:ShopMessageHandler}}" which specifies the class that will handle the dynamic content for the mustache file, and "{{doc}}" which is supplied by the handler. Here is my ShopMessageHandler.swift class:

import PerfectLib

class ShopMessageHandler: PageHandler {

    func valuesForResponse(context: MustacheEvaluationContext, collector: MustacheEvaluationOutputCollector) throws -> MustacheEvaluationContext.MapType {
    
        var values = MustacheEvaluationContext.MapType()
        
        values["doc"] = "my shop message" 
        return values
    }
    
}

Now I need to modify the  PerfectServerModuleInit to register the ShopMessageHandler.

public func PerfectServerModuleInit() {
    
    PageHandlerRegistry.addPageHandler("ShopMessageHandler") { (r: WebResponse) -> PageHandler in return ShopMessageHandler() }
    
    Routing.Handler.registerGlobally()
    
    // Create Routes
    Routing.Routes["/*"] = { _ in return StaticFileHandler() }
    Routing.Routes["auto_make"] = { _ in return AutoMakeRecord() }
}

In the valuesForRespose I create a dictionary of the values to be used in the .mustache file. In this case there is just one value and it is hard coded to a static string. But this now gives me the framework to develop my service.

Now when I go to http://localhost:8181/shopmessage.mustache I get this:


My Bicycle Store