Personal Data: Days Biking to Work

Some years ago I used to run marathons and half-marathons. After 3 full marathons and countless half’s I got tired of the crazy training regiment and decided I would switch to triathlons (which would probably require just as much training). I was missing a key component though: a bike. So I got this:

Trek Alpha 1.5c

Unfortunately my laziness won over regarding training and I never did any triathlons but I did decide to start commuting to work on my bike. It took a few commutes to get comfortable riding down San Francisco’s Market Street and as I did I began tracking the days I rode. My goal was to see how long it would take to pay off my bike in saved Muni fare. The bike, with accessories, was $981 and considering I paid $4 a day for the bus ($2 each way) I calculated it would take 246 days to pay this off.

I can’t believe it but the day has finally come and I have finally paid off my bike in saved bus fare. Being that I’m a bit of a data tracking/Excel fanatic I had a spreadsheet tally of each day that I rode my bike.

Here is a graph over time that tally’s the days where I rode to work. The steeper the blue plot, the more consistent my ride to work was. The green line represents the percentage of days that I biked to work (246 of 706 days).

bike days

Over the course of 706 days I rode to work 34% of those days. Obviously there are some very flat regions on the graph which initially represented laziness, yet some of those days were because I had to drive to work to carry equipment.

Eventually though I broke my laziness streak once and for all and became much more consistent with my bike commute. I started riding everyday and that is where the graph finally consistently increases. Though two recent plateaus of progress occurred because I was unemployed most of last summer and had no where to go, and my gear snapped just recently. I have a tally of the months as well, that show how often I would ride over the 2.5 years its taken.

month

2012 was a Lazy Year!

With a commute of about 3 miles (one way), this puts me at at least 1500 miles over the course of the 2.5 years this has taken me to achieve. I love my Trek!

Load Project Folder into Sublime Text with Automator

For many years I have been an advocate for automation for repetitive routines when using my computer(s). I have dabbled in AppleScript and heavily in Excel, but I think a highly overlooked application for Mac OS X is Automator.

automator

What is great about Automator is that it enables you a large number of Plug-Ins right off the bat that are all somewhat useful. I originally learned about Automator when I had gotten fed up with building a download file filter using AppleScript. I just wasn’t prepared for learning the AS language at the time, and in a sense, I’m glad I gave up on it and explored Automator.app which was fairly new at that time.

Automator was first introduced way back with Mac OS 10.4 (Tiger) and over the years I’ve never really seen people talk about, much rather use, this program much. Since Automator’s introduction back in 2005 there have been many additions to the program with each new OS X release, sadly I have not delved nearly deep enough to stay up to speed. But for what I do know, I have always quietly enjoyed using the little ‘Pipe holding robot’ for solutions like what I am about to explain.

The Problem

When I am working on a development project I, like many others, load the entire folder into Sublime Text 2. Now you can use the Sublime command line interface to do this by running the subl . command from the Terminal when you’re in your working directory. This works just fine and I am all about it. But as I started into more front end work I realized I didn’t always have a Terminal window open. Why open a Terminal window to run the subl command? There’s gotta be an easier way right? (Although I can highly recommend Go2Shell.app to quickly go from a Finder window to that directory in the Terminal.)

Enter Automator

The solution to this was a dead simple Automator workflow. So simple that I thought it was a great introduction topic to talk about. What I came up with is a Finder contextual menu item (i.e. right-click menu) that loads whatever folder you select into Sublime.

When you first open Automator you are given several choices for the type of document you want to create. I haven’t explored all of these items too much, but in our case we will use a Service.

start_screen

Amongst many things, a Service is what can provide the Finder a contextual menu item that performs some operation. After you choose this item you get the blank document to drag and drop your workflow actions. For this we really only need one Action – “Open Finder Items”. It helps to use the little search bar to quickly find this Action.

Ok, so you’ve dragged your “Open Finder Items” action into your work area on the right and selected Sublime Text 2 from the “Open with:” dropdown menu. You should have something that looks like this.

workflow

You’ll possibly see one other thing I’ve changed, which is above the workflow area. The “Service receives selected” dropdown should be set to “folders” so that this workflow will expect a folder object (although if you put folders or files it’d be ok too).

