Archive for the ‘open source’ Category
Toggling a default value of an input field using JQuery
Thursday, February 11th, 2010
Posted in: Forms, Jquery open source.
… is easy: Either use the powerful ToggleVal plugin or, if you have simpler intentions, this snippet for toggling a default value of an input field:
/**
* Applies and toggles a default value
* to input fields.
*/
jQuery.fn.defaultValue = function(defaultValue, defaultValueColor) {
return this.each(
function(e, k) {
var $t = $(k);
$t.defaultValue = defaultValue;
$t.modified = false;
$t.originalColor = $t.css("color");
$t.defaultValueColor = defaultValueColor == null? $t.originalColor : defaultValueColor;
$t.provideDefaultIfEmpty = function() {
if ($t.val() == "") {
$t.css({color: $t.defaultValueColor});
$t.val(defaultValue);
}
};
$t.clearIfDefault = function() {
if (!$t.modified && $t.val() == $t.defaultValue) {
$t.val("");
}
}
$t.change(function() {
if($t.val() != $t.defaultValue && $t.val() != "") {
$t.css({color: $t.originalColor});
$t.modified = true;
}
});
$t.focus(function() {
$t.css({color: $t.originalColor});
$t.clearIfDefault();
});
$t.blur(function() {
$t.provideDefaultIfEmpty();
});
$t.parents("form").submit(function() {
$t.clearIfDefault();
});
$t.provideDefaultIfEmpty();
return this;
}
);
};
And use it like so:
<input id="myField" />
...
$("#myField").defaultValue("Search for...", "gray");
No Comments Creating HDR images in Ubuntu with Luminance (QTPFSGUI)
Saturday, February 6th, 2010
Posted in: HDR, luminance, qtpfsgui open source.
For those who are not (yet) posession one of the latest generation digital cameras with build-in HDR capailities and the more experimental folks, there is a fantastic tool to create HDR images by combining multiple shots of the same scene: Its called qtpfsgui.
That is, it used to be called that and is still avaiable in Ubuntu under this name (sudo apt-get install qtpfsgui). However, qtpfsgui is discontinued since mid 2009 and has been replaced by the Luminance HDR project.
Since qtpfsgui crashed under ubuntu 9.10 when attempting to save any HDR image, I downloaded the latest luminance version, compiled and installed it like so:
- Download the luminance source and unpack the folder.
-
Install the dependencies required to compile luminance:
sudo apt-get install qt4-qmake libexiv2-dev libopenexr-dev fftw3-dev libtiff4-dev libqt4-dev g++ libgsl0-dev -
Compile luminance (takes a few minues) and install it. Change to the unpacked luminance folder and do:
qmake
make
sudo make install
That´s it! you now have luminance installed and it should be in your main menu under applications>graphics.
It works perfectly under Karmic.
One of the best things about luminance is that you can play a lot with the algorithms and parameters used to tonemap the HDR into a LDR image. In contrast to many other (commercial) tools, you actually get to know which algorithms are used, who created them and can read a little more on how they work (if you are not to opposed to mathematics) by googling up the corresponding papers on scholar or so. This way, experienced users are able to “squeeze” a lot more out of their HDR’s with this tool than with many commercial ones.
Obtaining the default charset (aka platform encoding) in JAVA
Monday, November 9th, 2009
Posted in: Charset, Platform encoding java, open source.
… is really simple since JDK 1.5:
java.nio.charset.Charset.defaultCharset()
So please don’t use messy, old workarounds such as this:
byte [] byteArray = {'a'};
InputStream inputStream = new ByteArrayInputStream(byteArray);
InputStreamReader reader = new InputStreamReader(inputStream);
String defaultEncoding = reader.getEncoding();
Which, unfortunately, is one of the first things you stumble upon when searching for this topic.
No CommentsUsing RPC-style, encoded Axis 1 webservices with spring-remoting
Monday, October 12th, 2009
Posted in: Axis 1, Jax-ws, Spring-Remoting J2EE, System architecture, java, open source.
Preamble
When working with enterprise integration you will quite often deal with legacy systems integration.
I recently had the case where integration of webservices was requested, and much to my surprise there are huge issues when attempting to integrate old webservices (as in pre axis2 and pre jax-ws).
These webservices use outdated or unsupported methods, such as rpc-style/encoded communication, or even worce, outdated elements in the XML messages, for instance <multiref>’s. Having to integrate such services does of course imply that you cannot change anything on the server side, and thus such an outdated format must still be consumed.
This is a huge problem, since current WS implementations, such as the popular axis2 framework, do simply not support these formats.
What surprised me the most about this is that webservices are designed to make systems independent by defining a common communication and data format, which is the exact opposite of what is going on here – and these formats are not that old, we are probably talking 4-5 years.
Developers facing these problems are taking rather desperate measures to work around these problems, such as using on-the-fly XSLT transformation to convert incoming and outgoing WS messages. However, this binds your application even stronger to the outdated format and specific service data.
In my case I wanted to use Spring-remoting. Since the service was RPC-style, I wanted to use the JaxRpcPortProxyFactoryBean to create an on-the-fly proxy implementing the service interface. What I did not want to do is having to write any additional code to consume the service. Furthermore, I wanted the complex objects transferred by the services to be represented by standard JAVA beans, and not be generated using the wsdl2java axis1 tools. Here is how I got this to work.
Read the rest of “Using RPC-style, encoded Axis 1 webservices with spring-remoting”
Using apache to redirect from the root “/” context to a webapp context
Monday, October 12th, 2009
Posted in: apache, java, open source, tomcat.
Just a short note:
The best way of doing this avoiding endless recursion is to use apaches RedirectMatch rule, like this:
RedirectMatch ^/$ http://targethost/mywebapp
Easy, agreed. But i’ve seen (and done it wrong my self) quite often…
No CommentsRunning mvn:release with Subversion 1.5.x
Monday, March 23rd, 2009
Posted in: J2EE, SCM, System engineering, java, maven 2, open source, subversion.
When attempting to prepare a release using maven and the maven-release-plugin, you are currently very likely to see your build fail with a message such as:
[INFO] Executing: svn --non-interactive copy --file /tmp/...commit . https://subversion..../tags/...
[INFO] Working directory: ...
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Unable to tag SCM
Provider message:
The svn tag command failed.
Command output:
svn: Commit failed (details follow):
svn: File '...' already exists
If you do, you are using subversion 1.5.x which no longer supports tagging from a local working copy, thus causing the unfortunately very misleading error message.
This is a known issue of the subversion sourcecode management (SCM) and there is a simple workaround:
Read the rest of “Running mvn:release with Subversion 1.5.x”
Modular development with OSGI about to be very, very popular – finally.
Monday, March 2nd, 2009
Posted in: J2EE, JPA, OSGI, System architecture, eclipselink, java, open source, spring.
It’s quite exciting to see the tremendous progress in development tools, patterns, frameworks and libraries since the release of JAVA 1.0 in 1996.
Within just thirteen years, development improved from the first applets, from the dark ages of the first EJB standardization attempts and a lack of suitable development processes into an age where aspect oriented programming, dependency injection and a freely available range of lightweight yet extremely powerful frameworks, libraries and API’s finally permitted the humble programmer to do what he always wanted to do – analyze problems, and elegantly write them down without spending all of his precious time on the syntax.
I would even go as far as saying that there was no object orientation before programming crosscutting concerns and using dependency injection became established mechanisms.
Think about it: The original goal of OO is not to use inheritance, encapsulation, identity and polymorphism, but to express the real world of things – our reality – using an abstract world of things, while preserving most of the properties and relationships we observe in reality.
Before AOP, before being able to separate the description of things from creating, configurating and connecting concrete instances through dependency injection frameworks, this goal was hard to achieve.
Modules larger than classes with OSGI
Now however, we are about to reach a new stage in development of object orientation in JAVA: Developing modules that are larger than classes, modules which can, once properly identified, be developed independently using all the wonderful technology described beforehand. The technology used to achieve this has a name: OSGI. This technology has quite a long history of development, but a certain lack of elegance and light-weightiness barred this component model from becoming a real hit in the worldwide development community. This is about to change.
Read the rest of “Modular development with OSGI about to be very, very popular – finally.”
Debian etch and “The following packages have been kept back…”
Sunday, February 15th, 2009
Posted in: System engineering, debian 4, lenny, open source.
Just for the record: It seems the new Debian Lenny release is close at hand.
Apparently a few packages for the lenny release already made it into the productive repositories, which causes them to be held back by apt-get upgrade:
apt-get dist-upgrade -V
Reading package lists... Done
Building dependency tree... Done
Calculating upgrade... Done
The following packages have been kept back:
libapache2-mod-php5 (... => 5.2.6.dfsg.1-1+lenny2)
libperl5.8 (... => 5.8.8-11.1+lenny1)
php-pear (... => 5.2.6.dfsg.1-1+lenny2)
...
apt-get dist-upgrade, which usually resolves this issue by upgrading the system to the most recent release does not work yet, since lenny was not released so far.
No CommentsRepository search for maven artifacts
Monday, November 10th, 2008
Posted in: java, maven 2, open source.
Most of the maven users know the site www.mvnrepository.com which provides a nice lookup of maven artefacts.
Now there is also a newer site, www.mvnbrowser.com which currently performs better than mvnrepository. In addition, you can lookup repositories actually containing your desired artifact – now that’s sweet!
Facts on open source projects for decision-makers
Friday, October 17th, 2008
Posted in: QA, System architecture, hibernate, ohloh.net, open source.
Summary
Finding useful information about open source software projects can be tedious – especially when trying to find facts that your customers understand.
ohloh.net provides excellent, comparable meta information for open source projects and should be on every decision-makers favorites list.
Why this software and not another?
I often find the need to justify the use of a specific open source software. Why is is better than another, competing open source software? How much better is the community support? How many supporters does it have? How active is the project and how much effort was spend on it’s development? How about metrics for the code, and how do you compare software in general?
Those are about the most important questions i have to answer.
Read the rest of “Facts on open source projects for decision-makers”