Groovy documentation and the human mind

How can one not be disappointed with Groovy after looking at its User Guide?

Here is just one example. Can you tell from the StreamingMarkupBuilder documentation how it works? I bet no. After looking through the code snippets on the page and figuring out I could not understand a line of code there, I wondered what is the mkp variable that appears twice on the page.

It took me some time to get through the Groovy class hierarchy up to the just to find the mkp namespace declaration.

 namespaces.put("mkp", "");   // pseudo namespace for markup keywords

After googling for mkp markup keywords, I found a page that explains in a few words the design of markup builders. Nothing more, nothing less. Now, I know everything I had to know about mkp and markup builders. The thing is, it is a post of the developer who just committed the markup builders feature. The documentation is supposed to be better that that but it not even worse, it is blatantly misleading.

Controlling the size of the $PWD in bash, version 2

Er... after reading the insightful comments at, I figured out a much shorter version which is also easier to understand. Tested on GNU bash, version 3.1.17(1)-release (i486-pc-linux-gnu).

{syntaxhighlighter brush: bash} function truncate_pwd { newPWD="${PWD/#$HOME/~}" local pwdmaxlen=$((${COLUMNS:-80}/4)) if [ ${#newPWD} -gt $pwdmaxlen ] then newPWD=".+${newPWD: -$pwdmaxlen}" fi } PROMPT_COMMAND=truncate_pwd PS1="${ttyname}@\h:\${newPWD}\\$ " {/syntaxhighlighter}

Controlling the size of the $PWD in bash

I just fixed a 6-year old bug in the 5 lines of code that I use at least 100 times a day, every day, including weekends and holidays. Now, I can finally publish it.

function truncate_pwd
 if [ $HOME == $PWD ]
 elif [ $HOME ==  ${PWD:0:${#HOME}} ]

  local pwdmaxlen=15
  if [ ${#newPWD} -gt $pwdmaxlen ]
    local pwdoffset=$(( ${#newPWD} - $pwdmaxlen  ))

PS1="${ttyname}@\[${HOST_COLOUR}\]\h\[${RESET_COLOR}\]:\${newPWD}\\$ "

Just put the above snippet of code into ~/.bashrc

Debian shows the absolute path in the command prompt by default, and it can be really long, sometimes.To fix this, we can limit the command prompt to show only the last x characters using only the variable expansion features of bash 2.0.5+. Since this code does not fork out sed, tr or wc, it is blazingly fast.

Java sucks where Python rulez

There's been a long-standing commitment from Sun to make Java backwards-compatible. It made introducing new features in Java painful (generics), and fixing bugs (java.sql.Timestamp vs. java.lang.Date) impossible. On the other hand, that huge Java Class Library really needs refactoring and compatibility breaking is the only way to improve the developer experience.

Python development goes on in a completely different manner. They are set on producing a partially incompatible version called "Python 3000" that will fix the major design flows of the language (e.g. crappy i18n).

I hope Java does the same or dies.

Using GNU screen's multiuser feature

I am regularly doing the LLOD support over phone+remote console to the production support guys. Our software runs on virtualized headless Fedora 5 instances that are accessible solely by ssh, as it should naturally be.

It turns out to be a waste of time to the person on the other end, as he just listens to me explaining what I do, without really seeing what goes on.

So, I decided to use GNU screen to share the console between us.

I log in as a user and start screen on the command line. Then, I enter ^A:multiuser on[RET]. That is, I type Ctrl-a, then I type a : to enter the screen's build-in command line. I can now activate the multiuser mode by typing multiuser on in the screen's command line that appears in reverse color at the bottom of the console window. To execute, I hit Return.

The other guy just has to log in with the same user and type screen -x to connect to my screen session running in multiuser mode.

Что делать?

В течение долгих лет у меня идёт вялотекущий спор с che по поводу причин оттока интересных людей из Беларуси. Из года в год уезжают отличные собутыльники, идеальные коллеги, люди, выделяющиеся из общей среды умением отдыхать и работать, смекалкой и бодрым настроением. Остаются чуть более ленивые, привязанные к семье, чуть более неуверенные в себе. Замечательная статья с продолжением отвечает на вопрос "Кто виноват?". Как ни крути, молодёжь растёт на канонах, далёких от современного уклада беларусского общества. Многие не находят себе места во взрослой жизни, но только некоторым удаётся сорваться с места и попробовать себя на новом месте, в чужой среде.

Так вот, вопрос, который задаёт che и на который у меня до сих пор нет чёткого ответа -- "Что делать?". Что нужно изменить в Беларуси, чтобы уменьшился отток интересных людей?

What is the thousand separator in french numerals?

Linux says, it's U0020 aka SPACE

$ grep mon_thousands_sep /usr/share/i18n/locales/fr_FR
mon_thousands_sep         "<U0020>"

Java says, it's U00A0 aka NO-BREAK SPACE as the following code returns "160", better known as as in &#160; or &nbsp;

NumberFormat numberFormat = NumberFormat.getInstance(Locale.FRANCE);
            System.out.println(numberFormat.format(new BigDecimal(1000)).codePointAt(1));


NumberFormat numberFormat = NumberFormat.getInstance(locale);
if (numberFormat instanceof DecimalFormat) {
  DecimalFormat decimalFormat = (DecimalFormat) numberFormat;
  bd = (BigDecimal) decimalFormat.parse(string);

parses only U00A0 as the thousands separator.

Where's the truth, brother?

JSF, dead born, resurrected by hormonal injections

I tried to look over the internet for an article critical of JSF technology. Surprisingly I found nothing worth mentioning. This is really strange, as JSF lends itself easily to critics. The whole idea if JSF looks suspicious. It was built as a Java answer to the Web Forms concept from Microsoft. The whole buzz around JSF was about being able to use a GUI editor to build web pages à la MS Visual Studio.NET.