Posts

Slow going on coding project

I've embraced Ruby for my coding project. Ruby has been great: I really like it's object-oriented nature: it's inherently object-oriented, with that built in to the core of the language, rather than some sort of kludge built onto what is essentially a sequential language. Actually, I'm not sure whether "object" versus "sequential" is correct, here, since Ruby is still highly sequential, it just heavily uses objects. You can still write Ruby code which looks much like Perl code, with notable exceptions. But I don't want to write Ruby code which looks Perlish. I want it to look Rubyish. So therein is what makes for slow going: I write stuff, check it, re-read the on-line documentation to make sure I'm not reinventing any wheels (there are a lot of standard methods in Ruby), make adjustments, run, and track down the inevitable bugs. Slow going, but it's what it takes to build aptitude in a language. So my end-of-Feb deadline for t...

SB1464: revised 3-foot passing bill for California

Image
Last year California's Governor Jerry Brown pocketed SB910 , a bill which would have effectively banned drivers from passing cyclists with less than a 3-foot margin. Additionally it would have allowed drivers to cross the center-line when it was safe to do so in order to provide for that mandatory margin, which is a practice well over 99% of the drivers already exercise, anyway. His logic in pocketing the bill seemed inconsistent with the bill itself, as I described , bringing into question whether politics and influence was the actual motive. So another year brings another legislative session, and the California Bike Coalition continues, to its substantial credit, to push the matter. The Give Me Three campaign is not dead, not at all. Instead, SB910 has been replaced with SB1464 . This bill is a direct response to Brown's concern, in his own words: On streets with a speed limit of 35 or 45 mph, slowing to 15 mph to pass a cyclist could cause rear-end collisions. On t...

Strava lament

My KOM up Dyer's Pass on the South Island of New Zealand was crushed "yesterday"... I put "yesterday" in quotes because it's hard to figure out precisely what it means that many time zones away, especially with the date line: The horror... the horror... With my light bike, with fresher legs, with a better warm-up, I know I could have gone faster. But a full minute faster? Or rather -- 61 seconds faster? That's the way Strava is. With exponentially increasing user base, records don't usually last long. In the San Francisco Bay area, things are hitting the linear growth regime, but elsewhere, the market penetration is still much smaller. Every week, more people are going to be posting rides, more climbs are going to be ridden hard, and KOMs come and all-to-quickly go. I'd love to go back -- it was a great trip, and I miss the great riding there, even if I am appreciating with renewed freshness the riding here in the San Francisco area ...

Ruby SmoothData class: now static-free

Last time I posted what I called a "SmoothData" class for Ruby. But even as I was hitting "publish" on Blogger I realized I wasn't being honest. There wasn't much "class" about it: it was a single static method which was similar to what one would write for any sequential procedural language. Indeed, since it was essentially ported from Perl, this shouldn't be a surprise. Initially my attitude was "this function doesn't need to preserve any local state. There doesn't need to be multiple instances of it. It's just an algorithm an nothing more. Why make life too complicated just for a dogmatic adherence to the object oriented cult?" But then I tried to use it and I realized... hmm... maybe I should reconsider. The plan was to, for various measured Strava parameters (altitude, speed, power) to have both measured values and smoothed values. So, for example, for altitude, I'd have an altitude array and a smoothed al...

SmoothData : a simple Ruby data smoothing class

Ruby self-teach continues, so I put together a data smoothing class for Ruby. Nothing new here: another in a series of codes I've used for comparing Java to Perl to Ruby. Data smoothing is an important part of anything I do with cycling data. So this is a critical component for me on any sort of project I might want to accomplish. For example, suppose I wanted to write a code to identify and rate climbs in an activity. I know -- Strava already does this, but I've got my own ideas about algorithms. Well, if I were to take altitude data raw, a small glitch yielding a 50% grade between two closely-spaced points might generate a huge spike in the climb rating for just those two points. Instead it would be important to smooth the altitude out, for example with a 50 meter characteristic smoothing distance. 50 meters is a fairly good number on climbs this length and shorter you can generally use momentum to blunt the blow. It also covers up small errors in position and altitu...

StravaToCSV : It's Ruby's turn

StravaToCSV has become my "test app" for various programming languages ( Perl , Java , and now Ruby). And for that it works fairly well: I need to process command line arguments, open an HTTP connection to Strava, download JSON data, convert it, then then output it as CSV. So there's a decent amount there. This project went much smoother than my Java implementation. It was fairly quick, taking a bit longer when I wanted to avoid the program imploding when it was fed a bad activity specification. This version takes as its only command line arguments activity numbers (for full activities) or activity-segment pairs, where the activity number is separated from the matched segment by a "#". It will sequentially load each of these, outputting a CSV stream with the header determined by what fields it finds in the first non-empty activity. It adds the activity number as the first column of the CSV stream. At first I expected the JSON library to have some sort ...

Perl, Java, Ruby

Well, I realized the Pine Flat Road Race was tomorrow (Sunday) not today (Saturday) and so, had I rested today, I probably could have gone. Ah, well. I have a rule that I need to do a hard group ride before I even think about racing, and I haven't yet done so this year, or even towards the end of last year. No, the Friday Noon Ride is not a "hard group ride".... nor is Wednesday. Only Tue and Thu come close to qualifying. So it probably wouldn't have been prudent trying to mix it up at Pine Flat, anyway. But on the positive side, that's 6-7 hours I will not be spending in a car, and more time I won't spend in a smelly motel room, more time to devote to my coding project. On Facebook, it was recommended I look at Ruby. This was an obvious thing to do, since it is what Strava uses for its API example . However, I had gravitated towards Java because with Java I knew I could generate an Android app. All it takes is a bit of Googling to note that Android a...