No Comments »

If you are wondering about the “deutsche gamestage”-banner placed on this blog: We are going to the Quo Vadis - Die Entwicklerkonferenz next week using the blogger ticket. Precondition: Place the banner and link it to their website. So, see you there?

Deutsche Gamestage

By the way: We are also visiting the Euruko 2009 in May in Barcelona. If not in Berlin at the Quo Vadis, we maybe meet you in Barcelona.

FEtMab-Team
Sebastian

2 Comments »

Quite some time ago I read a book about Groovy and thought a little bit about their shortcut syntax to the collect a.k.a. map method. It looks like this:

  [1, -2, 3, -4, 4]*.abs()

What would be in Ruby

  [1, -2, 3, -4, 4].map {|e| e.abs}

I might be wrong but I think the * operator in Groovy wasn’t there since the beginning and at least in my memories you could call abs directly at the array formerly. Anyway, in the end I really like the way Ruby handles collections - as first class objects like anything else.

But as I sneaked through a Rails project I’m currently working on using script/console I really got sick of typing:

  User.all.map {|u| u.email}

and I recalled the Groovy way of doing this and felt a little bit jealous of the Groovy guys for the first time.

But being jealous of Groovy is a very nasty state of being so I hacked a together a few lines

class MapMethodProxy
  Object.instance_methods.each {|m| eval("undef #{m}") unless m =~ /^__.*__$/}
 
  def initialize(enum)
    @enum = enum
  end
 
  def method_missing(method_name, *params)
    @enum.map {|o| o.send(method_name, *params)}
  end
end
 
class Array
  alias old_map map
  def map(&blck)
    return old_map(&blck) if block_given?
 
    MapMethodProxy.new(self)
  end
end

and now I can just do this:

  [1, -2, 3, -4, 4].map.abs # => [1,2,3,4,4]
  #which is equivalent to
  [1, -2, 3, -4, 4].map {|e| e.abs} # => [1,2,3,4,4]

And in my Rails project I can use it as well:

  User.all.map.email

Cool, this doesn’t lead to ugly anti-oop constructs and just saves me a few keystrokes now and then.

Hopefully you find some usage for this snippet, too.

I’m thankful for any thoughts and comments as I think there could already be a ton of more sophisticated solutions to this somewhere out there (I just can’t find them).

Yours,

Thorben
FEtMab-Team

No Comments »

Lately I wasn’t able to clone any Git repository from GitHub or any other source that I had not created myself. Google unveiled only a few mailing lists and this blog post. They all boil down to some OpenSSL problems with Fink or Darwin Ports on Mac OS X. I followed their instructions but nothing worked for me.

In a last desperate try to get Git back under my control I downloaded the OpenSSL sources, compiled them and specified their path explicitly to the Git configure script. And TADA! Anything works great again.

Here is the error I got beforehand:

localhost:tmp walski$ git clone git://github.com/git/hello-world.git
Initialized empty Git repository in /private/tmp/hello-world/.git/
 
remote: Counting objects: 158, done.
remote: Compressing objects: 100% (79/79), done.
remote: Total 158 (delta 54), reused 157 (delta 54)
Receiving objects: 100% (158/158), 15.62 KiB, done.
fatal: pack is corrupted (SHA1 mismatch)
fatal: index-pack failed

And how I solved it:

cd /tmp
curl http://www.openssl.org/source/openssl-0.9.8j.tar.gz > openssl.tar.gz
tar -xzf openssl.tar.gz
cd openssl-0.9.8j/
./config
make
sudo make install
cd ..
curl http://kernel.org/pub/software/scm/git/git-1.6.1.2.tar.bz2 > git.tar.bz2
tar xjf git.tar.bz2
cd git-1.6.1.2/
./configure --with-openssl=/usr/local/ssl/lib/
make
sudo make install

Have a look at the ./config output of OpenSSL it tells you the path where it installs the library, in my case it is /usr/local/ssl/lib/.

Hope that helps someone out there.

Yours,

Thorben
FEtMab-Team

No Comments »

From time to time I stumble upon some cool and useful Ruby functionality which I think is not so well known among the Ruby users. So I would like to start a loose series of posts to give those neat tidbits, which usually play the second fiddle, some of the love that they deserve.

Starring today: Converting numbers to another base

The Fixnum#to_s method is exactly which does that. You can easily convert a decimal number to a binary or hexadecimal number or any other base from 2 to 36. The Ruby Core RDoc shows us how:

