Archive for the ‘programming’ Category

Life saving keyboard shortcut in Eclipse

Friday, March 6th, 2009

A look at the Window > Navigation menu reveals a number of ways to quickly navigate between the various views, editors, perspectives, and menus in the workbench. These commands have keyword accelerators such as Ctrl+F6 for switching between editors, Ctrl+F7 for switching between views, Ctrl+F8 for switching between perspectives, and F12 for activating the editor.

To directly navigate to a particular view you can define a keyboard shortcut to a view via the General > Keys

Help – Eclipse SDK

I have since I made the switch from IntelliJ IDEA to Eclipse longed for a shortcut to move the focus directly to the Project Explorer. Now I’ve found it!

Just go to Preferences > General > Keys and search for ‘project explorer’. Select the ‘Show View (View: Project Explorer)’ alternative and assign a binding for it. I used alt+<, which is easy to press with the left hand.

Now you can enjoy instant access to the Project Explorer from anywhere.

Default sorting the Dojo DataGrid

Tuesday, March 3rd, 2009

This is how I have configure default sorting for our grids:

dojo.declare("DefaultSortableGrid", dojox.grid.DataGrid, {
    sortInfo: 1 // the index (1-based) of the column 
                // to sort, + => asc, - => desc
});

And then I use DefaultSortableGrid when defining the grid:

<div dojoType="DefaultSortableGrid"
    id="grid"
    rowsPerPage="50">
</div>

Pretty simple really.

Verify your work with checklists – (37signals)

Friday, January 30th, 2009

WHO has recently shown that surgical deaths can be reduced by a third when hospitals follow their Surgical Safety Checklist. The checklist is very low tech. It includes questions like whether the patient has been properly identified, whether the proper tools are available, and whether everyone knows what kind of procedure is about to be done.

If a checklist so simple can save so many lives, I thought the technique could surely help us do better as well. So after reading about this study and their checklist, I’ve been pushing us to create checklists for all the common procedures at 37signals.

via Verify your work with checklists – (37signals).

It’s funny. This is one of those things you know you should be doing, you might even have thought that we should do this, but you never get around to actually creating those checklists.

Rails And Merb Merge

Tuesday, December 23rd, 2008
On to the news: beginning today, the Merb team will be working with the Rails core team on a joint project. The plan is to merge in the things that made Merb different. This will make it possible to use Rails 3 for the same sorts of use-cases that were compelling for Merb users. Effectively, Merb 2 is Rails 3.

Katz Got Your Tongue? » Rails and Merb Merge.

Great news!

It-juristen: “Bäst kvalitet på stängd kod”

Thursday, November 13th, 2008

Detta går att läsa i en artikel i gårdagens Computer Sweden och den finns även att njuta av online.

För att inte nämna hur absurt det är att kalla en en advokat på en advokatfirma som arbetar som rådgivare åt svenska it-företag för expert. Baserat på hennes uttalande så är jag dessutom tveksam till om hon egentligen vet vad öppen källkod är.

– Det krävs en morot för att man ska anstränga sig ordentligt. Om den stora inkomstkällan står och faller med kvaliteten på koden tror jag att man anstränger sig mer, säger hon.

Det är väl snarare så att det är lättare att ta genvägar och små fuska för att korta time-to-market på bekostnad av kvaliteten då man vet att kunden inte kommer att se vad man har gjort.

I ett öppet källkods projekt så bygger allting på den respekt bland resten av utvecklarna man får genom att skriva bra, genomtänkt och fungerande kod. Den respekten försvinner snabbt om man börjar ta onödiga genvägar och slarva. Att man skickar in ett bidrag till ett projekt med sitt eget namn för oftast allmän beskådan av hela internet gör att man ser till att det är bra.

Artikeln avslutas med detta guldkorn ifrån Johan Tömmervik, cio på Volvo Cars.