And that’s it! You’re done with the workflow, so let’s save it as “Open in Sublime Text” and go try it out!

contexual

Head into the Finder and select a project folder you want to open into Sublime, right-click and select the Services sub-menu at the bottom. Select your new “Open in Sublime” contextual item and your project should now be opened up and you’re ready to get to work!

One last thing, in case you want to know where this file is stored locally, it is found in: ~/Library/Services

DIY Speaker Repairs

I was testing a used power amplifier earlier this week and, like an idiot, hooked it up to one of my home speakers. My speakers are Paradigm Titan II’s that I’ve had for over 10 years now.

When I tested this amplifier I ended up blowing the speaker which I feel very stupid about (time to review impedance matching!). I opened up the speaker to find a tiny tear, about 2 inches long, at the foam surround and the cone.

Speaker-Cross-Section

I should have taken pictures of this all but hopefully this spells it out. Since the tear was pretty clean at the cone and foam I figured I should be able to glue it back together. I wanted to post my story so someone in the same position may benefit.

I bought some flexible drying adhesive for vinyl and leather applications (this specifically). I used a paper clip to carefully dab the adhesive where the tear had occurred and was very careful to only use what was need, we’re talking a few light drips of this stuff.

A speaker works more effectively the less mass it has, yet it needs to be strong enough to probably displace air so you get a nice crisp sound. Increasing the mass of the cone can reduce the fidelity of the speaker and thus I stress again, use only a small amount of glue to make sure the speaker doesn’t become imbalanced.

Exploring Inject and Finding the Mode in Ruby

Prior to Dev Bootcamp a packet of preparation Ruby problems were distributed. These challenges are hosted on a site that has a compiler that will run it’s RSpec tests against your code. If your code does not turn all the tests ‘green’ then you fail. As prep works this does a great job of testing you. When I entered that prep work phase way back in March I got very stuck on one problem: Find the Mode of an Array.

For the uninitiated the mode is the number that occurs the most within a number set. I did eventually solve this problem, but I wanted to share a recent solution I came to which involves some Ruby methods that I feel should be known.

Now what I want to focus on is the inject method in line 2. My use of this inject call here is to avoid an additional line of code defining an empty hash variable. What inject is doing in this block is defining ‘k’ as the hash object and then counting the number of times an integer is in the array. At the end of the block I must return the hash so the next iteration of the inject block defines the ‘k’ variable. This is how I use inject to populate a hash object.

Finally the third line uses select to determine any integer that exits the most times (i.e. the mode). This line took me a little while to really understand, yet it is very straight forward. The select method will only return the values that are true in the block. Therefore, the max value values returns the key, thus the mode of the array. I’m learning to love these two methods.

Poor Mans AppleTV (Raspberry Pi + Plex)

I have been on a mission for several years to create the cheapest home theater PC (HTPC) with the basic condition that it must be drop dead simple to use and it MUST have a Plex client. I don’t really care what you say, Plex is absolutely a must have for a HTPC setup.

Lately I have been using my iMac to run Plex and watch shows, but this isn’t the best solution. So a few months ago I bought a Raspberry Pi and recently I installed Rasplex on it. Rasplex is a Plex port that runs on the very lightweight hardware of the RPi. The menu’s of Rasplex are a little slow, but this is all resolved if you use the Plex iOS app to select what shows you want to watch. The app is $4.99 and is absolutely worth it (I think most apps that are under $5 are worth it).

What amazed me about the RPi is it’s ability to handle 1080p without a problem (possibly better than my iMac) and Rasplex is able to connect to Plex Media Server running on my iMac. I admit I will be willing to jump to a future AppleTV revision if it opens up to apps, but at the time being this is a great, cheap, solution.

I am debating writing up a tutorial on getting the RPi and Plex all setup. If there are questions out there I’m more than happy to lend a hand. Email me or leave a comment, I check all these quite often.

It’s taken 32 years

But I finally caught a foul ball. This does mean I have to admit I went to a Dodgers game last night but after being a lifelong ball player and having gone to countless games in my life, this was a pretty big deal.

Caught a foul ball at Dodger Stadium

Caught a foul ball at Dodger Stadium

A web developer, are you?

