Wireshark on remote host through SSH

I was trying to find a way to capture the network interface traffic on a remote server, just to see what (or who!) messed up the Web Services based communication. I didn’t have to search too long, because my favorite capturing software, Wireshark, can listen on a named pipe. So, below you can find the simplest solution I found (SSH + FIFO) based on this tutorial: On the client side (my computer – GNU/Linux) type:...

April 22, 2011 · 1 min

Kdenlive -- cannot render in Xvid, H.264, MPEG-4, etc.

It’s at least the third time I try to find a solution for the unavailable codecs proclem during rendering video project in Kdenlive. This time, I’ll write it down and link to this great site to make sure I’ll be able to easily find it next time ;-) The process is quite simple (I’m using Ubuntu 10.10 x86) – just install all the codecs in their full versions: sudo apt-get install libavcodec-unstripped-52 libavdevice-unstripped-52 libavformat-unstripped-52 libpostproc-unstripped-51 libswscale-unstripped-0 and execute the KDEnlive wizard (Settings menu)....

April 1, 2011 · 1 min

BASH -- find files with names different than the pattern

If you’re using BASH find and want to find files which are named differently than the given pattern, you can use the following syntax: find . -type f ! -iname "*.class" The above command will find all files in the current directory (and subdirectories) which have the extension different (exclamation mark) from “class” (case insensitive). You can also use conditional operations to build slightly more complicated commands, like: find . -type f !...

March 27, 2011 · 1 min

Java EE 6 SCWCD Mock Exam

The mock exam has been moved to a separate application working on the OpenShift and is available at exam.piotrnowicki.com. This post will be still available because of the comments – at this point the exam simulator doesn’t have the commenting functionality so you can leave your opinion here. In time it’ll be modified and will allow to post comments directly next to the questions. If you’d like to get more information about the exam migration take a look at this post: New OCE WCD Exam Simulator....

March 27, 2011 · 1 min

Using Servlets 3.0 ServletContainerInitializer

Servlets 3.0 in Java EE 6, brings new interface called ServletContainerInitializer. The name is very self-explanatory, but the question is – how it’s different from the ServletContextListener? Well, technically, the ServletContainerInitializer is not a listener – it is an initializer and it’s executed before any servlet context will even be ready. You can use this initializer to do some programmatic servlet/filters/listeners addition (which is also possible in Servlets 3.0!). The ServletContainerInitializer....

March 20, 2011 · 2 min

Defining JSP version for Tag Files with implicit TLD

If you want to use new features of JSP >= 2.1 and EL, like deferred binding (the #{…} construction in EL), you’ll find that you cannot achieve it within a Tag File with implicit TLD generation. It is simply because the implicit TLD defines that the Tag File is using JSPs in version 2.0. How to solve it? There are two possible solutions: deliver an explicit TLD for your Tag Files, modify the implicit TLD form....

February 20, 2011 · 2 min

Precision and scale in BigDecimal and MathContext

Lately, after publishing the previous post, a friend of mine passed me a snipped of BigDecimal code. He was wondering, why the following execution: BigDecimal a = new BigDecimal(2.9); BigDecimal b = new BigDecimal(4000); MathContext mc = new MathContext(2, RoundingMode.HALF_DOWN); BigDecimal r1 = a.multiply(b, mc); BigDecimal r2 = a.multiply(b).setScale(2, RoundingMode.HALF_DOWN); System.out.println("r1 = " + r1); System.out.println("r2 = " + r2); is returning different values for r1 and r2: r1 = 1....

February 5, 2011 · 2 min

Float and double in Java "inaccurate" result

There is a well known problem with precise floating point numbers representation in a computer, and Java is no different in this case. If you want to see it for yourself, than try executing the below code: Double d = new Double(4.395f); System.out.println(d); You might expect the 4.395 will be printed out, right? Well, you’re defining an “exact” number as a float (32 bit), than casting it to the double (64 bit) so there should be no problem, as it shouldn’t affect the value....

February 4, 2011 · 3 min

Eclipse Go to... interface method implementation

In Eclipse you can open a method definition if you point the method name (its invocation), and hit ctrl + LMB. You can also achieve the same if you select the method call and hit F3, and probably in few other ways. Try to use this feature on the interface type… What’s annoying is that when you use this shortcut on a method which uses an interface type rather than the implementing class, you are forwarded to the interface method declaration....

January 31, 2011 · 1 min

Executing SSH commands from ANT

Sometimes, when building an application, there is a need for some SSH command execution on the remote server. An example of such command could be: Redeployment of an application, Server restart, Temporary files removal, Custom script execution. Have no fear – SSHExec is here! You can easily achieve remote command invocation, using an ANT Task sshexec. An example of its usage could be this snippet (note that remote.* variables are taken from the *....

January 31, 2011 · 1 min