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 ]
 then
   newPWD="~"
 elif [ $HOME ==  ${PWD:0:${#HOME}} ]
 then
   newPWD="~${PWD:${#HOME}}"
 else
   newPWD=$PWD
 fi

  local pwdmaxlen=15
  if [ ${#newPWD} -gt $pwdmaxlen ]
  then
    local pwdoffset=$(( ${#newPWD} - $pwdmaxlen  ))
    newPWD=".+${newPWD:$pwdoffset:$pwdmaxlen}"
  fi
}

PROMPT_COMMAND=truncate_pwd
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));

Also,

NumberFormat numberFormat = NumberFormat.getInstance(locale);
if (numberFormat instanceof DecimalFormat) {
  DecimalFormat decimalFormat = (DecimalFormat) numberFormat;
  decimalFormat.setParseBigDecimal(true);
  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.

My ideal development team

When choosing between features, deadlines and maintainability, they always choose maintainability.

They have settled on a development methodology, be it Evo, Scrum XP or some home-made cocktail and follows that methodology rigorously.

They do not let themselves run by MS Project plans but rather by a backlog of features and by on-site customer demands.

Pages