12345.to_s       #=> "12345"
12345.to_s(2)    #=> "11000000111001"
12345.to_s(8)    #=> "30071"
12345.to_s(10)   #=> "12345"
12345.to_s(16)   #=> "3039"
12345.to_s(36)   #=> "9ix"

Cool!

That’s it for today.

Thorben
FEtMab-Team

No Comments »

Hey,

switching to old school editors seems to be fashionable since more and more people in the Rails ecosystem seem to switch back to them.

Personally I’m not one of those guys. My Vim skills are not sufficient and I never really got the spirit of Emacs so I’ll stick with Textmate for another while and I’m very happy with it. But from time to time there is these clunky shell and I’m trying to do anything that’s not worth starting Textmate or I’m working on a remote server and have to stick to the console. During those times I often was a little lost in Vim and other tools and decided to change that. Since that anytime I used one of those nifty CLI tools and editors I googled for some cool shortcuts and for Vi I even bought a tiny book.

These are my top tips until today:

Vim:

  • Cool Window Stuff:
    • Split the Vim window: Ctrl+w s
    • Switch to another splitted window: Ctrl+w UP/DOWN
    • Switch to the next window: Ctrl+w w
    • Close a window: Ctrl+w q
    • Resize a window: Ctrl+w +/-
  • Access a shell from within Vim: :sh (exit with Ctrl+d)
  • Open a file: :e FILENAME
  • Read a file and insert it at the current position: :r FILENAME
  • Delete a line: dd
  • Delete 100 lines: 100dd
  • Search for XYZ: /XYZ
  • Next hit: n
  • Jump to end of file: G
  • Jump to beginning of file: gg
  • Undo: u
  • Copy one/10 line(s): yy / 10yy
  • Paste: p

Less:
It’s really cool: With v less fires up the editor configured in your $EDITOR environment variable and let you edit it’s current buffer within the editor. And with s the buffer gets saved to a file (if you’re invoking less on a file it seems to me that is is always saved back to the original file, even if there is a filename prompt!).

Ok, that’s all I can remember right now. More to come!

Yours,

Thorben
FEtMab-Team

2 Comments »

Lately we’ve been using Dropbox a lot and as a small team we love it! As a few days ago the need for a small staging server arose we decided to give Phusion Passenger a try and setup a very bare bone box with Apache, Passenger, Rails and all the small stuff around such a setup. When we came to the point when I would just start to configure Capistrano a tremendous idea came to our mind: How cool would it be if we could deploy and control our server by just moving things around in our shared Dropbox folders? GREAT! We never miss the chance for an adventure which lays along our path so we got right into it and would like to share what we found out with the rest of the world.

Photo by kellan: http://www.flickr.com/photos/kellan/2422461496/

Photo by kellan: http://www.flickr.com/photos/kellan/2422461496/

For the most impatient folks of you: It works great! We can now deploy an application by just heading to our Dropbox folder with a shell, do a “git pull” and touch the tmp/restart.txt within the deployment! Also can our designers work just within the deployed version. We share the folder with them and they can see any changes to the CSS, views and images instantly online. They don’t have to run a Rails server on their own or bother with any kind of manual connection to the server. They work with files in their favorite file manager all day long and Dropbox integrates like a charm in this “workflow”. In addition to that we’ve built a plugin that let you even run rake tasks on the server and watch their output. But enough now, let’s start!

In a first step we will create a new Rails app and a distributed git repository. And because this article is all about Dropbox it’s just an obvious decision to “host” the repository on the Dropbox. This definitely has some flaws and might not be the right solution for you, so feel free to just use your normal git procedure instead of the described one:

Lets setup our Rails project:

rails myapp
cd myapp
git init

Now we’re following the instructions given by Tim Lucas to ensure that those annoying log files etc are not getting into our git repository. namely:

Create a .gitignore right where you are and add this into it:

log/*.log
tmp/**/*
.DS_Store
doc/api
doc/app

Nearly there. Just don’t forget to create to empty .gitignore files in log/ and tmp/ so that those directories are commited to the respository.

touch log/.gitignore
touch tmp/.gitignore

We’re now finally ready to do add anything into a first commit to the new git repository:

git add *
git commit -m "Initial commit"

The next step: Dropboxfication