Of all of my web app ideas I come up with, the one I couldn’t get out of my head was a dumb little Yoda advice page. Fortunately, my dumb ideas are not without making practice of something I can use later. Originally I had used Nokogiri to parse data from websites but it isn’t the easiest to use gem. I’m sure if I took time to master it I’d be a parsing machine, but I had heard about Mechanize and this was the gem I wanted to try out for my Yoda site.

I parsed out data from a few other Yoda quotes sites and shoveled them right into my database using a rake task. It gets the job done and enabled me to easily randomize a quote along with an image to display everytime you hit the reload button (or just press ‘R’).

Anyway, I have no other plans for this little exercise but wanted to share. Check it out.

Dev Bootcamp Final Project: Bounty Cove

We finally finished up our final week of Dev Bootcamp and our final product is Bounty Cove! This was the labor of one week of intense team programming and we are very proud of the results.

The idea behind the site was to teach children financial literacy through a pirate themed website. The site requires that a parent sign-up as a “Captain” and then they can recruit “Pirates” (i.e. their kids) to take on different quests that are set up. Now the quests are thinly veiled chores around the house which, when completed, you are rewarded with gold dubloons. These dubloons can then be used to buy items in the pirate store that the parents setup.

It was a lot of work to get this site up in just a week but much work is left to be completed. Let us know what you think!

Command-A, Delete

Last weekend I got fairly excited about my guitar tab writing app. It was going to become a big traffic source for Redundant and I was going to build street cred as the guy who made tabbing fast and easy.

But then something happened, my app got complicated. Before I knew it I had three nested loops needed just to print tabs to the screen. It required method after method just to check if chords were in the library, and if they weren’t were they integers. What was the user trying to enter exactly?

Yes, things got complicated to the point that I was procrastinating just “thinking” of making this into a Sinatra App. Creating embedded ruby from all my poorly named variables and giant loop methods was the opposite of how I originally envisioned this project. I was avoiding my once exciting project.

I have been told from the beginning of Dev Bootcamp to adopt the mantra <buddhist drone>”I am not my code”</buddhist drone>.  I’ve understood this advice should be taken for a few reasons:

Primarily, it was to enable ourselves to received feedback/critiques on our code without feeling we were being personally attacked. What you’ve programmed does represent your knowledge base and effort, but at the end of the day you have to realize that it can always be improved upon.

Secondly, there may come a time when your code has become ugly, unmanageable and confusing to the point where it needs to be put out of it’s misery. If you are too attached to your code then you risk wasting mucho time in trying to give hope to hopeless code. Sometimes you gotta know when to let go.

So that’s what I’m doing with the guitar tab project. Letting it go. I realized that building the views, database, and controller for the code would probably be rage inducing and I feared having to deal with it. Furthermore, I feared having to manage the code as I attempted to improve the project. Ultimately, I had coded myself into a corner and the best way out was to just walk away.

The idea is still very much alive in my mind but I think I’ll approach it again when I get more comfortable with Rails and can take a little more time on it. Until then, this will become yet another abandoned repository on github (https://github.com/TravisL12/guitartab_builder).

Let’s Talk Guitar for a Second

Over the weekend I was looking up some guitar tabs to learn to play a song and I was struck with an idea. “I should build a guitar tablature app in Ruby”. It’s amazing how a 2 second idea turns into a dedicated weekend of coding.

I built my guitar tablature app (https://github.com/TravisL12/guitartab_builder.git) to allow myself to write tabs very quickly because writing them manually into a text file is super lame. This means I wanted the interface to allow me to very quickly type in the fret number and which string it’s on and get it printed to screen (and eventually text file or the web). So the interface may be a little cryptic but I’ll work on that. Though this will not change my goal of being able to produce a tab very quickly.

Above is a brief output of the program. All you have to do is type in a guitar chord and bam! it is printed to screen. So now what about if I want to type out something that aren’t chords? Well then you just enter in the frets to play followed by the strings to strum. The following is a simple 12-bar blues progression that should look familiar:

And there you have it! I still have plenty to work out on this (like double-digit frets!) but I’m happy with the progress over a few hours this weekend. Ultimately when I get more comfortable with the DOM and perhaps Sinatra I’ll get a sub-domain rolling with this tab in it so people can start producing their own tabs. That’ll be a trip.