Ruby On Rails, Design, Simplicity, Web 2.0, Ajax, Mac and Tons of Pizza.

Aug 20

The best recipe for creating a profitable web app in a 2.0 era

Posted by Massimo Sgrelli in Got Things Done - Ruby on Rails - no comments digg this add to delicious

We, as many other startups, are keep doing ourself the same question: which is the best recipe to create a profitable web app nowadays?

It’s a tough question. I think a good web app, something making money, has many simple characteristics. One of the best and also funny video I found on the Net, talking about this, is the speech that David Heinemeier Hansson gave to the last Start Up School 08 (watch it after having read this article)

<div><a href='http://www.omnisio.com'>Share and annotate your videos</a> with Omnisio!</div>

In short, David recipe to create a (Internet) profitable company:

  • Make a product, price it and sell it!
    It has been working in this way from time immemorial, so don’t think that the web is different. It’s not. The best way to see if you really have something groovy to sell, is make it and trying to sell it
  • Don’t try to set up 1 billion company! The odds are against you.
    He’s right, between your current income (typically below 100k a year) and 1 billion dollars, there are a wide range of acceptable revenues. One million company is definitely a good target (isn’t it?), a target you can probably manage without anyone financing you (no VC). BTW… making one million a year is not simple, definitely not easy, but it’s immensely much simpler, than try to making 1 billion a year.
  • Target: business is better than consumer.
    Convincing consumers to spend their money is not so easy, even if your application is useful and well designed. Companies, on the other side, are always looking for tools or services enabling cost cutting or easy management or knowledge management or what so ever. So try with them first.
  • Keep it simple.
    This is a mantra for all of us and Rails helps us a lot following this direction. It’s fundamental that people could understand quickly why they need you.

I’d like to integrate David recipe with some small ingredients of mine:

  • Your product must have a barrier to the entrance.
    I don’t know if this is the right term in English, but I mean you must avoid that someone can copy you in a fraction of a second. The elements part of your barrier can be many: good design, idea, time to market, technology, smartness (why not?), etc. And there’s a postulate to this theorem…
  • (postulate) Whatever your barrier is, remember that it won’t last forever.
    Feed your idea day by day.
  • The fact that you caught a good product once, it doesn’t mean you are like Mida king.
    Every time is a new challenge; no one will buy your product because of your once famous hit.
  • Making a good product is an art.
    It requires time and patience. If you don’t earn 50,000 dollars the first day you’re out, don’t be too angry. Pace yourself and wait. In the meantime think about how to improve it.
  • Ask yourself: would I spend 50 bucks a month to buy my product?
    It’s better to ask you this question before start coding. In any case, it’s important to repeat it every time your expectations are above your results. BTW, if you are not using what you’ve built, then probably it’s not so useful, aren’t you?
    Don’t be so sever with you. Even Evan William who built Blogger.com forgot this truth when he founded Odeo. Then he understood and created Twitter
Aug 15

Use MacVim and rails.vim plugin to edit your Rails work

Posted by Massimo Sgrelli in Ruby on Rails - 6 comments digg this add to delicious

A couple of years ago I bought a copy of TextMate, the preferred and “exclusive” text editor of Ruby on Rails community. Two years ago I was a newcomer to Ruby language and Rails framework and TextMate helped me to enter quickly in this marvelous world. Coming back to then I chose this editor because on Rails official web site there weren’t others good suggested tools.

NOTE THIS: actually checking on the site, a few things are really changed. I read, “The entire Rails core team is using TextMate on Mac OS X. It’s a fantastic editor that ships with Ruby on Rails highlighting and macros”. I know it’s not true (Jeremy Kemper must is actually using a different tool).... is it some kind of hidden advertising?

In any case the Macromates product is definitely a good one, but soon I felt I needed something different, something I could suggest to my colleagues, to my friends, without force them to invest 30 bucks or so. I needed something like vi... vi?

Now vi has been replaced by vim.
VIM (an improved version of vi) is already installed on OSX or on Ubuntu and it’s free. But to be used as my preferred Ruby and Rails text editor I needed it could manage 2 things:

  • some sort of integration with Rails (how?)
  • syntax coloring TextMate-like (yeah, I like it)