To really host your git repository on the Dropbox you have to create a new folder within your Dropbox account and share it with your colleagues or friends who should have access to the repository. Now just clone your freshly created app here in git’s bare mode:

cd ~/Dropbox/your/newly/shared/dropbox/folder
git clone --bare path/to/your/earlier/created/rails/app yourapp.git

You should now throw away the folder where you created your app initially and clone a new version from the repository in the Dropbox to get all those settings right where a git push should be directed to. If you’ve done that create another shared folder in your Dropbox. This is the one where your app is going to be deployed to. So lets say you’ve created ~/Dropbox/your/newly/shared/yourapp-deploy for that purpose.

Now clone the repository there:

git clone ~/Dropbox/your/newly/shared/dropbox/folder ~/Dropbox/your/newly/shared/yourapp-deploy/

Step 3: Setting up the webserver

At the moment Dropox is not intended to be installed on a UNIX system without any X window system. But there is a great tutorial which explains how to do it anyway. So the first thing to do is just follow the tutorial and install the Dropbox client on your server within as a dedicated “dropbox” user (at least we did so). Please also do the last step and create the start/stop script, it’s just a matter of copy&paste the code shown in the tutorial!

At least as important as the Dropbox client on the server is an Apache2 setup with mod_rails. Again the installation process is very well documented. Just head over to the mod_rails website.

If you’ve mastered this, too, let’s take the last step towards your new deployment situation.

Step 4: Getting all the parts together

First we should link the deployment folder in the Dropbox to /var/www.

ln -s ~/Dropbox/your/newly/shared/yourapp-deploy/public /var/www/yourapp

Note that it’s important that you only link the public directory instead of the whole application!

Now let’s add a new virtual host file to Apache. It goes into the sites-available folder of the Apache config which should be located in /etc/apache2. So open /etc/apache2/sites-available/yourapp and let it look like this:

NameVirtualHost *:80

   RailsEnv development
   ServerName dev.yourhost.com
   DocumentRoot /var/www/yourapp/

As you can see the environment your server runs in can be configured. For a whole list of all mod_rails configuration options have a look at it’s documentation.

After you’ve created the virtual host file you need to enable it and it might also be a good idea to restart apache even if this is not allways necessary:

a2ensite yourapp
apache2ctl graceful

Voila, at this time, you should already be able to completely manipulate your application by browsing and editing on any computer that has been invited to the “yourapp-deploy” folder just by altering the files.

Also keep in mind that you can restart the server by touching ‘yourapp-deploy/tmp/restart.txt’.

If you would like to get the newest version out of the git repository ot the server just take any shell you can get, head over to the yourapp-deploy folder and do a

git pull

That’s it! Give Dropbox the time it needs to transfer all the changed files to their server and then add a little extra time which your server needs to get the changes from the Dropbox, again. And if you or a designer or anybody else has changed something directly in the deploy directory just feel free to commit those changes back into the repository:

git add 
git commit -m "A commit directly from the deploy folder"
git push

Pretty simple and pretty clean for a solution that can be used as an “instant online” test bed!

The little extra

This setup seems to be really cool for a small test or staging server. But we felt one urge with it: For any rake operation we need to connect to the server and loose all those benefits the Dropbox integration gave us, namely “the ease of use”. So we wrote a tool which allows you to run rake commands remotely just by echoing the arguments of the rake call into “yourapp-deploy/tmp/rake.txt”.

You can install this tool as a git submodule by executing

cd ~/Dropbox/your/newly/shared/dropbox/folder
git submodule add git://github.com/walski/control_by_files.git vendor/plugins/control_by_files
git submodule init
git submodule update

Now run this script as a cronjob. To accomplish this, get a shell on your server with the Dropbox user and run

crontab -e

now add the following line (IMPORTANT! ONE LINE)

* * * * * cd /home/user we created for dropbox/Dropbox/yourapp-deploy/the-name-of-the-app-itself/ ; export RAILS_ENV=development; ruby vendor/plugins/control_by_files/lib/control_by_files.rb

Your system is now complete! Anything you write to yourapp-deploy/tmp/rake.txt is executed after short amount of time by the server. The output of those rake tasks (you can enter multiple tasks at once! Just one in each line) is written back to the same rake.txt file and it gets marked so that it is not run twice.

That’s it. It’s a lot of stuff so please let us now if you encounter any problems or find any bug in our description.

