Showing posts with label camping. Show all posts
Showing posts with label camping. Show all posts

Monday, January 21, 2008

I finally made up my mind

Those who read this blog more often may have noticed the minor change in the sub-title. It now reads:
Experiences from a hard core Java programmer that finally decided Ruby is a very very nice language, but rather stays on the JVM.
Compare it to the previous text:
Experiences from a hard core Java programmer that struggles with the question of switching to the world of Ruby and Ruby on Rails.
So how did I come to this conclusion? Here are some random considerations:
  • I have only once in the last 2 years used Ruby professionally (to do some counting in a site dump).
  • I do have 3 Ruby sites running (one Camping and two using Radiant). So I am not going to stop using Ruby anytime soon.
  • ActiveRecord totally kicks ass and is hugely impressive. Rails for the rest not so much (totally old school request response based, with like JSP code in the templates). It may be just my lack of experience, so don't base your opinion on this.
  • I am very addicted to correct refactoring and code completion.
  • As I wrote before, we now have Scala.
  • Update 2008-01-23: This one needs to be added. Since I recently became a father, it is simply too much to keep track of 2 worlds at the same time.
So if you expected me to be on amsterdam.rb right now, here is why.

Monday, October 29, 2007

Getting started with Ruby on Ubuntu 7.10

 

Update 20100922: Apparently this article is so out of date that I even get e-mail to get this article down (or replace it).

Therefore: please do not use this article, in fact don't even rely on the Ubuntu packages as they are not all maintained properly.

One approach that may be fine (I did not try, don't blame me), is on http://krainboltgreene.github.com/l/3/. Good luck!

 

 

So now I have a new server, and a new 10Mbit/s internet connection. Its time for some applications! Here are my experiences with installing Rails, Radiant and Camping on a fresh Ubuntu 7.10 server installation.

First of all, if your server is running in a closet somewhere (like mine) or worse: in a remote data center, you need to disable apt-get asking for the installation CD. Edit /etc/apt/sources.list and comment the line that refers to the installation cdrom.

The next step of course it to install Ruby and Ruby Gems: sudo apt-get install ruby rubygems ruby1.8-dev Without the ruby1.8-dev you can not do much, don't forget it!

Where would you be without irb? The default install however does not link it! sudo ln -s /usr/bin/irb1.8 /usr/bin/irb

Any serious Ruby web application uses Mongrel. However, Mongrel compiles some of its stuff during the install. So you first need to get the compilation tools:
sudo apt-get install make gcc libc6

Mongrel is a trusted enterprise application nowadays, so you can install it with a certificate:

wget http://rubyforge.org/frs/download.php/25325/mongrel-public_cert.pem
gem cert --add mongrel-public_cert.pem
rm mongrel-public_cert.pem
gem install mongrel --include-dependencies -P HighSecurity
Select the highest version followed by (ruby).

Luckily, installing Rails is still a simple: sudo gem install rails --include-dependencies

If you want Camping, you'll first need to install sqlite: sudo apt-get install libsqlite3 libsqlite3-dev

Now you can:

sudo gem install camping --source http://code.whytheluckystiff.net
sudo gem install camping-omnibus --source http://code.whytheluckystiff.net

Radiant is a simple: sudo gem install radiant

For some reason the gem executables do not get added to the path. Make sure they do by adding /var/lib/gems/1.8/bin to your path. For example by adding the following line at the end of /etc/bash.bashrc: export PATH="$PATH:/var/lib/gems/1.8/bin".

The favorite database amongst Railers is of course MySQL. I assume you selected LAMP during the Ubuntu server installation, that means you already have MySQL installed. To use MySQL with ActiveRecord, its best to install the MySQL native adapter. Before you can install that, you first need to install all the compile stuff from above and some more: sudo apt-get install libmysqlclient15-dev sudo gem install mysql Again, for the gem select highest version number followed by (ruby).

Have fun!

Wednesday, October 10, 2007

Announcement: Version 99 Does Not Exist

Update 2025-07-08: Version 99 was shutdown.

In a previous post I announced no-commons-logging (a.k.a. commons-logging version 99.0-does-not-exist). After a request to add no-commons-logging-api I immediately realized that this can be generalized. So here it is: Version 99 Does Not Exist.

Features
Version 99 Does Not Exist emulates a Maven 2 repository and serves empty jars for any valid package that has version number 99.0-does-not-exist. It also generates poms, metadata files and of course the appropriate hashes.

For example the following links will give an empty jar, its pom and the maven metadata for commons-logging.

Why?
To get rid of dependencies that maven 2 insists on including on your classpath (like commons-logging while you want to use jcl-over-slf4j).

How do you use it?
First of all: if you were using no-commons-logging before, you do not need to change anything! Version 99 Does Not Exist is fully backward compatible with no-commons-logging. Otherwise, read on.

In your pom.xml declare the following 2 things: 1) the Version 99 Does Not Exist repository, and 2) for each jar that you get but do not want, declare a dependency with version 99.0-does-not-exist.

