Google Guava : Annotations : Beta

Oh those guys rock. They've just put @Beta on the Beta itself, which is kinda showing that they have some wits but is practically useless.

Well, this is something like: "we'll mark some other entities in the project as to-be-soon-removed, including the marker itself, so - essentially, long term - the marker, our message and all relations thereof are void, there's nothing written here (long term, mind you, dumbo)".

...and this, as usually, is doomed to stick around for years, literally... 


Convert key + pem to jks (java keystore)

I had to convert ssl private key + cert chain from the format nginx understands to a format which jetty/tomcat understands.
Sounds pretty simple, but... well, I'd come up with so many ways to break the certificate chain that it deserves a separate post of its own.

So, that's the magic:

openssl pkcs12 -export -in mysite.pem -inkey mysite.key -out mysite.p12 -name "jetty"

And then you open the .p12 file with Portecle and simply do Tools > Change Keystore Type > JKS.
Don't forget to reset both key and keystore passwords: jetty/tomcat expect both passwords to be equal.

AFAIK there's no one-shot command to import .p12 into java keystore. At least with java 5 keytool. So I'd prefer to keep things more or less simple by using Portecle.

...oh, and this cool collection of examples for openssl/keytool simply has to be bookmarked: Not so few frequently used SSL commands


SO: graph/network library for java, Trove-style

Well, is there a high-performance graph library for working with primitivies, without those generics/autoboxing overheads? For double lists you may use trove, for linear algebra you may use netlib-java (examples for you to better understand the point of my interest in this question).
As for Graphs/Networks: all the libs I've found use generics and should be not that performant. I may as well do some tests for that, but I believe that heap-managed network link weights would be inferior to double[] with some bit offsets to get the index for i and j. The usage scenario: there're hundreds of such networks (most of them sparse) of size 4k*4k, there's some genetic optimization running over that set of networks, which do some flow/min route estimations for each specimen.
So, there're: JGraphT, JUNG, ANNAS (the links lead to the APIs/code samples which expose the miserable Java Generics in all of them). Are there any Trove-ish alternatives? I'd already created some simplistic implementation, but just decided to look around to avoid inventing the proper bicycle...
PS: Please don't start on performance of generics-laden Java code, at least without linking to some decent benchmark, ok? ;)
Some trolling was spiced in, but let's see how StackOverflow users will respond to that... :)

Genetic Algorithm in Java: library line-up

Watchmaker: Manual

ECJ: Manual

Jenes: Tutorial

JGAP: Sample code

JAGA: Javadoc

java-GAlib: seems to be inactive, so I did not dig too much

Bulk transcode TTA to FLAC

Done on ubuntu command line with bash and sed.
Proper escaping (and ordering of escaping) is a major pain, I should say...

find -type f -and -name "*.tta" -and -exec bash -c "ffmpeg -i '{}' \"\`echo '{}' | sed -e 's/ /_/g' -e 's/\.tta$/\.flac/g'\`\"" \;

UPD: This did not keep metadata on the files, so I had to use even more brutal method... :D


Сленг разработчика (2008)

Самое время немного посмеяться - вечер пятницы. Я тут нашел на своем старом сайте для студентов небольшую объясняловску по поводу фольклора, с которым они могут столкнуться если я им что-то рассказываю по разработке.
Этой штуковине уже два года, так что кое-что уже устарело. 

  • репа - репозитарий SVN, в некоторых (редких) случаях может иметься в виду local maven repository (второе чаще всего называется "репкой")
  • тянуть репу - получать рабочую версию проекта, тобишь делать svn checkout
  • песочница - локальная рабочая версия проекта
  • залить - сохранить изменения песочницы в репу
  • нолито! - репа обновлена, следует обновить песочницы
  • дать в репу - передать другому разработчику необходимые ему изменения через репозитарий, в некоторых случаях связано с передачей больших бинарных файлов
  • тазикстанокпылесос: рабочая станция, персональный компьютер
  • калдырить - следить за процессом сборки версии продукта
  • закалдырить - собрать продукт, собственно, завершить процесс калдыряния (иногда под этим еще понимается и развертывание версии на тестовой или производственной платформе)
  • завалить сборку - допустить ошибку компиляции или тестов, и не обнаружив ее, дать в репу коллегам, нарушив тем самым их беззаботное калдыряние

Ну вот как-то так. Ежели кто еще какие плюхи за мной (или собой) вспомнит - милости прошу в комментарии!

Networks, Crowds, and Markets: Reasoning about a Highly Connected World (David Easley, Jon Kleinberg)

Kinda short review/notes on the Cornell's book I'd been referred almost a year ago (download, amazon).

Well, I was able to read 13 chapters of 24. Then the authors got to the structure of the web, heavy tails and small worlds, which are quite more familiar for me - so I started skipping.
Percolations and spectras were discussed at mere basics, so there was nothing quite new/interesting for me in the book, though some of game theory was quite a nice refresher.

The gross volume of the material does not deserve 800 pages: some of the general whatnot should be evicted from the book, especially in the beginning chapters.
In most cases couple of formulas are quite sufficient and should not be duplicated by two or three paragraphs of redundant examples (or at least some styling should denote those "for-dummies" sections).

BTW: chapter 23 on politics and state seems to be of some marginal interest. No explicit discussion of networked warfare in there, so...


How to: Install Maven on Windows

Well, there's no easily googlable howto on getting started with Maven on a Windows box. And I'm a bit tired of explaining the same thing for so many times, so...

You should have Oracle's JDK set up properly, more on that in a moment.

Here we go, step by step:
1. Grab the latest version of the maven distro from the maven binaries
this, for the time being, is the version 3.0.2

2. Unpack that distro to some convenient public place where you store your development tools.
Something like
would be perfectly fine - short path without any spaces...

3. Then we have to ensure that main maven executable,
is seen in the PATH (so you're able to run it from any other folder)
We do this simply by hitting Win+Pause and switching to the Advanced Tab and hitting Environment Properties:

Then you choose the PATH property (global, not a per-user one), and edit it away as shown:
edit the PATH to enable maven
 Now couple of OKs and you're mostly done, hopefully.

4. Now fire up a command prompt (on most systems this would be win+r cmd <return>).
It should not really matter which current directory you use. Just run the command
mvn -version
this should report something aligned with the version you've downloaded and installed.
This should actually be quite like that my linux maven installation says to me:

anton@arcano:~$ mvn -version
Apache Maven 2.2.1 (rdebian-4)
Java version: 1.6.0_22
Java home: /usr/lib/jvm/java-6-sun-
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.35-25-generic" arch: "i386" Family: "unix"

5. Of course, you ask me next - "Okay, so we installed that thing, but how do we use it?"...
Well, don't close the console you've fired in the step #4. Just change the current working dir to the location of your maven project, and fire one or another magical command from the list below:
mvn clean package - do a full clean build of the project, fetching the libraries off the public internet repository, run a basic set of project unit-tests...
mvn dependency:tree - just check which submodules use which libraries
mvn site - generate project documentation
Oh, and note that simple cd command won't switch you across system disks in windows. You need to issue d: command to switch current directory to disk d: and so forth.


Ubuntu package management

If you have any heavy packages recently installed (and are going to wipe the system for any reason), you might look into

ls -l /var/cache/apt/archives

to see which might be restored to the same place to avoid repumping them.

A quick way to see which packages are related to something is

apt-cache search java

Another less quick but more detailed, also shows what is installed on your system, is

dpkg -l '*java*'

You may see what was installed and when (for maverick)

less /var/log/apt/history.log

or, less conveniently (for lucid)

less /var/log/apt/term.log