Geschrieben von Jens
am 29. Januar 2010
To generate a instance of a enum class by a given string you can use the valueOf() method.
-
public class EnumByGivenStringSample {
-
private enum Language
-
{
-
JAVA, RUBY, SCALA, GROOVY, CLOJURE
-
}
-
-
public static Language languageByString(String language)
-
{
-
return Language.valueOf(language);
-
}
-
}
Geschrieben von Jens
am 26. Januar 2010
With the db2 comand line tool:
db2 ? SQL$FOO
Replace $FOO with your sql code.
Geschrieben von Jens
am 18. Dezember 2009
Das Jahr neigt sich dem Ende zu, Weihnachten steht vor der Tür. Alle Jahre wieder machen wir uns auf die Suche nach Geschenken für unsere Lieben. Weihnachtsfeiern stehen an und die Weihnachtsmärkte locken mit leckerem Glühwein.
Doch es ist auch die Zeit innezuhalten und an die Menschen zu denken denen es schlechter geht. Doch wo soll man spenden, damit das Geld nicht in dunklen Kanälen verschwindet? Diesem Problem hat sich Betterplace angenommen. Eine Web 2.0 Hilfsorganisation deren Motto ist: “Menschen, die Unterstützung brauchen treffen auf Menschen, die helfen wollen”. Gespendetes Geld wird zu 100% an das jeweilige Hilfsprojekt weitergeleitet. Auf Betterplace gibt es zahlreiche Projekte die man unterstützen kann.
Ich habe für folgende Projekte gespendet:
Geschrieben 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.
Geschrieben 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:
-
alias wt='~/tools/workingtime.rb'
So finally the script looks like this:
-
#!/usr/bin/ruby
-
HOURS_PER_DAY = 24
-
MINUTES_PER_HOUR = 60
-
SEC_PER_MINUTE = 60
-
times = []
-
-
#get times from windows systeminfo
-
#Systembetriebszeit: 0 Tage, 0 Stunden, 10 Minuten, 0 Sekunden
-
uptime_string = `systeminfo | grep Systembetriebszeit`
-
uptime_string.slice!(0..28)
-
time_strings = uptime_string.split(',')
-
time_strings.each do |s|
-
times < < s.gsub(/[A-Za-z\s]+/, '')
-
end
-
-
#do some calculation
-
seconds = times[0].to_i * HOURS_PER_DAY * MINUTES_PER_HOUR * SEC_PER_MINUTE
-
seconds = seconds + times[1].to_i * MINUTES_PER_HOUR * SEC_PER_MINUTE
-
seconds = seconds + times[2].to_i * SEC_PER_MINUTE
-
seconds = seconds + times[3].to_i
-
now = Time.now
-
login = now - seconds
-
if (times[0].to_i != 0)
-
times[1] = times[1].to_i + times[0] * HOURS_PER_DAY
-
end
-
-
#print it
-
puts login.strftime("Login: %H:%M")
-
puts now.strftime("Now: %H:%M")
-
puts "======================"
-
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.
Geschrieben von Jens
am 25. September 2009
To check if a BigDecimal in Java is negative use the signum() method like it’s shown in the following snippet:
-
public static boolean isNegative(BigDecimal b)
-
{
-
b.signum() == -1;
-
}
Geschrieben von Jens
am 04. Juli 2009
Finally I found time to finish my writeup about the second day of railswaycon 2009.
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!

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.