So, for example, if you do not want to be bothered with commons-logging, include the following in your pom.xml:

<repositories>
    <repository>
        <id>Version99</id>
        <name>Version 99 Does Not Exist Maven repository</name>
        <layout>default</layout>
        <url>http://no-commons-logging.zapto.org/mvn2</url>
    </repository>
</repositories>
<dependencies>
    <!-- get empty jar instead of commons-logging -->
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>99.0-does-not-exist</version>
    </dependency>
</dependencies>
When? Right now. As I received questions on how stable this service will be, I hereby promise to keep this maven repository on-line for at least 5 years (or until no-ip stops offering their free dns service). Read further if you want to run Version 99 Does Not Exist yourself.

How?
Version 99 Does Not Exist is implemented in a single file as a Camping application.

Where is the code?
If you want to run it yourself you'll need the following: Version 99 Does Not Exist download (rb file, 4Kb, MIT license), Ruby, Ruby Gems and Camping. Version 99 Does Not Exist is started with a simple camping version99.rb. Good camping!

Update 2007-11-06: The empty jar is no longer completely empty as 'mvn site' fails on it. Thanks to Stefan Fußenegger for the report.

Update 2007-12-14: The repository was off line for a day or so because I goofed while switching internet provider. Now, it is not only working again, but reachability is better then ever: 10 Mbit/s up and down!

Update 2008-02-09: Version 1.2: another update to the empty jar. Sasha Ovsankin reported that the compiler could not open it. The jar now contains a valid manifest. Thanks Sacha!

Update 2009-05-01: During my move from Amsterdam to Haarlem the server has been off line for a day or so. I am now on ADSL so my internet connection is a lot slower. If anyone want to run a mirror, I am happy to set up a rotating DNS.

Update 2009-07-24: Version 1.3: artifacts with a groupid that contain a dot are now supported. Éric Vigeant, thanks for the bug report!

Update 2009-10-17: Version 2.0: Éric Vigeant's problems were still not over. Now removed metadata support, this will hopefully make some proxies behave better.

Update 2011-08-15: DNS for Version 99 is offline.

Update 2011-12-19: I just found an alternative with almost the same name: version99.qos.ch. It is a static maven repository with a limited number of version 99 jars.

Update uknown date: Alternative hostname for Version 99: version99.grons.nl

Update 2019-11-15: Fixed link to original Camping appliction. The Camping links now point to wikipedia.

Update 2025-07-08: Version 99 was shutdown.

Monday, October 8, 2007

Watch where you place those Camping constants!

Finally got that bastard Camping application to work properly. I kept getting a ERROR: wrong number of arguments (0 for 3) on the first request. Subsequent requests would sometimes succeed, sometimes not. The funny thing was, the get method was not even called yet!

With deep gratitude for ruby guru Remco van 't Veer who found out that you can not use constants in a Camping Controller (actually, I already knew it from a previous camping app, but I had stupidly forgotten it). Move it up to the main module and you're good to go.

Wrong

Camping.goes :Nowhere module Nowhere module Controllers MY_CONSTANT = 'wrong' # Camping going nowhere end end

Correct
Camping.goes :ForPresident module ForPresident MY_CONSTANT = 'fine' module Controllers end end

See my next post to see what this is all about.

Monday, October 1, 2007

Camping: optional group in regular expression

Recently I finished a Camping application where I wanted to handle URIs with an optional part. Like so:
class Jar < R '/(.*)\.jar(\.sha1|\.md5)?' def get(jarname, hash) # does not work ... end end
Unfortunately this does not work. (Does this look familiar? See my next post!) In the end it turned out to be as simple as:
class Jar < R '/(.*)\.jar(\.sha1|\.md5)?' def get(jarname, hash = nil) ... end end
At RailsconfEurope Manfred taught me another trick:
n = 4 class DigitParty < R "/" + ("(\\d)?" * n) def get(*args) args.length # -> 4 args[0] # -> first digit or nil args[n - 1] # -> last digit or nil end end
This matches anything from 0 to n digits where a group is created for each digit. Using * in the parameter list will make method get work for any value of n. For URI's with less then n digits, the corresponding array elements are nil.

