Sortable tables with Rails 3 and Twitter Bootstrap 2

As you must know by now, Twitter Bootstrap 2 dropped support for sortable tables with DataTables for an unknown reason. The DataTables team wrote a post to put back sorting of tables but I just didn't like their integration. Here is mine.

I take for granted that you are in your APP roots.

1. Download the latest version of datatables.

2. Extract the files from the zip

3. Copy the minified javascript in your vendor assets : 

cp ~/Downloads/DataTables-1.9.1/media/js/jquery.dataTables.min.js vendor/assets/javascripts/

4. In a global coffeescript file, write this

6. Copy all sorting images in this directory :

cp ~/Downloads/DataTables-1.9.1/media/images/sort_* vendor/assets/images/

6.1 if vendor/assets/images doesn't exist, create it (mkdir vendor/assets/images) and then restart your development server

7. Add the .table-sortable class to every table you want to be sortable

7. Add the .unsortable class to every column you don't want to be sortable

 

 

Node.js on Heroku : "Process bound to port 3000, should be 12345"

I am trying Express on Heroku. I'm still looking for a good environment in node but it seems that it doesn't exist still. I am the kind of guy who likes Rails because I don't have the choice of the stack, I am provided with good defaults that I can override if I want to... but I don't.

After starting the project on Heroku, I had this error :  "Process bound to port 3000, should be 12345". The first number (3000) is your port in development. The second one is the port used by Heroku. By chance, it sets it automatically in the environment. So just run this code :

Dear Ubuntu, I still love you but we're drifting apart

Dear Ubuntu,

when I say "dear" I really mean it. I'm a user since about 2007. I went through six updates without a complete reinstall once. My system got faster with (almost) every update and it is quite a feat. I remember the old days when I had to wipe my hard drive and reinstall Windows every six months because it decayed day by day. I never went through a major update without beginning anew. I never installed SP2, I was too scared of the consequences.

A couple of weeks ago, I trusted you and I trusted that guy (yeah, that guy who wrote the article about how unity is now great) and clicked the upgrade button. The first days, I didn't enjoy my experience with unity but I tried to stay relax and convinced myself that it would be great once I'm accustomed to it. Everyday, I grew angrier about the UI and the last even that made me blow a fuse when I wanted to drag and drop files from my desktop to gmail but couldn't. I could see the guys from unity having a discussion : "hey, who is using that obscure feature called drag&drop? Let's just keep the drag and drop the drop". 

I did what a lot of people did and installed a package to get back to gnome. I booted gnome3 and got ready to go. It lasted 5 minutes and I hated it more than unity. 

I rebooted the "gnome classic" just as I did when WinXP got out and I had to change the theme to "windows classic". I was deceived, really deceived. I didn't notice it before but gnome2 looks old and no compiz effect can bring back its youthful days. After working a couple of weeks with unity, gnome2 is equivalent to windows classic.

Unity is an incomplete step forward and gnome is a step backward. I ask you dear Ubuntu, where should I go now? 

Ubuntu 11.10, Unity and gEdit (SnapOpen and other plugins not working)

Last weekend, I installed Ubuntu 11.10 and as most people, I'm dissatisfied with it. Mostly because Unity breaks my old ways of working. But, I'm a good guy and I will give Ubuntu a chance (even if behind its back, I'm looking for a replacement).

gEdit3
Ubuntu Oneiric Ocelot now ships with gEdit3 which breaks most of the plugins including SnapOpen, QuickOpen or the Python Console. 

The plugins moved from ~/.gnome2/gedit/plugins to ~/.local/share/gedit/plugins/. My first thought was to move all my plugins to that directory... but it did not work. Most of the plugins were written for gEdit2 and it looks quite incompatible.

The only plugin I really have to have is SnapOpen. It was "replaced" by QuickOpen but I can't work with it. It just doesn't find the file I wish to open and I don't want to spend time understanding why. SnapOpen founds it and it just works.

The last commit of the original SnapOpen was in november 2008. A completely new one was created more recently and is still maintained. The problem is that the new one is not (yet) compatible with Ubuntu 11.10. So WhiteThunder wrote a patch to make it compatible. There was a patch in another repository but now it is merged so I updated the post and the Gist.

Install SnapOpen on Ubuntu 11.10 and gEdit3

Assets problems with Heroku and Rails 3.1

I'm playing with Heroku right now and I'm having some problems with the assets.

ActionView::Template::Error (application.css isn't precompiled)

ActionView::Template::Error (Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
in /app/app/assets/javascripts/machines.js.coffee))

What happened is that I created a Heroku stack without cedar, which was created by Heroku to run Rails 3.1 apps. So what I had to do is create another Heroku stack and change the URL of my repository. 

Revenue Sharing : A new type of open source license

I use and write open source but there's a gap in open source licensing, I don't make money out of it!

I do a living writing proprietary code in my own business and I always feel guilty when working on open source because I doesn't help me getting financially free. As most developers, I do it on my free times and this situation doesn't help the quality of the code I'm writing. I am more prone to take shortcuts because of the limited time I put on this. I want this to change...

GPL licenses are reknown for being too restrictive. If I understand them well, they are spreading like a virus in your projects so you can't use something GPL unless you also apply on GPL all your codebase. MIT, BSD and WTFPL are too loose, someone can take your code, include it in his work and make a load of money out of it while you keep a job you (probably) hate and continue to write open source at night.

Revenue sharing
Let's be realistic, 95% of all apps don't make money. It would be useless to charge a flat fee for an open source library in that context because it would just ensure that your code would never be used. Who wants to pay for something when the project in which it is used doesn't make money?

That's why a license that claims "You agree to give me 1% of the revenues from this project" would make sense. The percentage could be dealt between the parties and someone could release his work with a different percentage but the basic idea is this : if you make money with my code, I make money from it too.

There are lots of other things that should be included in a license of that type and it would be based solely on honor and openness. But if it would help open source developers make a better living, it would be a step in the right direction.

Find in all files with Linux/Ubuntu

I don't really like all Microsoft's development IDE but there's a functionality that I really love and use : find in all files (ctrl+shift+F). I always forget about the syntax of grep on linux so I made a little bash to help me. Here is the code :