Thanks a lot for reading and also a huuuuuge thanks to Jan who did nearly all the work to get this setup running and documented.

Enjoy your new super dynamic workspace.

Yours,

Thorben
FEtMab-Team

No Comments »

Hey,

all of you should really have a look at No Kahuna, a very clean and simple task management app for your team. It’s a pleasure to use and so we decided to let our new product connect directly to it in order to handle our user feedback.

To achieve this I contacted Alex of No Kahuna and asked if there is an API or if there are plans to release an API in the near future. Unfortunately there isn’t but it seems that something is in the pipe of the No Kahuna guys. Anyway, we needed the functionality now and so I wrote Neoneo, a ruby No Kahuna wrapper.

In a few words is nothing more than an HTML scraper that interacts with No Kahuna in the same way as you can do with your browser.

At the moment it’s primarily designed to add tasks to your No Kahuna projects but it has some other cool features like reading tasks of a project or editing a project’s name etc, too.
Just install it right away from rubyforge:

sudo gem install neoneo

And then it takes nothing more than:

1
2
3
4
5
6
7
8
9
  require 'rubygems'
  require 'neoneo'
 
  user = Neoneo::User.new('user name', 'password').
  project = user.projects.find('My Project')
 
  project.add_task("A fantastic and delicious new task.",
                   :notify => ['Peter Paul', 'Someone Else'],
                   :category => "Crazy Shit")

Check out Neoneo’s docs for more info and some examples of how to use it or have a look at the source in our github repository.

You’re welcome to contribute in any way! Ideas, bug reports, patches and new solutions are highly welcomed :)

So enjoy No Kahuna at your fingertips and leave us a line if you encounter any trouble with it!

Yours,
Thorben
FEtMab-Team

No Comments »

Hey guys,

recently we’ve released our first two gems.

Tags4Free let’s you easily extract tags/keywords from a text using Yahoo!’s Term Extraction Webservice

Babylon gives you the power of the Google AJAX Language API to determine the language of a text without the hassle of quering the service yourself.

The gems can be installed via:

gem install tags4free

and

gem install babylon

And the documentation can be found at the kickass.rb page at Rubyforge.

Both gems are using the John Nunemaker’s HTTParty gem which is really fun and easy to use, so thanks a lot John!

Ok, thats it for now!

Thorben
FEtMab - Team

2 Comments »

The next two days in Prague the things went more like they should :) . We had a nice first day with interesting talks. Unfortunately most of the talks were in a little bit “philosophical” direction. This IS interesting too, but it seemed to us, that nothing really new was said during that talks, so that the technical ones were more “innovative”.

Koichi’s topic was VERY interesting. Maybe it would’ve been cool, if he had the opportunity to speak something like the Netbeans tutorial. A longer, less philosophical, more detailed explanation of his work.

A very interesting talk of the first day was the lightning introduction to the “Agile Whiteboard” by Kingsley Hendrickse and his companion. This is actually a white board web application where you can pin notes (story cards) to a virtual whiteboard, drag and group them into categories. It may sound very simple but their implementation looked nice and really usable! So as far as we’ve understood there is no public version of this one now, but they will release it’s source in the near future. Maybe they should consider to make a “white board service” from that, too. There likely will be users who would pay for such a service.

Davids talk via Skype was nice, but philosophical, too. But what he said perfectly fitted into a Ruby conference! We thought it might be a little bit misplaced, beforehand. What turned out to be somewhat true during the Q&A session after his talk. As it wasn’t a talk about “hard facts” not many questions regarding the talk arose and it seemed, that the people didn’t really know what to ask him. Maybe this is a little bit surprising, as a quick poll during Matz’s talk showed, that around 90% of the participants come from a Rails background.

The day ended with a nice party.

I had a beer and Goulash (thanks again, Carsten) with the person who taught me the Rails basics, a professor at the University of Bremen, and we talked a while about the conference day, a Rails/Ruby user group in Bremen and many other things.

Sunday morning I delayed our arrival at the conference with my strong feelings against getting up on time. So we missed the first talk which, accordingly to Carsten, was a very interesting one. So if you feel like testing if your mocks represent the mocked objects correctly, you should have a look at Synthesis by George Malamidis.

