Copy and paste mit syntaxhighlighting

Veröffentlicht von Jens am 28. November 2009

Bei der Arbeit an einer Präsentation über Ruby hatte ich das Problem Quellcode mit syntaxhighlighing in Keynote zu bekommen. Dabei bin ich auf das geniale Copy as RTF TextMate bundle von Max Muermann gestoßen.

Nach der Installation kann man über das Bundle beliebigen Quellcode in die Zwischenablage kopieren und das Highlighting bleibt als RTF erhalten. Programme, die RTF unterstützen (wie Keynote), kann man so sehr einfach mit Codeschnipseln versorgen.

Measure your working time on windows

Veröffentlicht von Jens am 19. Oktober 2009

For measure working time on windows I wrote a little script. It calculates the time since the last login. The output of the script looks like this:

Login:        10:10
Now:          18:13
======================
Working time: 8 h 3 m

The script is written in Ruby and runs under cygwin. I saved the script in a folder tools in my homedir and have the following alias in my .bashrc:

  1. alias wt='~/tools/workingtime.rb'

So finally the script looks like this:

  1. #!/usr/bin/ruby
  2. HOURS_PER_DAY = 24
  3. MINUTES_PER_HOUR = 60
  4. SEC_PER_MINUTE = 60
  5. times = []
  6.  
  7. #get times from windows systeminfo
  8. #Systembetriebszeit:                     0 Tage, 0 Stunden, 10 Minuten, 0 Sekunden
  9. uptime_string = `systeminfo | grep Systembetriebszeit`
  10. uptime_string.slice!(0..28)
  11. time_strings = uptime_string.split(',')
  12. time_strings.each do |s|
  13. times < < s.gsub(/[A-Za-z\s]+/, '')
  14. end
  15.  
  16. #do some calculation
  17. seconds = times[0].to_i *  HOURS_PER_DAY * MINUTES_PER_HOUR * SEC_PER_MINUTE
  18. seconds = seconds + times[1].to_i * MINUTES_PER_HOUR * SEC_PER_MINUTE
  19. seconds = seconds + times[2].to_i * SEC_PER_MINUTE
  20. seconds = seconds + times[3].to_i
  21. now = Time.now
  22. login = now - seconds
  23. if (times[0].to_i != 0)
  24.   times[1] = times[1].to_i + times[0] * HOURS_PER_DAY  
  25. end
  26.  
  27. #print it
  28. puts login.strftime("Login:        %H:%M")
  29. puts now.strftime("Now:          %H:%M")
  30. puts "======================"
  31. puts "Working time: #{times[1].to_i} h #{times[2].to_i} m"

Known issues: The script is based on the windows command systeminfo. Systeminfo returns values in the language of the operating system. So this works only with a german windows. Replace “Systembetriebszeit” with whatever your systeminfo command returns for the uptime.

RailsWayCon 2009 day 2

Veröffentlicht von Jens am 04. Juli 2009

Finally I found time to finish my writeup about the second day of railswaycon 2009.

RailsWayCon Session: Integrating Enterprise Java with JRuby and Rails

Michael Johann

Michael showed some examples how to integrate Java with Ruby. The reasons for integrating Java with Rails might be reruse of java code or a smooth transitition to Rails.

He showed some swing programming from the jruby console and he used a EJB enitity bean fasade with a rails controller to provide a restinterface.

The talks was in a bit slow in general. I think Johann an the croud was still a bit tired from the webinale party the day before. But the talk gaves a really great overview integrating java with ruby.



RailsWayCon Keynote: From Rails to Rack: Making Rails 3 a better Ruby Citizen

Yehuda Katz

In his Keynote Yehuda haves an an overview of Rails 3 which will be a merge with Merb.

In Rails 3 every part of rails will be a standardized Rack app. Rails with using Rack as a Core feature will be able to use and provides middleware in the rack standard. This will make testing much easier, because you can just mock every rack part of Rails.

This will make it much easier to replace parts of Rails with your own stuff. For example replace Active Record with Sequel or DataMapper and keep the Rails form magick work. Or replace prototype/script.aculo.us with jquery without loosing the rails ajax helpers.

Great Keynote!



RailsWayCon Session: Rails in Large

Neal Ford

Neal gaves an overview how thoughtworks build on of the biggest rails apps. It’s the vehicle trade plattform ove.com.
According to Neil ove has about 7million page views per week and they build the app with 11 pairs of developers, 8 buisness analysts and other staff.

He gaves a great overview how the development process at thoughtworks works and how the solve their problems.



RailsWayCon Session: Ruby/Rails in the Enterprise

