Archive

Archive for October, 2006

Proof of my lack of brilliance

October 27th, 2006 joelhainley 2 comments

I’ve been reading through Structure And Interpretation Of Computer Programs in the evenings, and have started going through the exercises as well. I figure it’ll help bring home the finer points of the text, and it’s sorta like little puzzles to work on, plus i’m learning scheme, and since I have a well documented affection for lisp it works out well.

One of the first exercises that they recommended was given three numbers square the sums of the two greater numbers. Pretty straight-forward right? Yea..pretty much. I implemented the usual if (and (> a b) (> b c)) then A is the biggest number. Pretty easy to find the largest and smallest numbers with that approach. However, start coding up for the middle number and you end up with this mess of unreadable garbage, well not unreadable but you end up wishing there was something elegant you could like the above statements.

After a bit of thought I hit upon it it goes something like this (- (+ a b c) (+ (get-max-num(a b c)) (get-min-num(a b c))) which works out rather well because the both the max and min of three numbers are very easy found using just a couple of lines of code. This is obvious when you think about it, but when you’re coming from a bunch of >, <, and, cond statements it’s not the thing you would consider at first..i guess…well i didn’t.

I mentioned this to shad and his response was something along the lines of “duh, obviously b = (a + b + c) – (a + c) it’s algebra”. This response further reinforces the theory that i’m in over my head most of the time.

Categories: programming, scheme Tags:

Unit Testing….NUnit, PHPUnit, Smarty..and stuff

October 17th, 2006 joelhainley No comments

My personal project has been coming along quite nicely recently, I have been retooling my PHP framework to be able to utilize the Smarty templating engine and it has been going really well. I rewrite several pages using smarty and i am terribly enthused about how clean things have become. My framework went to great efforts to keep things as clean as possible but this makes the whole system significantly cleaner. Very VERY nice.

I have also been spending some time fiddling around with unit testing in both php and .net using PHPUnit and NUnit respectively.

In the .NET project i’ve been working on I started writing unit tests alongside the creation of the application. This has already saved me quite a bit of time in terms of changes in various objects/classes breaking things in unexpected ways. I am almost sold on the whole concept, my initial thoughts around this were that the unit tests would be instructive for the initial development but their benefits would not be realized until the client requested new features to be implemented, at this point I could make the changes and then ensure that the application had been broken because of these changes. However, there have been many times that I have found the unit tests very useful during development, whether it is catching coding errors, or providing a convenient way to run a bit of code and see how it behaves.
This has carried over to the personal project and efforts to get PHPUnit setup and tests written for all of my business objects. Work is going a little slower on this mostly due to challenges I had with Centos but I have done a few small tests and everything seems to be in working order. I am probably going to write tests for all of the new classes, and then build the tests for the existing objects when I touch them.

One thing that has worked extremely well for me is to start each session off by writing a couple of unit tests, or going through the testing code and seeing if there’s any way I can test something better. It helps get me into the groove of writing code, and gets my head in the project, but it doesn’t just dump me right into the middle of the business logic. I can sorta ease my way into it. Write a test..did it pass? Cool..or damn! why not?. I’m a big believer in inertia when it comes to development, you’ve gotta crank through a few things, get the mind, and fingers, warmed up then start to tackle some of the bigger things.

Categories: programming Tags:

Foxys Fall Classic

October 16th, 2006 joelhainley 2 comments

I did it. Davis Bike Club was putting on a century yesterday. They call it the “Foxy’s Fall Classic”. It was a mostly flat route, with one hill of any note on the ride. This was on hwy 128 ( or maybe hwy 129 ) between Lake Berryessa and Winters. It was really damned cold though, riding through Wooden Valley there was a layer of fog, and the only time I was warm on the whole ride was when I was climbing the hill going towards winters.

Overall the ride was a huge success, I have a bit of knee pain today, mostl because when it’s cold it’s hard to keep the body limber during rest stops, the rest stops on the route were easily the longest i’ve stopped on my over 50 mile rides. As a result of this i kept having to get _re_warmed up. Well during one of these I probably pushed a little hard right out of the rest stop. There was a hill and it was warmer than it had been, and people kept getting in the way, so I attacked the hill, probably wasn’t the best idea. I think things will be fine in a few days, then I can get back to commuting.

I think that’s it for centuries this year, there’s a ride in Solvang that might be a good ride in November, but that falls among some important birthdays so I probably won’t commit to anything. So if nothing else comes up maybe I’ll do the Century in Death Valley in February, that could be a lot of fun 8-).

Ride distance for yesterday : 106.77 miles

Ride Time for yesterday : 7hrs17minutes.