Vad är det ni tvekar om med supporten? – Om de som utvecklar ett öppet program avbryter sitt arbete med det kan det bli problem. – Om ett företag som utvecklar stängda program går i konkurs brukar det finnas någon som köper rättigheterna till programmet och tar över supporten.

Så istället för att företagets egna utvecklare fortsätta att underhålla ett öppet program utifall alla dess utvecklare ledsnat, så är det bättre att sätta sitt hopp till att det konkursade företaget ska bli uppköpt av någon som ämnar driva det vidare.

Det låter helt vanvettigt.

How to use git plugins in your subversion rails project

Thursday, August 28th, 2008

If you like me still use subversion for your own rails projects but you want to use all the latest and coolest rails plugins that are hosted in a git repository you need to do as follows.

Start with installing git. If you use OS X you can download an installer here.

After you’ve done that use the following line to clone the remote git repository in your local vendor/plugins directory.

git clone --depth 1 git://github.com/fauna/has_many_polymorphs.git vendor/plugins/has_many_polymorphs

Change the address to the git repository and the name of the directory under vendor/plugins to fit your needs. In the above example I got the has_many_polymorphs plugin from github.

The checked out directory can then be added to your subversion repository like all other files. If you later want to update the plugin all you have to do is enter the directory and execute.

git pull

This ‘Using Git like svn:externals’ article helped me figure this out.

The Ruby on Rails I18n core api

Wednesday, July 23rd, 2008
Future versions of Rails will ship with a minimalistic, yet powerful I18n/L10n api baked in.
The following post is about technical api and implementation details. You can read more about the motivation and reasoning behind this work here.

The Ruby on Rails I18n core api – artweb design .

The Greatest Bug of All

Tuesday, July 8th, 2008
Software is written by humans. Humans get tired. Humans become discouraged. They aren’t perfect beings. As developers, we want to pretend this isn’t so, that our software springs from our head whole and immaculate like the goddess Athena. Customers don’t want to hear us admit that we fail.

So true. Luckily for us developers a week is more than Monday morning and Friday afternoon…

Call Me Fishmeal.: Pimp My Code, Part 15: The Greatest Bug of All

via Daring Fireball

How to copy production database data to the development database with Capistrano

Friday, June 27th, 2008

At times it is useful to easily be able to copy the content of the production database to the database running on your local development machine. In my case I use mysql on the production server and sqlite on my MacBook Pro. Unfortunately the use of different database servers makes this task a bit more tricky.

With a bit of googling I found a bit of code here and there which I combined and modified and turned into the following snippet of code to be dropped into your Capistrano deploy.rb file.

desc "Copy production database to development database" task :update_dev_db, :roles => :db do db = YAML::load(ERB.new(IO.read(File.join(File.dirname(FILE), 'database.yml'))).result)['production']

filename = "#{db['database']}_dump.#{Time.now.strftime '%Y%m%dT%:%H%M%S'}.sql" remote_path = "#{current_path}/tmp/#{filename}" local_path = "tmp/#{filename}"

on_rollback { run "rm #{remote_path}" }

run "mysqldump -u #{db['username']} --password=#{db['password']} --skip-opt #{db['database']} --complete-insert=true --skip-quote-names --no-create-info > #{remote_path}" do |ch, stream, data| puts data end

get remote_path, local_path

converted = File.read(local_path).gsub(/\'/, '\'\'') File.open("#{local_path}_converted", 'w') {|f| f.write(converted)}

system "sqlite3 db/dev.db < #{local_path}_converted" system "rm #{local_path}" system "rm #{local_path}_converted" run "rm #{remote_path}" end

There is a small problem with \n (new line) characters that on the production server get evaluated as they should. However, on the development machine after the data has been exported from mysql and imported into the sqlite database the \n characters will show as \n on the screen. But for me this is good enough for now.

Free Rails 2.1 Book

Wednesday, June 11th, 2008
If you’re eager to learn how to use all the new features in Rails 2.1, Carlos Brando just released a free book titled Ruby on Rails 2.1, What’s New?.

Free Rails 2.1 Book