środa, 29 lutego 2012

Extract sound from YouTube MP4 videos to Ogg Vorbis files

I simply googled up dir2ogg man page
Then I used it in such a way on a current directory (use --delete-input if you want to delete the source files - I didn't want to until I have checked the results):
dir2ogg -q 1 -a .

sobota, 18 lutego 2012

Hamcrest everyItem matcher

Couldn't make that matcher work. Even found the solution http://blog.dutchworks.nl/2011/02/19/some-trouble-with-getting-the-right-version-of-hamcrest-and-the-solution/
...but somehow it didn't work - probably I was tired and made some stupid mistake.
Eclipse compiler kept complaining about some generics type mismatch. Then I extracted a matcher to a local variable and added a type (SomeObject below) to it. And the it worked. And - as you can see in the second matcher usage - after inlining a matcher the syntax is the syntax from the blog post above - and it works - this time. BTW - IDE refactorings are really useful. Even more than I thought.
// the service method we want to test
List<SomeObject> results = service.doSomething(parameter);
assertEquals("unexpected size", 3, results.size());
// a matcher which basically checks that someObject.getLabel() == "generic"
Matcher<SomeObject> labelTypedMatcher = hasProperty("label", is("generic"));
// and now we want to ensure that all the results meet the condition above
assertThat(results, everyItem(labelTypedMatcher));
// you do not have to create local variable, but then the syntax is, well, unusual a bit
// now we want every object meet the condition (someObject.getTypeId() == "generic")
assertThat(results, everyItem(Matchers.<SomeObject>hasProperty("typeId", is("007"))));

środa, 15 lutego 2012

How to use Konsole with OpenExtern in eclipse

"Konsole is the X terminal emulator of KDE with support for several sessions" as you can learn from konsole.kde.org
Open extern "an eclipse plugin, which you can use to open a shell (either a command prompt - CMD or a linux shell), or a folder (windows explorer, nautilus, konqueror) from eclipse's resource navigator or package explorer" - see http://code.google.com/p/openextern/
Now it is useful, simply, and Konsole has a parameter to specify working dir, just use it.
Choose Window-Preferences in eclipse, Open extern has its own entry there. Set for "open shell command" the value (the 2nd option prevents Konsole from creating a new window):
konsole --workdir {path} --new-tab

środa, 1 lutego 2012

How to quickly call a stored procedure in Spring

If your procedure does not take parameters nor return any values (or you're not interested), do just that:

DataSource dataSource = getDataSourceSomehowMostProbablyFromYourSpringContext();

SimpleJdbcCall theProcedureCall = new SimpleJdbcCall(dataSource).withProcedureName("myproc");

That's it