Posts mit dem Label java werden angezeigt. Alle Posts anzeigen
Posts mit dem Label java werden angezeigt. Alle Posts anzeigen

Donnerstag, 10. Februar 2011

Lady Java

Hier mal wieder ein lustiges Video für die JavaZone!



(via Bilyana)

Dienstag, 1. Februar 2011

Erst php, jetzt Java


Nachdem ja neulich eine Lücke in php bekannt wurde, durch die es Probleme beim Parsen von Dezimalzahlen geben kann, wird jetzt bekannt, dass ein ähnliches Problem auch bei Java existiert.

Besonders interessant dabei: Nicht nur die Runtime ist betroffenen, sondern auch der Compiler.

Näheres unter: Java Hangs When Converting 2.2250738585072012e-308 - Exploring Binary 

(via Fefe)

Montag, 24. Mai 2010

How to upload files to a MediaWiki using JWBF

This little issue has been nagging me for a while, this is why I post it here hoping it will help others as well.

So if you want to
- upload images to your own (or somebody else's) MediaWiki
and you
- want to do it using java
and
- you happen to use the Java Wiki Bot Framework (aka jwbf)
then this one is for you:

String localPathToFile = "/home/klausbert/tmp/myTestImage.jpg";
String urlToWiki = "http://mydoma.in/wiki/";
String wikiUser = "klausbert";
String wikiPassword = "klausbertsPassword";
String descriptionText = "Some text to describe the image";

MediaWikiBot mwb = new MediaWikiBot(urlToWiki);
mwb.login(wikiUser, wikiPassword);
SimpleFile file = new SimpleFile(localPathToFile);
file.addText(descriptionText);
mwb.performAction(new FileUpload(file, mwb));

Of course you will need some imports and try-catches. But the code is the essence of what you need to upload the file.

Mittwoch, 17. März 2010

On my way to TweetMountain (Part 2)

Almost two months ago I wrote a first post about TweetMountain. Back then I only had a faint idea of what I wanted to do and what it could look like. Now - several weeks later - the idea still is the same but the look and a lot of technical details have changed. This post will summarize what has changed since then.


Before

The biggest step was for sure the change over from single-letter-rendering to the usage of whole words. This step changed the mountain from a sheer mess to a mess that can be read and interpreted as something that was created by humans ;-)
In addition to using whole words as building blocks I also introduced colors to the mountain. The color of the words now represents the account that has sent the according tweet.
Both ideas base on discussions with @prokrastinator whom I'd like to thank for his great input!

These content based changes were accompanied by one other change: Whenever an image gets posted in a tweet it will not be rendered as the URL that was shown in the tweet but as the actual image. This brings the visual content of a tweet into the mountain in its natural form.

After

So this is what TweetMountain currently looks like in full action (Unfortunately the people it currently follows do not post many pictures).

Next to the changes to the look and algorithms of TweetMountain, it also got its own twitter account: @zwitscherhuegel. It is used to follow different people and institutions that this way produce the mountain itself. But it is also used to output screen shots of the mountain and to get in touch for discussion about TweetMountain or other twitter-art-projects. So, the account is not (only) a bot, it also gets used manually. So if you have some questions or input, go ahead and tweet ;-)

So much for the current status of the project. Some further steps I may/will take include:
  • Support of more image services. Currently I only support Twitpic and yfrog, there are several other platforms that shold be used.
  • Find a place and a computer to host the Mountain 24/7.
  • Use a "dynamic camera" that zooms in or out depending on what is currently going on on TweetMountain.
  • Translate the twitter output the mountain generates to several languages so it gets more diverse.
  • Change letter rendering from a hard coded image map to dynamic font based rendering.
  • ...
Okay, that's it for today from TweetMountain. I will continue this project and keep you informed. If you want to, just follow @zwitscherhuegel and get in touch with TweetMountain or me on twitter.

Other posts that may be of interest:

Mittwoch, 27. Januar 2010

On my way to TweetMountain

I am using twitter now for quite a while. It has been a never ending source of inspiration and a great tool to implement and communicate some of my ideas. In the last few days I somehow realized that there are times in which the output of my twitter timeline just gets "somehow" overwhelming.

In the last view months I also started to dig a little into a programming language called processing (see processing.org). It is basically Java tweaked in a way that allows easy access to all graphic routines. Surfing thru the examples on OpenProcessing.org (a site built to share and exchange processing projects) I stumbled upon this cool sketch by antiplastik. I shows how simple physics and the use of OpenGL are in processing. This is a screen shot of the sketch in action:
Both inputs (the twitter overflow and the stacked boxes by antiplastik) fermented in my backbrain for a while till they came together in a small processing project I call TwitterMountain:
It uses little boxes that fall from the ceiling to create a pile of letters. The input is taken from my twitter timeline tweet by tweet, split into little boxes/letters and dropped onto the pile. Every now and the letters are lost and their boxes get deleted, but as twitter keeps on generating output the pile never vanishes.
My first implementation looked like this image above. The physics where there and I got the letters in the image. Twitter was connected and kept sending input.
Today I reworked it a little. First of all I added some limitations to box creation so the pile never fills my sketch completely. Secondly I created a nice sprite map that I can use as textures for the blocks. This way now the letters rotate correctly with their boxes.
So for now the TweetMountain is running and running, flooding my screen with an endless stream of tweets and letters.
There is some work left to do:
- clean code, write comments, use logging (gna gna gna... you know the routine)
- there seems to be a newer (and faster) version of jbox2d that I should check out (jbox2d is the library that does all the physics simulation in the background)
- build an Applet that can by used by everybody to watch his own twitter timeline