Wednesday, May 2, 2007

RubyEnRails 2007 site is live! (Dutch)

Vanaf vandaag kunnen mensen zich aanmelden voor RubyEnRails dag 2007! Op de website http://2007.rubyenrails.nl kan je je aanmelden met je OpenID.

Het sprekers gedeelte op de pagina is nog niet volledig. De lijst met sprekers zal zo spoedig mogelijk worden aangevuld. Er zullen diverse presentaties plaatsvinden over o.a. RESTful ontwikkeling, Behaviour Driven Development, Radiant en het Camping Framework.

Dus ben jij een Ruby On Rails specialist of ben je gewoon geïnteresseerd in Ruby of Ruby on Rails? Meldt je dan nu aan! Deelname is overigens geheel gratis!

Wednesday, March 7, 2007

Vooraankondiging Ruby En Rails 2007 (Dutch)

Binnenkort is het weer zover. Een nieuwe Ruby En Rails dag. Vorig jaar was het een zeer geslaagde, zonnige en gezellige dag waar veel Rails en Ruby enthousiastelingen aanwezig waren.

Ook voor dit jaar zijn we bezig om weer een dag te organiseren. Er wordt druk gezocht naar een lokatie (waarschijnlijk Amsterdam) en we zijn aan het inventariseren welke sprekers uitgenodigd worden. Waarschijnlijk zal het allemaal plaatsvinden op 31 mei, maar het is 7 juni geworden.

Heb je zelf nog goede ideeën of verzoeken m.b.t. sprekers op deze dag, surf dan naar Ruby en Rails en laat iets achter in de comments. Je kunt ook een e-mail sturen naar danny at rubyenrails.nl.

We zijn op zoek naar sprekers voor:

  • Presentaties van 45-50 minuten;
  • Lightning Quickies™ van 5-15 minuten.
Mogelijke onderwerpen:
  • Handige Ruby libraries (gems)
  • Rails plugins
  • Interessante real-world toepassingen van Rails
  • Tips & truuks, leuke vondsten, enzovoorts
Update 2007-03-20 De datum is intussen vast gezet op 7 juni. Ruby en Rails 2007 wordt gehouden in het gebouw van de Hogeschool van Amsterdam nabij het Amstel station.

Tuesday, March 6, 2007

Mule patch accepted

Another product that accepted my patch. Till today I was proud to have patches in the following products:
- Xml2Db (specification for an aspect of the API, no code, long time ago)
- Struts (something with generating session ids, not long ago enough)
- Wicket (MixedUrlEncoding, other patches pending)
- Spring (a small documentation error)

Today this is extended with: - Mule (MailMessageAdapter potentially adds "null" string)

These were all small things, but I am still proud I was able to move open source further :)

For the future: I wrote a Camping application to manage a virtual e-mail domain for Postfix. My plan is to convert this to a Radiant extension and make it available under the MIT license.

Sunday, October 29, 2006

JRuby on Rails status

JRuby 0.9.1 is out for a week. This is the first version in which JRuby really starts to perform and behave properly. Though Ruby on Rails has been reported to work on JRuby for a longer time, this was not repeated by many people; too many loopholes to jump through. However, with the advent of version 0.9.1 there are suddenly many people on the mailing list that are trying and achieving exactly this.

Another promising release was done yesterday in Japan: rails-asyncweb 0.1, a very fast web server for JRuby on Rails. TAKAI, Naoto's asyncweb uses AsyncWeb, a web server that prevents the synchronization pitfall that the Java Servlet API brings. AsyncWeb scales a lot better under load then traditional Java web servers. And the performance rocks! It is about 10 times faster then Webbrick under loads to 10 concurrent users. It will be very interesting to see what happens under much much larger loads. I am also curious how this will compare to Mongrel, Zed Shaw's successor for Webbrick in the C-Ruby world. Another interesting question is whether this will end Mongrel's Java port.

Another web framework that works under JRuby is Camping. Camping is smaller then 4K, but quite powerful. It is a creation of the well known Ruby virtuoso why the lucky stiff. If you want to get a feel for what Ruby can do but don't want to learn Ruby on Rails (which I found quite a large task) I recommend you try out Camping. Ola Bini has a nice tutorial on getting you started. (Note: you should not use Camping version 1.5 because JRuby does not support continuations.) Another very good Camping tutorial (Dutch) was written by Remco van 't Veer.

Update 2006-10-30: added Remco's tutorial.