Front loaded estimation is selling your stakeholder a lie – The Hashrocket Blog

I am singing this song for something like 3 years now.
Estimations, fixed price projects and estimation ahead are all a scam.

You lose, the client loses, not a good situation.

A nice writeup on the Hashrocket blog.

Front loaded estimation is selling your stakeholder a lie – The Hashrocket Blog.

10 Things You Didn’t Know Rails Could do

James Eduard Grey published a presentation of a talk he did in RailsConf.

It is pure gold, so many tips and tricks, I promise you, some of these will be new even to the most experienced of Rails developers.

10 Things You Didn’t Know Rails Could do // Speaker Deck.

Decorating Devise’s current_user with Draper – Ariejan.net

A great trick to decorate the current_user method from devise using Draper.

IMHO it’s actually applicable to any authentication system out there that is using current_user but that requires some testing.

Decorators are an awesome way to remove logic from the view or the models, so the models have real business logic and the rest can be “decorated” with another class.

If you are looking for more information about decorators, Ryan Bates has a great screencast about it here: http://railscasts.com/episodes/286-draper

Enjoy

Decorating Devise’s current_user with Draper – Ariejan.net.

Submit any form with a keyboard shortcut

Say you have a simple form like “Add comment” similar to this image

Add comment form

Now, this is a text-area, so the ENTER key will break rows and will not automatically submit the form to the server.

I want to create a flexible way to send the form to the server with a keyboard shortcut like CTRL+ENTER.

Thanks to an awesome library by Thomas Fuchs called KeyMaster it turned out to be quite simple.

By default, Keymaster ignores all keyboard shortcuts if it’s inside an input or textarea or even a select box, obviously that is not what I wanted or needed.

Luckily, you can override that behavior with a filter function, like so

 

Now, all you need to do is listen to the event, and when it’s fired, submit the parent form. like so:

 

That’s it, now every text-input, input or select box can submit the form with this shortcut, it’s super useful and your users will certainly like it.

Essential Sublime Text 2 Plugins and Extensions | Nettuts+

I switched from TextMate to Sublime Text 2.

Been using it for months now and it keeps surprising me with how fast, smooth of an experience it is.

If you are still using TextMate or something else, you need to look at this post.

Essential Sublime Text 2 Plugins and Extensions | Nettuts+.

Do your own Agile…

There’s a lot of buzz going on about software development methodologies, people talking about Agile, Kanban, Pair, XP and more and more.

There’s not much people are talking about when it comes to a single developer.

I have been a consultant/developer for the past ~3 years or so, working from home for several clients both in Israel and abroad (US mainly).

During this time I gained tons of experience in knowing what works and what doesn’t, this may be specific to me, but I don’t think so, so I decided to share this knowledge. So… what am I doing to keep productive during the day?

Pomodoro

The pomodoro technique I am using is simple, I have a small application running on my Mac constantly (there’s windows versions as well).

When I start work, I simply choose start pomodoro, input what I am going to work on and dive in.

Now, all that’s pretty standard, but I am using it with get-shit-done, so once I start a pomodoro, get-shit-done executes work mode.

This work mode shuts down all outer traffic to time-sinks like Facebook, Twitter, news sites, YouTube and many more.

The script is customizable so I keep changing what I want/need. Along side with shutting down the time sinks, I execute a “busy” mode on Skype and any IM I am using at the moment. This is completely automatic, you can see it in the following screenshots

Pomodoro scripts
IM status change by Pomodoro

As you can see, any pomodoro I do is going into “Things” which I can then look at my day and see where my time went, what did I accomplish during the day and so on (it has OmniFocus integration as well).

If you want to get the app, you can get it here

Stay Hydrated

This may seem stupid so up high here, but it’s REALLY important. I found that in days where I drink and stay hydrated, I am much more productive, less tired and get a lot more done during the day.

Water break

Another benefit is that I need to visit the restroom quite often :) so I don’t slack around in the chair too much. I use an application for that as well, it sits in my top bar and reminds me to take 5 minute water breaks every hour. if you are wired in, you can just ignore that, but don’t ignore it too much, it’s not the point :-)

If you want to get the app, you can get it here

Things To Do

Things To Do

I open every day with a “things to do” list.

I write down anything I need to do, and then I forget about it, I don’t keep my mind occupied with all I need to do, I look at the list during the day.

One important thing is that I set times for stuff

  • 1-2pm => working on the cashier module
  • 2:30-3:30pm => working on the master/slave @dirty variable

While of course, these 2 tasks don’t actually take an hour, it’s here just for an example :-).

Anything you need to remember during the day, write it down, than simply let it go, don’t keep you mind occupied about that.

I keep any blog post idea, stuff that come to mind on other project that are not currently in work order and more…

Knowing I have it written down saves me the trouble of having it in my brain, and I dedicate all my brain resources (which are slim to begin with) dedicated to my code.