Maik Schmidt

Maik explaind how to solve typical problems programmers will face when developing Rails applications in a common enterprise environment.
Like large amounts of date in xml files lets you run in performance problems with rexml (you can solve them with using libxml).
Or i18n will force you to monkey patch active record because the sales department want different looking validation error messages.

A really great talk.



RailsWayCon 2009 day 1 part 2

Veröffentlicht von Jens am 06. Juni 2009

RailsWayCon Keynote: Present and Future of Programming Languages Through a Ruby Lens

Ola Bini

Ola gives an awesome Keynote about his toughts on programming languages in general.
The talk was really great and he gives so much information in a short time that is hard to
cover everything in a blog entry. He made some assumtions which I will repeat here for you:

  • The jvm is great and will be there a long time. I totally agree to this. The jvm is a great pice of software engineering.
  • Don’t use the term “Scripting” language call it pragmatic languages. For Ola and probably a lot of people out there scripting language has a negative sound. I personaly don’t think so but he made a good point.
  • Natural Languages are not rational designed and not logical in a lot of cases. The Sapir Worph hypotesis (where bdd is based on) doesn’t matter for natural languages but it does in programming languages.
  • This points are important to Ola as language designer: communication, abstraction, expressiveness (remove everything whats not relevant to buisness logic), first class access (for example eval in ruby).
  • The language is more important than the tools. That’s a point I totally agree. Especially in the java world people talk all the time about tools and forget the essence what’s really important: Get the job done in a simple, kiss and dry way. A Simple soluten without any tool support is much better than a complex solution with great tool support.
  • For Ola in the future there will be more than less programming languages. So if you know just one programming language it might be a good idea to learn another one.



RailsWayCon Session: Ruby sittin on the Couch

Alexander Lang

Alex talk was about CouchDB. Apache CouchDB is a distributed, fault-tolerant and schema-free document-oriented database accessible via a RESTful HTTP/JSON API.

So, why Couch DB?
Alex says:

  • RESTful HTTP Interface
  • Store/read JSON documents
  • provides map reduce
  • It Scales on a single node by optimistic locking
  • muliple nodes (master/master replication)

The english was a bit hard to understand in some parts of the presentation. And I missed some comparison between CouchDB and a relational db model.



RailsWayCon Session: What is good UI?

Steven Bristol

Steven demonstrated 5 revisions of less accounting to get an impression how the user interface of the app changed and improved over the time.

Steven gave some nice tips for making a good ui:

  • You don’t get it right the first time
  • Whats your app? Do that not more.
  • Write more code so your users don’t have to do so much.
  • Ask for feedback
  • Use your own applications
  • If it’s hard to code a webpage the ui is bad



RailsWayCon 2009 day 1 part 1

Veröffentlicht von Jens am 26. Mai 2009

After running late because of some trouble with the berlin railways. I’ve skipped the first RailsWayCon Session and attended to the Webinale Keynote Phänomen Web 2.0 with Ossi Urchs .

The Talk was about Web 2.0 Basics and how the web has and will change buisness. It was nothing really new for me and most of the croud but a great summery of web 2.0 in general.


RailsWayCon Session: Show the Frontend some Love: HAML and SASS

Speaker: Jan Krutisch

Jan gives a really nice talk about haml. Haml is a markup language that’s used to cleanly and simply describe the XHTML of any web document without the use of inline code.

Accourding to Jan this are the pros on haml:

  • no redundancy
  • generates html nice code
  • For css ids and classes syntax similar to css
  • Filters to use textile, markdown, …

An this are the cons:

  • It’s a Problem when you have to deal with designers
  • Debugging is be harder in some cases

The other part of the session was about SASS which means Syntactically Awesome StyleSheets. The language comes with haml but can also used for it’s own. It solves some problems with css. A weird thing with cascading style sheets is that they doesn’t support real cascading. Sass solves this problem and also adds constants, calculations and imports.


RailsWayCon Session: The Pleasure and Pain of Migrating to jRuby

Speaker: Steven Bristol

Steven gives an intersting talk about problems he run into when moving his application LessAccounting to jruby. He decided to move the jruby because he had to implement a third party api written in java. The first Problems he run into was that all compiling gems like ferret or file column doesn’t work in jruby. So he had to replace this parts in his applications with other solutins.

The biggest Problem he run into was the deployment of the application with glass fish. After get everything running he still has the problem that the deployment with glass fish is much slower than with mongrel before.

His recomendation if somebody run into the same problem is don’t move your whole app to jruby. Just build a small application which exposes a rest interface.


RailWayCon 2009

