I will be moving this weblog to blog.john.yerhot.org in the next couple days. I will also be moving from Wordpress to my own home brew platform. johnyerhot.com will still go here, and so will all the posts, but I will not be posting here any longer.
0 CommentsAgainst the advice of, well, the entire Rails community, I attempted to deploy a project to Godaddy.
Godaddy proudly displays the little Ruby logo next to Php when browsing through their hosting plans, and seeing as you can get Rails hosting for $7/month through them, it seems like a decent deal, even if you know it’s gonna get slow.
Baisically, what ends up happening when deploying to Godaddy, is you upload your application to a special directory you create through their control pannel, modify your dispatch.fcgi file, .htaccess files, turn off Java and pray. Its all supposed to run as FCGI in the end, which is not the speediest way to deploy a Rails app, but is acceptable for smaller, non-demanding applications.
The application I was attempting to deploy was a Rails 2.1 app, and I found that Godaddy is rocking Rails 1.1.6 (Release Aug 2006), so I froze Rails (standard practice), change the configs to point to the manually created database (no rake support here folks) and tried to hit it. Nothing. First, every time you modify the .htaccess file (and you will need to - many times) it takes 10-30 minutes for Apache to notice. So, you’re stuck making a change, waiting, testing, washing and repeating. If you’re using FCGI, there is literally NO output into the ‘errorlog’ Godaddy gives you, so you have to deploy with regular CGI to get any idea why your application isn’t working and then switch back to FCGI and pray.
Finally, after a couple hours of searching the interwebs and poking and prodding, I was getting somewhere - the error log started to get populated, but FastCGI wasn’t starting correctly. After some snooping, I saw that Rails 2.1 assumes that you’re not running whatever version of Gem was around in 2006. Gem was failing with a method not found error when Rails tries to talk to Godaddy’s almost 3 year old version.
I putzed around a bit looking for ways to skip that step of Rails’ boot process, swaping out boot.rb files from older version of Rails, hacking, etc.. and to no avail.
This is where I stopped. I figured that even if I got past this problem, the version of Rmagick was from mid 2006 and would likely not work with my app, and I wasn’t about to try and get Godaddy to update it. If they haven’t updated any of the Rails stuff yet, I don’t think they are going to any time soon.
My message for Godaddy is this: I want the entire day I spend on this back. You should stop advertising that you support Ruby/Rails when you obviously don’t. I’d bet 90% of Rails apps in development today would not be able to run on their hosting plans. Eh.
1 CommentMy big project for the weekend has been moving my humble lil web hosting setup to a separated out, virtualized environment. We’re doing this at work and have been very happy with the results.
My original plan was to use KVM for the virtualization, so I could take advantage of paravirtualization. Supposedly it is much faster than a fully virtualized machine, but requires newer hardware… anyway, shouldn’t be an issue, I’m using an AMD X2 4400 which has AMD-V built it.
So I spend an hour installing everything on a fresh install of Hardy 8.04 only to realize that I couldn’t take advantage of paravirtualization because my motherboard didn’t even give an option to turn on AMD-V. Further, I found that KVM’s networking is screwy, especially when bridging connections.
Another hour of deciding what to do and I decided it was best to go with the good old VMware Server solution. Ended up creating three virtual machines, a Git server, web server, and a MySQL server. I’m really excited to experiment optimizing each spoke in my web stack, and I can easily back everything up, or setup other development servers quickly and easily.
I’m pretty happy with it and am glad to have it up and running. It’s totally nerdy and I love it.
0 CommentsJust for those of you in N. Minnesota that love Henry Rollins as much as I, he’s gonna be at Sacred Heart Studio/Music Hall on October 23rd. No word on how/where/when to get tickets…
Directions to Sacred Heart and their phone number = (218) 723-189.
0 CommentsHERE IT IS. Google’s rumored browser is actually real and you can download it. Runs webkit (good thing), seems very fast, and looks like cotton candy.
No OSX or Linux version yet.
Eh.
0 CommentsI merged some stock quoting stuff I had into a Rails plugin today. If you’d like to be able to simply grab real time stock quotes in your Rails app, this will do the job. Pretty much any stock symbol will work and you can enter as many as you’d like, you’ll get a hash array of hashes containing each symbol’s current value, change since open, and volume.
http://github.com/johnyerhot/rquote/tree/master
Rquote
======
Gets realtime stock quotes from Yahoo Finance.
Its super simple to use.
Example
=======
quote = Rquote.new
quote.find("aapl", "msft")
=> [{:change=>"-4.02", :price=>"169.72", :volume=>"16105013", :symbol=>"aapl"}, {:change=>"-0.42", :price=>"27.52",
:volume=>"27024456", :symbol=>"msft"}]
Copyright (c) 2008 John Yerhot, released under the MIT license
4 Comments 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.
0 CommentsI’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.
0 CommentsI’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!
0 CommentsMetaprogramming. 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?
2 Comments