No problem: the first issue has been trivial. You need to download rails.vim and extract the zip file to ~/.vim directory. This completes the installation :)

For the second issue wanted to have IR_Black theme (the theme I’m using under TextMate) on VIM too. This is how it looks like under TextMate:

... and you know what? It actually exists for VIM. Todd Werth, the creator of IR_Black theme for TextMate made it available for the Unix text editor. So I downloaded and put it under ~/.vim/colors directory, I launched vim and…

... this screen showed. From the shell, in the xterm, you have access to 16 ANSI colors only, so forget the full color result. I didn’t know that.

So? No fancy colors under VIM?

The solution is to download MacVim a project under the Google Code site, that easily access all the colors, using all the previous settings already stored under your ”.vim” directory.
The final result is awesome:

Aug 01

Fork with spawn

Posted by Sandro Paganotti in Ruby on Rails - comments are closed digg this add to delicious

During the development of our current project we needed to handle a very long task (4 minutes). After a bit of googling i found spawn by Tom Anderson. Here’s how it works:

Spawn let you fork (or thread) a block of code by simply pass it as a parameter to a ‘spawn’ function:


  spawn do
   # very long long task
  end

what spawn do (when used with ‘fork’) is recreate an ActiveRecord Connection inside a fork method and then execute your block of code. You can also set the priority of the process being create with the option ‘nice’:


  spawn(:nice => 7) do
    # do something
  end

Finally you can wait the end or your child processes with the method Spawn::wait() (I took this example from the official readme):


  N.times do |i|
    # spawn N blocks of code
    spawn_ids[i] = spawn do
      something(i)
    end
  end
  # wait for all N blocks of code to finish running
  wait(spawn_ids)

I haven’t tried to use spawn with threads but as far as I’ve tested it with fork, it works perfectly.

Jul 25

Anagrams with Ruby

Posted by Sandro Paganotti in Ruby on Rails - 3 comments digg this add to delicious

In my spare time I enjoy myself trying to figure out solutions to well-known problems without searching the web nor using third party libraries. It’s just a sort of challenge to keep my coding skills well trained.

Yesterday I challenged myself trying to find the faster way to get all the combination of the letters of a given word (excluding duplicates).


example:  "ruby" --> 
["ruby", "ruyb", "rbuy", "rbyu", "ryub", "rybu", "urby", "uryb", "ubry", "ubyr", "uyrb", "uybr", "bruy", "bryu", "bury", "buyr", "byru", "byur", "yrub", "yrbu", "yurb", "yubr", "ybru", "ybur"]   

My code uses recursion to accomplish the task and is not able to identify at run time duplicates so it’s really far from perfection. I’m going to post it here:


class String
  def anagram
    chars_size = (chars = self.split('')).size
    return chars if chars_size == 1
    return [chars,chars.reverse] if chars_size == 2
    ret = []; chars.each do |c| 
      (temp = chars.clone).delete_at(chars.index(c));
      ret += temp.to_s.anagram.collect{|a| "#{c}#{a}" } 
    end    
    return ret.uniq
  end
end

If you want to share a better solution please use the comment form below to link your code (you can use Pastie) or just to suggest changes.

Sandro

Jul 04

A new CheckBox component in Streamlined

Posted by Sandro Paganotti in Ruby on Rails - comments are closed digg this add to delicious

I’ve noticed that Streamlined when display has_and_belongs_to_many or has_many relationships in an edit view calls ‘Streamlined::Components::Select’ (lib/streamlined/column/association.rb line 123). That class simply render a ‘select’ tag with multiple choices.

I created a new component that can be called instead the standard one. It’s called CheckBox and it displays, as the name may suggest, a checkbox for each choice available.

