Day 962
https://github.com/postrank-labs/goliath
This basically just works out of the box, which was really impressive.
ruby server.rb -sv -p 8080
Thanks PostRank!
https://github.com/postrank-labs/goliath
This basically just works out of the box, which was really impressive.
ruby server.rb -sv -p 8080
Thanks PostRank!
Today (last Friday, really) I learned that when possible, you should have your model enforce intended behavior.
This seems pretty basic, but really makes life easier.
Context: I was working on resolving redirects, and by putting behavior into the same column, you can ensure that you will never have a redirect and a 404 or rename on the same page.
Today I’m working with Ruby’s Benchmark gem.
time = Benchmark.measure do
...
end
ap time
It’s pretty simple!
Today I will be writing a MapReduce job in javascript for MongoMapper. Never mind that I don’t know javascript… This is definitely going to be a learning experience!
These links were helpful to me: http://code.google.com/edu/parallel/mapreduce-tutorial.html http://www.chrisumbel.com/article/map_reduce_mongodb_mongomapper_rails http://technicaldebt.com/?page_id=983
Setting up a test environment for rails.
That’s my task for today. This should be a good learning experience.
Started off including rspec in the gemfile, and adding factorygirl:
group :test, :development do
gem "rspec-rails", "~> 2.4"
gem "factory_girl_rails", "~> 1.2"
end
Next, I updated my various backend configurations to include a test environment: database.yml, redis.yml, mongo.yml, mongoid.yml
EDIT: Turns out that’s about it. Bootstrap rspec: script/rails generate rspec:install And you’re good to go. One thing that I couldn’t get into my head was the fact that you populate the mock database with factories, which is what FactoryGirl is for. Basically, use a factory to give yourself the data you want for testing your MVC.
Cool!
New isn’t always better.
Just spend a day working on using a Sidekiq worker instead of the normal Resque ones. In theory, the sidekiq worker can do more work with less resources, if you’re memory constrained. The problem I ran into was that the Sidekiq worker would STOP ALL WORK after roughly two hours.
I switched back to using resque workers, and we’re processed about 5x more jobs in the past 2 hours than all of yesterday.
Cool number
Ruby’s string handling frustrates the CRAP out of me.
Somehow, while importing some text, ® is being converted to \xC2\xAE, but then being written into the DB as ®, and returns to me as ®. This futzes with all my string comparison efforts.
Grr!
oh, string.force_encoding(Encoding::UTF_8). BOOM
Going to Harvard means I have the very unique opportunity to be around a lot of smart people. Now, when I say “smart people,” I don’t mean that guy who always wins trivia night. I mean, blazingly intelligent individuals who are regarded as the pre-eminent scholars in their field. It’s pretty…
Take that, Chris.
(Source: tmac721)
Learn when to quit.
Just spent four hours on a single silly item (didn’t fix it). Fixing that would probably save us minutes a week. Cost benefit is not proportional. If you’re going to quit, quit early.
Interesting number for the day.
Apparently in C#, if you are using doubles, .1 + .2 + .7 = .999999989 which is != 1. RAWR! Use decimals instead.
Another coworker and I were in the office building our project until 11:30 last night. It was a bummer being there so late, but really peaceful at the same time. When I finally completed the backend, and we plugged it into the frontend, and numbers started coming out, we were both ecstatic. Sometimes working long hours suck (esp if you are salaried) but if the product works out, it’s all worth it. Yay!