Archive for January, 2008

Multiple File Upload with Ruby on Rails and file_column

Monday, January 21st, 2008

I just found a multiple file upload script here, and a rewrite for the use with the nice file_column plugin. There was a conflict with the mootools not playing well with prototype used by default in every Ruby on Rails application. So I’ve done a rewrite of the first version of this script. Of course there are other (newer) file upload plugins like attachment_fu, but they do not have the functionality I need. Generally they should work with this solution, too.
Here is the demo (browse for an image):

In your controller you just have to parse each param:

  params[:previews].each do |preview|
    Preview.create(:filename => preview[1]) if !preview[1].blank?
  end

That’s it! Grab the script here!

It’s the little things I like about Linux

Tuesday, January 8th, 2008

Today I wrote some handy syncronization-scripts with the help of my freebsd-loving co-worker Marius. Till today I managed the syncronization of my local database with our production database with the help of phpMyAdmin.
An export of the 13mb sql file at the production server and an import at my machine took me at least five minutes (~2mb gzipped). Now take a look at this:

[hans@zommuntu:~]$ time ssh user@production_server "mysqldump --add-drop-table database_to_process -uUSER -pPASSWORD | gzip" | gunzip | mysql -uLOCALUSER -pLOCALPASSWORD database_name
real    0m4.389s
user    0m0.592s
sys     0m0.052s

Under five seconds! woot!!
Some words to explain this: First, you establish a ssh connection to the production_server. The gzipped dumped sql of the beloved database_to_process is transferred to your machine. Here it is gunzipped and written to your local database server into the database_name. The quotes are necessary as brackets to let the script know that the gzip command belongs to the ssh command.

Warum gibt’s hier kein tolles Design?

Monday, January 7th, 2008

Das wurde ich gerade gefragt. Nun, die Antwort ist sowohl einfach als auch (für mich) einleuchtend:
Als ich gauda.de das letzte mal ge-relaunched habe (irgendwann Ende 2005) habe ich ein tolles Design gehabt, welches seiner Zeit wohl um einiges voraus war und deshalb im Internet Explorer auch nie richtig funktioniert hat. Man könnte auch sagen, der Internet Explorer ist der Zeit einiges hinterher.
Wie auch immer, habe ich irgendwann den Anschluss an das Eigentliche verloren: Das Bloggen selbst. Ich kann wohl die Einträge an zwei Händen abzählen, die es letztendlich an die Öffentlichkeit geschafft haben.
Diesmal möchte ich den Inhalt in den Vordergrund stellen, eventuell kommt dann irgendwann mal ein Design hinterher. Bis es soweit ist, möchte ich hier erstmal etwas Inhalt produzieren und bis dahin muss ich wohl oder übel mit dem Standard-Wordpress-Design vorlieb nehmen.