To add this component simply create a new file under ‘lib/streamlined/components’ called ‘checkbox.rb’ and paste the same content of ‘select.rb’ except these two changes:


    # line 15
    class CheckBox
    REQUIRED_ATTRS = [:view, :object, :method, :choices, :item]

    # Substitute the render method with this 
    def render
      ids = item.send(Inflector.pluralize(method.to_s)).collect{|b| b.id}
      name = "#{object}[#{method}][]" 
      choices.collect do |c| 
        view.check_box_tag(name,c[1],ids.include?(c[1])) + "#{c[0]}" 
      end.join("<br/>") + view.hidden_field_tag(name, STREAMLINED_SELECT_NONE)
   end

Remeber also to include this new file (from lib/streamlined/components.rb) and change the line 123 in association.rb to call this new component:


      result = Streamlined::Components::CheckBox.render do |s|
        s.view = view
        s.object = model_underscore
        s.method = name
        s.choices = choices
        s.options = {:selected => selected_choices }
        s.html_options = {:size => 5, :multiple => true}
        s.item = item
      end

Sandro

Jul 01

Ruby on Rails & Maths...

Posted by Annalisa Afeltra in Ruby on Rails - comments are closed digg this add to delicious

I have always been fascinated with Mathematics and how you can solve problems using it, we all know that in programming it is very useful. I recently had to use maths in a layout that I needed to incorporate for a new application…

Problem:

I had to display a dynamic list of suburbs in a table, that was an x amount of rows and had 3 columns.

Solution:

I used Mod (the mathematical arithmetic that gives you the remainder of the division).

Therefore:


<table>
<% r = 0 %>
<% @count_suburb.each do |c| %>
<% area = Area.find_by_code(c[0])%>

<% if ((r % 3) == 0)  %>
<tr>
<% end %>
<% r += 1%>

<td>Write something here....<%= c.name.capitalize  %></td>

<% if ((r % 3) == 0)  %>
</tr>    
<% end %>

<% end %>
</table>

Does anyone know of a better solution?

Thanks Annalisa

Jun 27

Advanced statements with Ruby

Posted by Sandro Paganotti in Ruby on Rails - comments are closed digg this add to delicious

Yesterday I was playing with statements trying to find out an elegant way to solve a problem:

The problem

While reading from an Excel file (using the Parseexcel gem) I needed to get a value from the 3rd column or from the 2nd (if the third is empty). Plus I had to execute an additional operation only if the value I got came from the second column. ( value / 100 )

The Solution

Parseexcel lets you scan your Excel worksheet by rows. Each row makes its value available through the ‘at(pos)’ method where pos is the index of the column (starting from 0). This is the solution I come across:


worksheet.each(3) do |row| 
        break if ((value=row.at(2)).nil? and (div=true;value=row.at(1)).nil?)
        value = value.to_i / 100 if div
        # other code ...
end

Conclusion

By using this trick I was able to detect when the assignment come from the second or the third column (remember that when the first condition in an ‘and’ clause isn’t met the interpreter doesn’t execute the second, thus div remains nil if row.at(2) is not nil).

Hope this could help. Sandro

Jun 23

Web design is about designing

Posted by Massimo Sgrelli in Design - Web 2.0 - 2 comments digg this add to delicious

It seems pretty obvious, but it isn’t. I assure you that.
I’ve just read Amy Hoy article “Design is not about solving problems” on Slash7 and I agree with her. She focused on the proactive role in designing, blaming the reactive role that design could have. Design is not about solving problems.

But I’d like to go further, remarking the obvious: design is about designing. Understanding the domain language (as recalled by Ryan Singer ), sketching the whole project down, positioning objects on a surface to fulfill the need and then build a mock-up. That is design. Web design makes no objections to this rule, but for sure it adds some constraints to the general process: the format. If a web designer builds up the complete idea of a project, without worrying about the final format of his work, he will probably have to plan a big rework. That project must be implemented by a software developer, so the format of the designer’s final object is fundamental.

Too often people speak different languages:

They simply don’t fit and sometimes tools don’t help a lot. This is why the big challenge is to forget about Photoshop and start promoting tools closer to the bare HTML.

HTML is composed by simple shapes. You can easily draw a rectangle, a square, color them, even blur the background. And again, set the font family, the boldness. Adding some AJAX you can get awesome effects… in a simple way. They are good and easily implemented, but you must study the fundamental of web development, the fundamental of browser rendering dialect.