Tomasz Stachewicz held an interesting talk about running things in background (mostly) in Rails. His solution is far superior to our StupidBackground, but the reason why he and we built our solutions seems to be the same: BackgrounDRB is too complex to use and run. So if you’re looking for accurate timed, background operations have a look at his project (no link, we’ve to wait till the slides get released). But if you just need a real simple solution with a nice, little DSL to define when things should run you definitively should have a look at StupidBackground ;) .

My favorite talk of the whole conference was the “Building Rails Playground” one by Petr Krontorád. They built a system, similar to Heroku but (different to what Jürgen suggested in his moderation of the Q&A session after the talk) we think that this system is better than Heroku! It has a nicer editor, access to the hosted projects via WebDAV and nice statistics. And: It’s a non-commercial project! They see themselves as a platform for beginners to start working with Rails. I’ve requested an invite to the system just after 2 minutes of the talk. Can’t wait to be accepted! A lot of kudos to this Petr and the rest of the team!

Unfortunately we had to leave after this talk and missed the last two talks which sounded really interesting, too (”Aspect Oriented Programming in Ruby” and “Lessons Learned Writing Native Extensions”). And maybe even more unfortunately we missed the rest of the lighting talks :/ .

But we should stop moaning! It was a great weekend and the organisators of the event did a GREAT job! We should say thank you to all the sponsors: SUN, ataxo, brightbox, CODE GEAR, Engine Yard, Unicorn College, Bit Nami, Dr Nic Academy, iQuest, Kraxnet, Nodeta and Skvělý.cz to help making such a great experience possible!

See you all next year somewhere in Europe :) .

No Comments »

Hey folks,

we’ve just returned, after an adventurous journey over Geneva, from Prague and brought a lot of impressions back, to Germany.
After the Euruko 2007 in Vienna, last year, this was the second Euruko we attended and we think that it was a great success! The familiar spirit couldn’t be washed away by a quadrupled number of participants and so we had two days full of fun and information, a great combination. I’ve splitted our report up into two parts. This one is a narrative summary of what happened, before the conference has even begun and the second part will be a less narrative summary of our favorite talks and comments on the conference.

It shouldn’t take too long, till the first curious thing happened to us: Just arrived at the Prague airport, we took our luggage, and wanted to take the next taxi to our hotel. But as we were just checking how long the transfer to the hotel would take by bus or tram, Peter and Marianna asked if we are attending Euruko… It took a while, but I can’t imagine anything that roughly sound like Euruko so I had to believe that they really said “Euruko”. After he explained, that he remembered our faces from the last conference the situation was little bit more clear ;) . But then that: They were at the airport with Karel and waited for… *drum roll* Matz :) . Woah! Alright, we changed our plan: No more taxi, instead a public transportation ride with Matz to the city. Nice start of this weekend! But actually the plan was changed once again. Sebastian was hit by a nasty virus last week and still struggled a little, so after waiting for about 30 minutes we left, without Matz and the his reception committee by taxi. Strange first hour in Prague :) .

After we had checked in at the hotel, I discovered Prague on my own. After a delicious meal near the hotel it was already somewhat around midnight, but I thought that tough Rubyists would doubtlessly partying till the early morning, so it would be worth go to the party, even if I would be a little late. A long story short: There is a club in Prague called “Farbique” or somewhat like that. I was confused, that it isn’t possible to buy a tram ticket IN the tram and then walked all the way down town, where this club is located. I found it… but it wasn’t “La Frabika” ;) . So this was my party-night at Friday. I found a ticket machine in a metro station, took the tram back to our hotel.

No Comments »

Hi,

we’ve been working on a Rails tutorial series in the last couple of weeks and the first of those articles has now been published.
Take a moment and head over to the guys from galaxy-news.net. We’re proud being asked for this tutorial by Galaxy-News and hope you like it! Please leave any comments, regarding this article, at the Galaxy-News comment section.

To the article!

Yours,

Thorben
FEtMab-Team

No Comments »

I’ve tagged the version 0.1.2 a few days ago and time has come to announce this :) .

A cool new feature made it’s way in this release which gives you the ability of concurrent jobs. In addition to this we’ve added a first, rough spec so it’s definitively a good one to check out.

But that’s not all. Together with the 0.1.2 release Stupid Background got it’s own webpage! Ok, I’ve to admit that it’s nothing special, just a drag&drop page made with iWeb, but this means it looks fine ;) . So have a look at the new pages, which you can find at: http://stupid.fetmab.net .

Stupid Background

So long!

Thorben
FEtMab-Team