NEXT!

Categories: bicycle Tags:

Simplicity wins…

October 12th, 2006 joelhainley No comments

I’ve decided to start keeping a journal. Not this blog, but an honest to goodness journal, something for me only. A chance to get out all of the things that I want to say but don’t to burden people with listening to. Sometime I’ll talk about why i decided to start a journal, and a few other things i’ve been considering doing. For now, I just want to talk about what software I ended up using for journaling.

I looked around a little at various software packages that were available for journaling. I specifically didn’t want to just use a big text file, because getting to a specific day would be a pain. I didn’t want something that worked on windows only. I use windows for a few minor things, but tend to prefer OS-X/Linux for my personal stuff. I wanted an interface that is mostly the same across the various systems, something that would allow me to easily move the journal around and keep it synced up among my various environments.

What i ended up with was……………ascii text files. 1 file for each entry. Broken out into year and month sub folders, but with the full date in the filename, edited with emacs, and stored in subversion. Pretty simple eh? Yeah i thought so, i’d even spent 10 minutes considering writing my own software till i realized that it was rather a silly thing to write software for.

With this setup it should be relatively straightforward to write a script to create a book form of this data for printing out if the urge ever hits me. Hopefully someone will do me the favor of running rm -rf journal when expire so that noone ever reads the journal. ;-)

Another area where simplicity won was in my bookkeeping, i tried Quicken, I tried Money, I now use one of those composition books they sell at staples to do my books. I have a spreadsheet that mirrors this mostly so i can pull out some numbers at the end of the year. Both Quicken/Money seem to manage your money at the end of the month, or when bills show up in your bank account. I don’t find this particularly useful. It’s much better to write down what you spent every day, that way when you get a bill you know it’s accounted for. The simplest way to do this for me has been just a composition book with a few columns drawn in with a ruler, and a few minutes every evening/morning.

Simplicity..wins.

Categories: life Tags:

Around the lake…..

October 10th, 2006 joelhainley 2 comments

I went up to Lake Tahoe this weekend, with my bicycle in tow. Arrived saturday afternoon, with the beginnings of a cold setting in. Got some food, walked around a bit, then went to bed.

I woke up around 8:30am Sunday morning, my birthday, ate some breakfast, then suited up and hit the road. I’d been training for this ride for the last few months, and even though i had this nagging cold i was gonna give it my best shot. I wasn’t worried about the mileage ( 72 miles ) as much as I was worried about the altitude, and the cold bug I had picked up.

The temperature was rather low so I wore a flannel over my cycling jersey as I pedaled west out of South Lake Tahoe, CA, for a clockwise trek around the lake. I hit Emerald Bay about an hour later, and was up and over that in no time. I had a few more hills to deal with and was afraid to really push hard on the hills because I wasn’t sure what was coming, and i was still leery about the oxygen and the headcold.

After the second hour i started to feel pretty warmed up and ready to start pushing, I was averaging around 17mph through the flat areas heading into Tahoe City then hit some hills and decided to start pushing a bit. Nothing broke. So I kept at it, and was hovering around 3 hours at the 40 mile mark when Amy caught up with me.

A quick refuel, some discussion about logistics and she was off again and so was I. I found the hills I had forgotten about from the ride 23 years earlier. The climb from North Shore to hwy 50 isn’t steep but it’s a LONG sumbitch, this was the part of the ride that was nearly my undoing when I was 10 years old. I just grabbed a comfortable gear and pedaled. Not trying to break any records, just pedal.

I caught up with Amy around 55 miles into the ride, and told her to just head back into town I wouldn’t need any more refuels for the rest of the ride and she could get tickets for the comedy show that night. Quick refuel, pedal pedal pedal…

I remember thinking that the few completely flat training rides i took were good preparation for these hills, because they weren’t especially hard, but required constant pedaling. You can’t coast in these situations, just keep pedaling, it’ll be over eventually.

So I hit hwy 50 and was coasting down the road at about 40mph with no cars really passing me or anything, nothing really crazy to report about the rest of the ride. I hit some hills that required me to work a little, and hit stateline passing traffic like it was standing still ( it was ). Rolled up to the hotel room with a total riding time of 5hrs 27minutes.

I’m pretty happy with my performance, I hadn’t intended to be doing this type of riding again when I bought this bike, but it’s just sorta happened. I like to think I started riding longer distances on the weekends to make the commutes to work easier, but I think there’s a large element of enjoying riding. I’d like to try some longer distance riding at some point. Who knows, maybe next year i’ll ride to Tahoe, then ride around the lake. That could be fun.

Categories: bicycle Tags: