Archive Page 2

One year older

I’m now one year older. I am 25. It is one of those ‘cup is half full or half empty’ ages. On one hand I’m halfway to thirty. On the other hand, I’m probably entering my prime. I’ll go with my prime.

Sometimes I look at the past year and I think that not much has happened. I think I’m one of those people that needs to have things happening all the time though, because in reality lots has happened.

  • We moved across town
  • I got a new job.. well got it at the end of last year..
  • Paid off lots of debt
  • Discovered the Stockmarket ($$)
  • Went out to Seattle/Portland for a while
  • Some other stuff I don’t really want to publicly put out there… ;)

I had a wonderful day.. nice dinner at Tom and Wanda’s last night. Some cake and cards and a nice dinner with Jen tonight… lots of “Happy virtual Facebook Birthday’s”. Plus my mom sent me flowers. Guys getting flowers is hardcore. Love ya mom.

I’m really happy and am extremely excited for what the next year holds.

I’ve been really putting off using Rspec. Unfortunately ( and like the vast majority or programmers out there) I have not been writing enough tests for my apps. When I did write them, they were using Rail’s built in Test::Unit library, which, many will say… sucks. Plus, honestly, they were half assed.

So, I’ve taken it upon myself to dive into Rspec. Most everyone agrees it is the way to go, and it gets you into BDD, which gives me another bussword I can throw on the resume (/sarcasm).

The part about writing tons and tons of tests to cover all your app that didn’t make sense was that you would end up writing so much more code. In reality, I think it boiled down to being lazy, which all programmers are. Since the Rails community prides itself on keeping things DRY and keeping the amount of code written to a minimum, why the hell would I want to write tons of tests for stuff I don’t think are going to break?

In the long run, for any programmer, it is really not about how much code you actually have to write, its more about how much time you send making the app work. If you’re like me, there have been many nights spent debugging some controller that totally broke and you’re stuck refreshing your browser, creating a user, deleting a user, and checking the log over and over until you solve it. I hate it and have probably wasted days doing this. If you had written tests for your app, starting with that first controller, and continued writing quality tests, used autotest, you would avoided this. You would be confident that you code was rock solid.

What about if you’re absolutely sure you’re code won’t break? Well, it will. Maybe not all of it, but you’re gonna have problems eventually. I don’t think that writing tests for trivia stuff (like validating that validates_presence_of is working) is really worth while, but other stuff is fair game.

The list point I’d like to make is that I think since really writing tests and using Rspec, my thinking has changed. I know think writing code, not just as how do I make this work, but also, how to I ensure this WILL work. You’ll find yourself trying look for ways that your code will break, looking for more flaws, and consequently, leaning from those flaws. I’ve found myself refactoring much more code and that end up making my code more flexible and cleaner.

I don’t want to pretend to be a captain awesome when it comes to writing tests yet, but I really think I’ve been coming along very well and am so glad I’ve been investing so much time in it. Give it a try ya’ll.

I’ve sort of finished up rDigg today. It’s to the point I’m comfortable letting other people start to play with it anyways.

As you’d expect, rDigg is a Digg API wrapper in the form of a Ruby on Rails plugin. It still needs some work, but works pretty well.

For example:

#create new Rdigg object
digg = Rdigg.new

# find the 3 newest submissions from Kevin Rose
stories = digg.user.find_submissions("kevinrose", :count => 3)

# stories is now an array with a hash for each story
stories.first[:story] #=> the story’s text
stories.first[:href] #=> the story’s url
stories.first[:diggs] #=> number of diggs the story has

Grab it at: http://github.com/johnyerhot/rdigg/tree/master. I’ll have the Rdoc up at rdigg.yerhot.org later tonight You can peruse the documentation at rdigg.yerhot.org. I highly recommend you check out all methods that are available to you.

If you want to really dig in (sorry couldn’t resist) I’d go over the Digg API wiki to see what arguments you can pass.

I hope you enjoy the plugin!

Metaprogramming.  What a lovely buzz word.  I guess I’ve heard it enough and knew what the short definition is. Metaprogramming is code that writes code.  I think it is one of those things I just never thought about, even though I had used concepts and even written some before without realizing it until recently.

Here is a short and simple example.

class Something

@my_hash = {"foo" => "1234", "bar" => "5678"}

def initialize
  @my_hash.each do |a, b|
       self.instance_eval do
             define_method(a.to_s) {b.to_s}
       end
  end
end
end

And now we can play with it.

a = Something.new
a.foo  # => 1234
a.bar # => 5678

Now, what happened here is pretty neat in my opinion. We took our hash, my_hash, and in our initialize method, created two instance methods from its values. define_method is what did all the magic. You need to pass it a proc or, like what I did, just give it a simple block (just the string value from my hash).

Pretty neat, eh?

Guess what I saw today driving in Lakeside…

Kind of hard to see, but yeah it is the Google Street View car.  My phone’s camera is pretty bad, this was as high res at it would allow…

I have DSL service from Qwest.  It is ok.  Beats the competition. The one thing I HATE is the modem I got from them, an Actiontec GT-701WG.

The problem?  It was darn near impossible to make it be JUST a modem, not act as a router/gateway, not act as a NAT, no frickin Actioncrap firewall, just give me the WAN Ip address!

Nearley, but not impossible.  Here is how.

The trick is to set the modem to transparent bridged mode (I think it was labeled as RFC 1483 Bridged). You should be able to find it somewhere in the advanced setup section.  The username and password needed below are also found on the same page.

Then you take your handy dandy router (mine is running DD WRT v.24, may not work with standard firmware) and change the WAN setup like this:

1. Connection type = PPPoE (Even though Qwest says they only support PPPoA
2. Username = your username… our was parts of our last name followed by some numbers.
3. Password = corresponding password
4. PPP Compression = On.  At least I have it on.

Everything else in that option group set to off.  While your at it, go to DNS and grab OpenDNS’s DNS server’s ips and throw them in there.

Now what the heck did this do?  Well, now your router’s WAN IP will be the Ip assigned by Qwest.  Before it was being assigned an IP by the Actiontec modem, probably 192.168.1.1XX, cause it was acting as a router, which sucks.  Now, the router is the gateway and, if you’re running DD WRT or some other thirdparty firmware, a much better gateway than the Actiontec was.

I honestly have experianced my better preformance from my DSL and used to have to powercycle the modem at least weekly.  Its been going for a month like this and hasn’t been power cycled.  Not to mention all the much better features DD WRT offers.  Sweet.

Moved hosts again.  Taking it all in house.  Yup, this fine blog of mine (and lots of other crap) is now being served off my home brew server sitting behind the TV(also acting as a fileserver).   If there is one thing I freaking hate, it is moving a Wordpress install.  Something always messes up and, while usually very easy to fix, it is never easy to spot.

I’ve also moved back to Apache2 from Nginx since I’ve got a lil more muscle to go around than with the Slicehost account I had.  I’m going to hold on to it (Slicehost account) to see if anything horribly wrong happens. but I think this should be fun.

Alright, DNS is still propagating for yerhot.org and some others.  Hopefully it’ll be done in the a.m.  I’m hitting the sack.

Lemme know if you have any thoughts.

Why don’t I listen to people?  Jen and I just sat through The Happening.  Yes, it does suck just as much as every other M Night Shamalama dig dong movie since the Sixth Sense.

How he managed to make Mark Wahlberg and John Leguizamo completely suck beyond belief is beyond me.  I’m not even sure why I’m writing this.  Guess it was so bad I felt the need to let everyone know.

Yes, Jen and I got some hot rods.. two wheeled hot rods with pedals…

We are now the proud owners of two Specialized bikes.   Jen has a Cross Roads and I got a Hard Rock.  It’s by far the nicest bike I’ve ever ridden, though both are used and a couple years old and not top of the line by hardcore biker standards.

Anyways, we’ve been riding all over our new neighborhood and I have to say it is really fun.  We’ve set a goal of riding (most of) the Munger Trail by the end of the summer.  Sweet.  Maybe we’ll even buy some of those spandex jump suits to bike around in. :)

Jen’s got the purple-ish one and I have the white one.

Seattle Day One

It has been a very long, but very fun day. We’re both pretty jet lagged and turning in for the day but some tthings we’ve noticed about the fine citizens of Seattle:

  • They do not jaywalk.
  • Pretty good and nice drivers
  • They park very close to each other. Like an inch.
     

Heres some pictures from the day.  Tomorrow I think we are going to go and see Mt. Rainier… more updates to follow.





    John Yerhot / Weblog / is Digg proof thanks to caching by WP Super Cache!