Maybe I even come up with some more ideas to put into the algorithm as well... I will keep you up to date with new versions.

Montag, 10. September 2007

Lightning Talk "Groovy on Grails"


Heute gab es am FZI einen "Lightning Talk" zum Thema "Groovy on Grails" von
Raphael Volz. Hier ein "Live-Mitschrieb" von der Session, also eher knapp gehalten und nur wirklich verständlich, wenn man die Folien dazu kennt (Folien gibt es hier)


Kurz und knapp

Grails: Framework für das schnelle Bauen von Webapplikationen
Groovy: Die Sprache, auf der Grails aufbaut

Insgesamt sind das also zwei Frameworks, die auf diversen Frameworks für Java aufbauen. Die Argumentation für so ein vorgehen ist, dass man so das "Prototyping" einfacher macht. Java ist nach dieser Argumentation zwar gut, aber oft zu kompliziert, um agile Webentwicklung zu betreiben und/oder einfache Prototypen zu entwickeln.


Einführung in Groovy
Baut auf Java auf.

  1. Feststellung: Der Syntax ist deutlich einfacher als bei Java.
  2. Feststellung: Variablen können Code enthalten, den ich abspeichern und wieder verwenden kann (sog. Closures). Das ist wohl vergleichbar mit den anonymen Lambda-Funktionen in Lisp. Leider hab ich nie Lisp programmiert ;-)
  3. Feststellung: Listen sind einfach zu coden! Dazu gibt es auch schöne Operatoren (abziehen von Elementen (=Entfernen) etc.). Maps sind wie Listen nur mit key:value Notation. Sortieren ist schon eingebaut und einfach zu bedienen)
  4. Feststellung: Überladen von Operatoren ist möglich.
  5. Feststellung: Es gibt sogenannte Builders, mit denen man verschiedene Sachen erzeugen kann. Insbesondere interessant, da es schon diverse fertige Builder gibt (XML, HTML, Swing-GUI, ...). Dazu gibt es dann auch Parser, die Groovy Objekte aus den entsprechenden Repräsentationen erzeugen.
Fazit zu Groovy: Schnell zu entwickeln. Kleiner/kurzer Code. Aber: schwerer zu debuggen und deutlich langsamer in der Ausführung als einfacher Java-Code.


Einführung in Grails
Grails ist ein MVC Web-Framework, das auf Spring, Hibernate, Groovy, Ant etc. aufbaut
Als Default-Web-Server wird Jetty verwendet.
"Programing by Convetion" oder auch "Convention over configuration"

So mach ich ein Programm damit:
%> grails create-app
Domänenobjekte beschreiben
%> grails generate-all
%> grails run-app

  1. Feststellungen: Objekten und ihren Attributen können Constraints zugewiesen werden. Insbesondere gibt es schon fertige Constraints für oft vorkommende Attribut-Typen (Email, ...)
  2. Feststellung: Suchen über freie Funktionsnamen (findByTitel("xy") ==> "WHERE title='xy', findByTitleLikeOrAuthor('xy','Fritz') ==> "WHERE title LIKE 'xy' OR author = 'Fritz'). Hier gibt es fixe Konventionen anhand derer dies Übersetzung gemacht wird.
  3. Feststellung: Prozesse, die mehrere Seiten verwenden müssen, können mit Hilfe eines Chain-Objektes direkt und einfach implementiert werden.
  4. Feststellung: Jobs (ähnlich wie Cron) sind machbar. Diese werden entsprechend im Hintergrund ausgeführt.
Fazit zu Grails: Mit dem Framework kann man wirklich schnell Web-Applikationen "prototypen". Muss aber noch einiges daran gemacht werden. Für einige private und kleinere Projekte werde ich es mir allerdings mal genauer anschauen.


Fragen am Ende der Session

  • Wie nachhaltig schätzt der Referent Grails/Groovy ein
    • Groovy wird wohl ziemlich sicher bleiben (insbesondere da es diverse Preise gewonnen hat) und da "man" sich als JSR-XXXX (als dynamische Scripting-Sprache für Java) Spezifikation beworben hat.
    • Bei Grails ist das noch nicht abzuschätzen. Momentan viel Buzz aber noch zu neu und zu unausgegoren.
  • Gibt es IDEs
    • Noch nicht so recht. Das Eclipse Plugin ist noch im SVN Status und der Referent hat noch keine Umgebung installiert bekommen.


Hinweise und Sachen, die mir nebenbei aufgefallen sind

  • Hier kann man Groovy runterladen: http://groovy.codehaus.org/
  • Hier kann man Grails runterladen: http://grails.codehaus.org/
  • Gargoylesoft Webclient als Zugriff auf's web (com.gargoylesoft.xxx). Das muss ich mir mal noch genauer ansehen.
  • Das in den Folien vorgestellt Grails Buch ist inzwischen veraltet und mancher Code daraus funktioniert nicht mehr
  • Im September kommt angeblich Grails 1.0