People can keep basing their design work on tools like Photoshop, but they have to keep in mind that software developers will need user interface design objects in bare HTML/CSS format

If you are use to apply your work through a specific set of tools, it’s very difficult to change your habits in a short time. To train myself in this way I change the tools I use quite often, but of course I have my favorite tools too. At the moment I love using office tools like Keynote or PowerPoint to design web applications. They help you draw simple shapes and words quickly, and they avoid you to design hard things to implement.

In any case, independently from the tools I like to use, I’ve learned to sketch my ideas on paper first. That’s absolutely faster and cheaper than any software tool on earth.
I make a drawing and then I take a picture of it with my (i)phone to record it on WhoDoes. The drawing phase starts days later.

Jun 20

Streamlined 1.0 hacks: add help text to forms.

Posted by Sandro Paganotti in Ruby on Rails - 1 comment digg this add to delicious

I’ve created a small Streamlined hack that let you implement a :help option while defining ‘user columns’, here’s a sample:


                :title,                 {
                                          :human_name   => "Book title",
                                          :help         => "Please specify the title of the book you're reading." 
                                        }

and this is the result (for ‘edit’ and ‘new’ views):

Instructions:

Here you’ll find what to change in the plugin:


#  in /lib/streamlined/column/base.rb 

# around line 9
attr_accessor :human_name, :link_to, :popup, :parent_model, :wrapper, :additional_column_pairs,
                :additional_includes, :filter_column, :help

# around line 196
      x.td(:class => 'sl_edit_value') do
        x << render_td(view, item)
        if(!help.nil?)
          x.p{ x << help }
        end  
      end 

Hope you’ll find useful.

Sandro

Jun 13

In/Out by 37signals

Posted by Massimo Sgrelli in News - Web 2.0 - comments are closed digg this add to delicious

In/Out is an internal application by 37signals first sited by Jason Fried 2 months ago. They implemented it to keep in touch with each other during the workday without useless interruptions:

In/Out is based on a simple need. People working together, on the same team or the same project, that sometimes need to know what each person is doing during the day.

What are you working on? When someone asks you this question it interrupts you and if 3, 4 or 5 people ask the same question during the day, it’s better that you take the day off.

In/Out helps to solve this problem efficiently. Each person in the team can use this tool to notify their actual status to others, and at the same time they can add log entries just describing what they have just accomplished.

The main page – and I suppose the only one – of this application allows you to see on the left side what has been finished by everyone during the day, while on the right side every worker can see each others status and the list of what they’ve already finished:

It’s probably one of the most innovative and simple tools that I’ve ever seen.

There’s only one thing that I cannot understand. Why they don’t release it as a stand alone product? I think it could be a major hit. Of course making something similar is not hard for anyone – so it cannot be considered a real asset for 37signals. Actually they only released it as part of Backpack.

But having conceived something so simple and at the same time so useful is really impressive. It’s like having designed the first non-Twitter application for the business, using the same fundamental principle of “simply useful” – I’ll get back on this concept again in future articles.

There’s only a subtle doubt I have. What if they decided not to release it stand alone to avoid cannibalizing their golden egg, Basecamp?
Mmmmhhhh…

If I was Jason Fried I would be studying a smart way to release it as a stand alone application and at the same time, have it integrated as a “module” of Basecamp – like they have already done with Writeboard.

For those of you that want to have some details there’s a short video describing this application at work – now renamed as Backpack Journal:


References:
- A peek at In/Out an internal app at 37signals
- Launch: the Backpack Journal
Jun 11

A free book about Rails 2.1

Posted by Massimo Sgrelli in Ruby on Rails - no comments digg this add to delicious

“A gift from all Brazilian Railers to the international community”.

This is how Carlos Brando presented the release of a free book about Ruby on Rails 2.1 that he and Marcos Tapajós just released on the Internet.

The book has been translated from Portuguese thanks to the aim of the Brazilian Rails community in general, and in particular with the effort of Rafael Barbosa, Caike Souza, Pedro Pimentel, Abraão Coelho and Ricardo S Yasuda.