Veröffentlicht von Jens am 22. Mai 2009

The conference on Ruby, Rails and more. Auf nach Berlin:

Eintrittskarte RailsWayCon

HOWTO: Install a rails stack with ruby-enterprise and passenger on CentOS

Veröffentlicht von Jens am 22. Februar 2009

Preparations:
Install CentOS with Apache and Mysql.

1. Install ruby enterprise:

  1. wget http://rubyforge.org/frs/download.php/41040/ruby-enterprise-X.X.X-X.tar.gz
  2. tar xzvf ruby-enterprise-X.X.X-X.tar.gz
  3. ./ruby-enterprise-X.X.X-X/installer

2. Create some links:

  1. ln -fs /opt/ruby-enterprise-1.8.6-20080624 /opt/ruby-enterprise
  2. ln -fs /opt/ruby-enterprise/bin/gem /usr/bin/gem
  3. ln -fs /opt/ruby-enterprise/bin/irb /usr/bin/irb
  4. ln -fs /opt/ruby-enterprise/bin/rake /usr/bin/rake
  5. ln -fs /opt/ruby-enterprise/bin/rails /usr/bin/rails
  6. ln -fs /opt/ruby-enterprise/bin/ruby /usr/bin/ruby

3. gem install rails -v 2.X.X

Problems:
I’ve got problems with missing Mysql libraries. To fix this:

3.1 Install mysql-devel

  1. yum install mysql-devel

3.2 Install mysql-gem

  1. /opt/ruby-enterprise-1.8.6-20080624/bin/ruby /opt/ruby-enterprise-1.8.6-20080624/bin/gem install mysql — –with-mysql-include=/usr/include/mysql –with-mysql-lib=/usr/lib64/mysql

4. Passenger (mod_rails)

4.1 Install Passenger (mod_rails)

  1. gem install passenger

4.2 Passenger Apache Module

  1. passenger-install-apache2-module

5. ImageMagick

5.1 Install ImageMagick Libraries

  1. yum install ImageMagick-devel

5.2 Install rmagick via gems

  1. sudo gem install –no-rdoc –no-ri –no-update-sources rmagick -v 1.15.15

Problems:

Parameter –version doesn’t work.
Don’t use the parameter “–version”

Read more about this problem:
http://www.beanlogic.co.uk/2008/8/13/installing-a-specific-verison-of-rmagick

Missing msfonts

Installation of msfonts according to:
http://hi.baidu.com/rainchen/blog/item/089ef7364497de320a55a9a3.html

  1. wget http://www.osresources.com/files/centos-windows-fonts/msfonts.tbz
  2. mkdir /usr/share/fonts/default/TrueType
  3. tar xvjpf msfonts.tbz -C /usr/share/fonts/default/TrueType/

6. Config of apache and your rails app
For configuration of passenger follow the instructions there

Thats it!

Merb wird in Rails 3 gemergt! 1

Veröffentlicht von Jens am 24. Dezember 2008

Wow tolle Nachrichten zu Weihnachten. Merb wird in Rails 3 gemerged. Damit wird Rails modularer, schneller und bekommt eine stabilere API für Plugins. Frohe Weihnachten.

Weitere Infos:

http://weblog.rubyonrails.com/2008/12/23/merb-gets-merged-into-rails-3 

http://yehudakatz.com/2008/12/23/rails-and-merb-merge/

Ruby

Veröffentlicht von Jens am 02. September 2008

A few years ago, I came across the Ruby programming language, and I fell in love. Somehow, it just seemed to work the way my brain works—I can express myself in Ruby more naturally and with less intervening fluff than in any other language I know. [...] And now, for the first time, I can seriously say that Ruby is ready for the enterprise. The language is stable, the libraries are great, and there is a growing pool of talented and enthusiastic Ruby developers, all rising to the challenge. Dave Thomas (Schmidt 2006, Foreword)

 

Ruby ist eine Programmiersprache, die 1995 von dem Japaner Yukihiro Matsumoto veröffentlicht wurde. Sie wurde durch die Sprachen Perl, Eiffel, Ada, Smalltalk und Lisp inspiriert. Die herausragenden Eigenschaften von Ruby sind:

  • Vollständige Objektorientierung. Es existieren keine einfachen Datentypen.
  • Die durch Lisp inspirierten Closures erlauben mächtige Operationen.
  • Ruby Mixins, die eine elegante Art der Mehrfachvererbung darstellen.
  • Das dynamische Typsystem, das große Flexibilität ermöglicht.
  • Die Ausbalancierung zwischen funktionaler und imperativer Programmierung.