Make up excuses to learn
I love to study and play with new stuff. I really enjoy this but there’s something that bothers me. My studies rarely result in something useful.
Some weeks ago I was watching one of Giles Bowkett’s screencasts and got caught by a goal he imposed himself some years ago: create a new app every month. Although that seemed a little too much for my available time, the thought itself kept coming back to my mind.
A few days later I was in trouble to sleep and started thinking about something to do with those hours. I knew I’d like to play with Sinatra and explore Selenium usage via Capybara but I decided I wouldn’t do it without concrete outcomes.
I ended up starting the development of a CPF and CNPJ generator which, even though there are dozens out there in the internet and is not very creative, is being useful for me when testing my apps.
Habit changes are tough to achieve and demand constant effort, but I’m totally into it.
Study, play around stuff, but apply it to something you or someone else will use. A real world example will guide your studies and usually takes your first contact with a technology much closer to what truly working with it would feel. And pushing a new app to the wild is always fun.
It’s not new. A lot of people talk about it. Very few people do it.
In case you’re interested, you can view the source code on GitHub.
More apps coming soon.
Cheers!
“
At Viaweb we had one programmer who was a sort of monster of productivity. I remember watching what he did one
long day and estimating that he had added several hundred thousand dollars to the market value of the company.
A great programmer, on a roll, could create a million dollars worth of wealth in a couple weeks.
A mediocre programmer over the same period will generate zero or even negative wealth (e.g. by introducing bugs).
—
Paul Graham
“
If Apple were to grow the iPod into a cell phone with a web browser, Microsoft would be in big trouble.
—
Paul Graham, 2004
Ruby 1.9.2 + RVM + RubyDebug
I have been investing some time in Rails3 and Ruby 1.9. Unfortunately that also means facing a lot of beta and release candidate gems.
One that I was specially missing was ruby-debug. Looking around I found ruby-debug19 but the Mac OS installation instructions are focused on MacPorts. After some research I was able to adapt the steps to my RVM based ruby install.
First, get rid of possible ruby-debug related gems:
$ gem unsintall columnize linecache linecache19 ruby-debug-base ruby-debug-base19
ruby-debug ruby-debug19 ruby-debug-ide ruby_core_source
Then you’ll have to figure out where is your ruby source code. Adapt it to your username and ruby version. It’ll be something like /Users/<username>/.rvm/src/<ruby-version>. For me it’s /Users/mhfs/.rvm/src/ruby-1.9.2-preview3. Adapt to your own username and ruby version.
And finally, let’s install ruby-debug19.
$ gem install ruby-debug19 -- --with-ruby-include=/Users/mhfs/.rvm/src/ruby-1.9.2-preview3
You should now be fine. Let me know if didn’t work.
I’d like to congratulate and thank Mark Moseley for the port of ruby-debug to 1.9.
Cheers!
Truly making Rails3 use JQuery
Being myself a JQuery fan, I always make the change from Prototype to JQuery in the rails projects I start.
The addition of the --skip-prototype option to the rails command was certainly a huge progress, but (you’ll probably call me a purist) not being able to use javascript_include_tag :defaults with JQuery used to annoy me.
Not anymore. Reading Rails Inside I figured out there’s a way of teaching Rails what your defaults are.
Just create an initializer with the following content:
module ActionView::Helpers::AssetTagHelper
remove_const :JAVASCRIPT_DEFAULT_SOURCES
JAVASCRIPT_DEFAULT_SOURCES = %w(jquery.js rails.js)
reset_javascript_include_default
end
And now your call to javascript_include_tag :defaults will include JQuery instead of Prototype.
Cheers!
Windows like Home and End keys on the Mac
When I bought an external keyboard to use with my macbook, I had 2 expectations. Stop burning my fingers in the freaking hot aluminum (I live in a hot city) and have Home/End/Delete keys.
My fingers were fine but the Home/End keys didn’t work as I expected. I wanted the same behavior I used to have in Windows, moving the cursor to the begin/end of each line.
After some research I discovered a small trick to achieve that. You can create a file named DefaultKeyBinding.dict under ~/Library/KeyBindings/ with the following content:
{
"\UF729" = "moveToBeginningOfLine:";
"$\UF729" = "moveToBeginningOfLineAndModifySelection:";
"\UF72B" = "moveToEndOfLine:";
"$\UF72B" = "moveToEndOfLineAndModifySelection:";
}
Restart the application and you should be fine.
Cheers!
RMagick and Snow Leopard
RMagick is a RubyGem that wraps ImageMagick’s features.
I never used it by myself but the project I’m working on uses a gem who depends on it.
I installed it twice. In the day I started working in the project and in my dev env rebuild last weekend. Both times it was a PITA. For different reasons.
The first time it was a conflict with a library MacPorts installed which I had to remove. Obviously after a lot of wasted hours.
This time it was a little bit harder to figure out. I installed ImageMagick via Homebrew and then installed RMagick via gem install. The installation went well and I wrongly assumed everything was fine, but when I tried script/server I got a frozen process. No error messages.
After a lot of research I discovered that even though RMagick 2.12.2 (latest available gem) compile against ImageMagick 6.5.6 (the version Homebrew installs) it only works with ImageMagick >= 6.5.8. My work around was a customized Homebrew formula for 6.5.9.
So, after the story, let’s make things happen.
Download the custom formula here.
Someone told me brew install -i would work, but it didn’t, so copy the file to /usr/local/Library/Formula/ and then:
$ brew install imagemagick_rmagick --with-ghostscript
$ gem install rmagick
That should make you ok.
Ruby 1.8.6 note: it seems ruby 1.8.6 has an issue with RMagick and Snow Leopard. You can see all the hardcore details here. It’s safer to go with 1.8.7.
Homebrew note: I created an issue asking for a ImageMagick formula update. The custom formula won’t be required soon.
Rebuilding my development environment
Some time ago I had to compile some libraries for a project I’m working on and that made me realize my machine was all messed up.
It had ruby and mysql manually compiled into /usr/local, imagemagick installed via a package, postgres installed via macports (arghh) and some other stuff that I don’t even recall compiled via different install scripts. I was also trapped to a single ruby version.
One may say it’s not a big deal but to a control freak like me, that’s more of a mess than I can leave with.
I guess my lack of familiarity with a Mac took me to that point and I finally decided to put some effort on rebuilding my environment.
I’m not the step-by-step kind of guy, so I’ll just present the tools that I now rely on and made the difference to me.
Homebrew is a recipe based package installer that’s becoming very popular. It’s great and the formula library is growing fast. It beautifully organizes everything into /usr/local and have a great symlinks approach. Very easy to install and uninstall stuff. Some basic dependency resolution is also present. It quickly gave me wget, mysql, postgres and imagemagick. Take a look on the list of recipes.
RVM or Ruby Version Manager is a sweet gem which allows you to have multiple versions of Ruby installed in the same machine and easily switch among them. Gem sets is a cool feature it offers which allows you to jail that app which purpose seems to be using all the gems out there.
One more cool side effect of using Homebrew and RVM is that I no longer need to use sudo all the time.
Hope it works well for other people like it’s working for me.
Cheers!
Get to know Heroku
If you’re looking for a hosting solution for your Rails app I have a suggestion. Try out Heroku.
It’s a git based deploy solution really easy to get running and with a decent free plan for small apps.
Once you start getting more traffic/data you can dynamically scale resources.
My blog is running on a free Heroku plan for a couple of months now and I have no complaints. I have some difficulties when deploying it but their support were great even for the free plan. And it was my fault on the .gems file anyway.
Now that I feel comfortable having tested it with my blog I’ll start migrating/deploying some other apps to it.
And keep an eye on the AddOns. They’re getting better everyday.
Cheers!
Apple Brazil Fail
Apple recently launched their online store in Brazil and I immediately ordered a full keyboard to use with my hot-as-hell-macbook.
The order was placed and processed on Oct 6th. The delivery was initially supposed to happen in 3 to 7 business days. From Oct 9th to Oct 15th.
Yesterday, Oct 7th, I received another email telling me they were sorry to inform my order would be shipped only on Oct 23th and could take up to Oct 30th to get to my home.
So I ask:
- how could the estimated date vary that much in 2 days?
- why are they stating on the online store they are shipping in 7 to 10 business days if my 2 days ago processed order will ship just in 12 business days?
Incredibly, It seems they still didn’t learn the lesson.
Very frustrating first experience. Specially considering all my expectation. I mean, it’s Apple.
Where’s Tim Cook, the master of distribution and logistics?
Cheers!
Update: after all the mess with my order they ended up delivering the keyboard today, Oct 14th.
Older Posts