Monatsarchiv für April 2010

CouchDB - How to replace an SQL Auto-Value, Auto-Increment or DB-Sequence with CouchDB Views?

Friday, den 30. April 2010

Learning CouchDB for a SQL educated person is sometimes a bit tricky because things are solved so different. So happened to me.
Currently I am trying to create a simple invoicing app based on CouchDB. When creating invoices you might want to have a straight integer sequence to acts as invoice numbers. In a RDBM this […]

CouchDB - Debug CouchDB Views

Friday, den 30. April 2010

In order to debug couchDB view functions you can use the log - function:

function(keys, values, rereduce) {
var max = 0;
for( i in values ) {
log( “\n\n” + values[i] + “\n\n”);
if (values[i] > max) {
max = values[i];
}
}

return max;
}
You’ll find the output in your couchdb-Log file.

CouchDB - Where can I find more information about build in JavaScript functions like sum()?

Friday, den 30. April 2010

When starting to work with CouchDB the lack of an indepth documentation can be a bit frustrating.
If you’re wondering where JavaScript methods like “sum” used in reduce functions are described, for example, you don’t find any detailed information in the CouchDB-Wiki.
What you can do is to have a look at:
COUCHDB_HOME/share/server
There are a number of javascript […]

Rails 3 - Beta - no such file to load — rails/cli (LoadError)

Tuesday, den 27. April 2010

When trying to create a rails project you might encounter the following error:
/Users/jfischer/.rvm/gems/ruby-1.9.1-p378/gems/rails-3.0.0.beta3/bin/rails:1:in `require’: no such file to load — rails/cli (LoadError)
from /Users/jfischer/.rvm/gems/ruby-1.9.1-p378/gems/rails-3.0.0.beta3/bin/rails:1:in `<top (required)>’
from /Users/jfischer/.rvm/gems/ruby-1.9.1-p378/bin/rails:19:in `load’
from /Users/jfischer/.rvm/gems/ruby-1.9.1-p378/bin/rails:19:in `<main>’
The problem can be solved by uninstalling all prior rails and active* beta versions using the gem command:

gem uninstall railties actionpack actionmailer activemodel activeresource activerecord activesupport
Then reinstall […]

Rails3 - Beta - No such file or directory - lib

Tuesday, den 27. April 2010

If you encounter an error like the following when trying to install rails 3 prerelease:

ravel:~ jfischer$ gem install rails –prerelease

Successfully installed rails-3.0.0.beta3

1 gem installed

Installing ri documentation for rails-3.0.0.beta3…

ERROR:  While executing gem … (Errno::ENOENT)

No such file or directory - lib
then you might want to try skipping the ri and rdoc generation which worked for me:

ravel:~ jfischer$ […]

Scottish Ruby Conference 2010 sum up

Thursday, den 8. April 2010

Really impressed by the beauty of scottish architecture I was wondering how the Scottish Ruby Conference will be like.It has been held at the Royal College of Physicians in Edinburgh a really impressive location. With a history of more than 300 (!) years it is an organization contrasting the the baby aged computer science fraction.
The contrast of talks delivering […]

Accessing the Java Printing API using JRuby

Monday, den 5. April 2010

If you ever have to print a document from a Ruby app you might want to consider using JRuby to access the Java Printing API.Here is a small example accessing the API, looking up the printers and printing out their names to the console:

require ‘java’
flavor = javax.print.DocFlavor::INPUT_STREAM::TEXT_PLAIN_HOST

aset = javax.print.attribute.HashPrintRequestAttributeSet.new
aset.add(javax.print.attribute.standard.MediaSizeName::ISO_A4)
aset.add(javax.print.attribute.standard.Copies.new(1))

services = javax.print.PrintServiceLookup.lookupPrintServices(flavor, aset);

puts(”Anzahl der Drucker: ” + […]