Thanks guys.

Jun 10

Is DHH planning to step back?

Posted by Massimo Sgrelli in Ruby on Rails - 7 comments digg this add to delicious

I’ve been to Portland to the RailsConf 2008 and everything has been quite great. Great venue, a lot of people and good food too – and that was really a surprise :)

There’s only one thing that left me a bit confused: “David Heinemeier Hansson”. I mean, he’s a great speaker and hacker too, but this year he didn’t make any technical speeches at the conference. He left that role to Jeremy Kemper, who is for sure a wizard inside the Ruby on Rails community, but… he’s not David of course.

David has a unique role in the Rails community, and right now the Rails future and success is definitely tied to him. The community needs a leader and a mentor, and David is the man.

But what will happen if he stops having a technical leading role in Ruby on Rails?
That could really be a bad strike for all of us. The framework is too young and it’s still gaining a dominant position in the technology landscape. It needs its creator more than ever.

A second “bad” sign I picked up on was during the final speech, with all the Rails core team on stage, David did not seem to be completely up-to-date with the actual status of Rails – and Michael Koziarski had to correct him once.

That was not a good thing. Definitely not a good thing.
In the end, just to give us the final shot, he decided that “it could be a good idea” to leave the conference 15 minutes earlier to catch the flight :)

What’s up man?
Does it mean something is changing?
Is he planning to step back from his role?
I hope not, because in that case Ruby on Rails could be threatened very quickly by its competitors, risking to lose its rising star role in the technology landscape.

So David, please stop evangelizing and show us the light. We need you to make some code.

Jun 09

Spread out the good novel

Posted by Massimo Sgrelli in Events - Ruby on Rails - comments are closed digg this add to delicious

RailsConf is over and I was so lucky to be there this year too. GotThingsDone.com presence at the all-important convention about Ruby on Rails has been centered around spreading the good novel” out all over the world. Let me explain you why.

We were pretty impressed last year discovering that quite a few people were covering the event professionally with videos, interviews and keynotes streaming. The most part of the attendees having a blog were summarizing the convention in real time on their web sites and they did a good job, but I soon realized people want to see their heroes, want to hear their voices. Dancan made amazing pictures and he shared them on Flickr, but you know, they cannot speak.

So, this year we decided that Rails is too important to not have any good video interview to show the people who were not as lucky as we were. We wanted to show what a revolution was taking place in Portland.

So, in the last few days preceding the conference the crew at GotThingsDone.com and I planned to interview some of the people we thought are leading the Rails scenario right now. We aren’t professional in producing videos, but we made our best to share the intense moments we had there.

So I’d like to say thank you to the people we interviewed, because they were so patient and kind with us. Thanks to David Heinemeier Hansson, Joel Splosky, Jeremy Kemper, Ola Bini, John Straw, Ryan Singer, Rick Olson, Chris Wanstrath and Geoffrey Grosenbach.

And then thank you to Annalisa, Sandro and Joe for their wonderful job.

At Portland we were about 1,800 people. Right now our interviews have been viewed more than 7,300 times :)

Jun 09

RailsConf 2008 Keynotes now available...

Posted by Annalisa Afeltra in Ruby on Rails - comments are closed digg this add to delicious

David Heinemeier Hansson, Jeremy Kemper, Kent Beck and Joel Spolsky.

If you missed out on the RailsConf 2008 this year or you would just like to have a recap on the Keynotes, you can now view them here.

If you have not yet seen the interviews of DHH, Jeremy Kemper and many more…. please view them here.

Annalisa

Jun 05

Now available: Interviews for your iPhone/iPod

Posted by Annalisa Afeltra in Ruby on Rails - comments are closed digg this add to delicious

As we promised here are the links to download the interviews and view them on your iPhone or your iPod.

David Heinemeier Hannson
Ryan Singer
Jeremy Kemper
Rick Olsen
Ola Bini
Geoffrey Grosenbach
Chris Wanstrath
Joel Spolsky
John Straw

Categories:

Tags:

Powered by Mephisto, Valid XHTML 1.1, Valid CSS - Supported by Wave Factory