I must say, I have tried any TODO app out there, the one that works best for me is a pen and a paper, I use Things as a history for my pomodoros and nothing more (usually)

TDD

Another possible controversial title in a “be productive” blog post :-)

When I am TDD’ing my mind goes into a “small piece” mode, I think only about the next 2-3 steps in what I need to accomplish.

People (wrongly) think that TDD is time consuming and they get less done, I have proven it numerous times in the past that this is incorrect, people that TDD are often 2-3X more productive then others.

Just think about every time you open a browser to “test” something, it can be done in TDD while you save your file, and you can instantly see if you broke something else in the code you are not thinking about.

The right side code is test, left side is actual controller code :-)

TDD your ass off

When you are not productive…

There are simply days when you are not productive on the actual things you need to get done, in these days I don’t try and force myself into it, I simply move to other exciting stuff for 20-30 minutes (sometimes more)

I do a TON of open source, I help people in groups, forums etc..

Sometimes, answering a question, gets me back into code mode and I can find myself wired in for 2-3 hours after it.

To sum up

I touched but a fraction of my work methodology.

The thing is, you need to find YOUR groove, you need to find your pace, the hours where you are productive, the things that excite you.

You may take some of what I said here, you may take all and you may take nothing, all I am saying is that regardless of where/how you work in the team, you can have your own thing going on.

You may work with Pivotal Tracker or Trajectory, but still maintain your TODO list for the next few hours (like I do).

Share your thoughts…

I would love to hear what you think in the comments and have a discussion.

Better simple_format for Rails 3.X projects

Since Rails 3.0 came out, we Rails devs deal with the auto escaping of HTML.

Now, in most cases it comes in SUPER handy, but not always.

Rails has an answer to that, it’s called ‘simple_format’, and it escapes the HTML and formats the string to be friendly, with line breaks, etc…

Now, the problem with simple_format is that it wraps everything with a paragraph tag, which doens’t always fit your design, your markup or just your sense of aesthetics.

So, I wrote a REALLY simple helper, not even going to explain it because it is so simple

[ruby]
def simple_format_no_tags(text, html_options = {}, options = {})
text = ” if text.nil?
text = smart_truncate(text, options[:truncate]) if options[:truncate].present?
text = sanitize(text) unless options[:sanitize] == false
text = text.to_str
text.gsub!(/\r\n?/, "\n") # \r\n and \r -> \n
text.gsub!(/([^\n]\n)(?=[^\n])/, ‘\1<br />’) # 1 newline -> br
text.html_safe
end
[/ruby]

As you can see, it does not wrap with any tag, also it adds an option to truncate the string.

403 Error when using passenger for rails deployment

passenger-e1298322115303
I have been using passenger for local Rails deployment for about 6 months now. I love the flexibility of not having to run Rails server, which enables me to work with sub domains and all kinds of other good stuff.

Lately, about a month back I started using my good friend and co-worker @elado‘s tip of putting all of my codebase on Dropbox.
Here’s a link to his post.

The most amazing thing about it is that you get constant backup with each save, and yeah, don’t get smart on me, I use GIT of course.

Now, since I did that, I kept getting all kind of strange 403 errors from passenger telling me that I can’t pull the favicon.ico file and all sorts of nasty voodoo bugs like that.

I went into the access logs an figured out the problem. The problem was that Dropbox was not properly configured with all the permissions that Apache (passenger) needs.

So, I added these lines of code which solved my problem.

[xml]
<directory "/users/avitzurel/dropbox">
Order allow,deny
Allow from all
</directory>
[/xml]

The file (for me) sits in:

[shell]
/private/etc/apache2/httpd.conf
[/shell]

After you do that, don’t forget to restart Apache for it to pick up the changes in the file.

[shell]
sudo apachectl -k restart
[/shell]

Good luck!

gitignore template for a Ruby on Rail project

Been working with Ruby On Rails for about 10 months now, about the same amount of time with GIT, I enjoy them both very much.

When I start a rails project and connect it to GIT, I always create the same gitignore file. Therefore, I thought I should share it with you.

Here it is:

[shell]
log/*
tmp/*
.DS_Store
db/*
[/shell]

Enjoy!

Empty dialogs in flex builder 3 + Flash builder 4

This week I needed to work with My PC on a flex project. I usually stay away of the PC with flex projects, I’m used to working on the mac with these project, but I needed to work on the PC.

While trying to configure the project in flex builder 3 (and with 4 as well), I stumbled upon a weird bug that made me scratch my head for a while.  The bug was that all of the dialogs appeared empty, no configuration, almost no buttons.

Here’s a screenshot of the problem:

Now, I remembered a teammate I had a while back that had the same problem and it appeared to be a WACOM with a windows 7 driver that caused the problem, so I started disabling devices one after the other.

The problem was a logitech mouse software I have installed on the pc. Once I quited this application everything went back to normal.

Here’s the icon on the taskbar (not hard to trace).

Hope this post helps you and you won’t scratch your had for hours like I did.