CarrierWave file exists?

If you ever wondered how to check for file if exist while you were using carrierwave gem with storage on amazon S3 here is how.

Assuming you have User class:

class User < ActiveRecord::Base
  mount_uploader :avatar, AvatarUploader
end

and uploader class
class AvatarUploader < CarrierWave::Uploader::Base
  storage :fog
end

then only thing that you have to do is this

user = User.first
user.avatar.file.exists?

thats it. I kind of assumed that it should be simple avatar.exist? but you have to get fog instance of file to be able to access exists? method.

9 Keys to Business & Career Success

This article is quite good, but as every article you have to make up your min about it. Don’t follow every advice blindly. Think and then you practice. Remember, start behaving like someone who you would like to be and then you will become that person.

via 9 Keys to Business & Career Success | Inc.com.

Remindcast – my latest project

I had conversation with @mattwilliams about weather and how it would be great to have some tools that will tell you if it will be warmer / colder than yesterday. So you can decide what to wear or what to bring (like umbrella) with you to work. So I build it and you can try it here. Let me know what do you think.

From developer point of view:

Whole thing is build in latest rails. I’m using Google API (that have no documentation) for weather feed, Twitter for messaging and for authentication. The whole thing is hosted on Heroku.

Miles Davis and his wit

Davis was a man of few words. When he did speak, his words often had a similar effect to a hand grenade being lobbed into the room. In 1987, he was invited to a White House dinner by Ronald Reagan. Few of the guests appeared to know who he was. During dinner, Nancy Reagan turned to him and asked what he’d done with his life to merit an invitation. Straight-faced, Davis replied: “Well, I’ve changed the course of music five or six times. What have you done except fuck the president?”

via Miles Davis: his wardrobe, his wit, his way with a basketball … | Music | guardian.co.uk.

Rails: The Next Five Years by Yehuda Katz

Rails: The Next Five Years by Yehuda Katz

When Ruby on Rails burst onto the scene in 2004, it excited web developers by showing that you could build next generation apps quickly and efficiently. Rails was one of the first frameworks to embrace Ajax, giving everyone the power to do partial page updates and whiz-bang effects in a conventional, effortless way.

TextMate folder pattern

I reinstalled my Mac recently. Because it was a new installation a had to install everything from scratch which includes a TextMate. After a while of using it I get annoyed by dialog window for opening a file. It list lots of similar files from vendor folder in my Rails env. So I investigate little bit and find that you can modified settings for that (Preferences -> Advanced -> Folder references -> Folder pattern). When I’m trying to open a file, TextMate is ignoring vendor folder, now. You can see regexp for that bellow.