RIP Dennis Ritchie


I have just happened to know about Dennis Ritchie's death. He was scientist and programmer. His work was the basis for the modern informational technologies world. IPhones and Androids, Mac OS X and Windows — this is a far incomplete list of things he contributed either directly or indirectly. Though he died on October 9th news of his death passed by me until today. It was drowned in a stream of sorrow for another deceased IT person Steve Jobs. I feel this is deeply unfair. The world has chosen to send their grief to pompous businessman who earned his billions on the work of modest scientists like Ritchie was. I choose to grieve about the former. Rest in piece, mister Dennis Ritchie.

How to disassemble Logitech Deluxe 250

logitech_deluxe_250_disassemble_hint
In case you need to disassemble Logitech Deluxe 250 PS/2 keyboard for some reason, that's what you need to know (same applies to 350 model and probably some other vintage Logitech keyboards). Besides the large number of screws on the back, which are pretty simple to find and untwist, there are another 4 of them. Two screws are located under the small rubber legs on the back. You need to remove them legs accurately and, yes, you will need to use glue to put them back. Two more screws are located under the keyboard buttons: one is somewhere around the Caps Lock and another one is under the Numpad «+» key. To remove the button, simply put the screwdriver under one and gently press until button is unhooked from the board.

I have published this simple hint like year ago in the Russian part of my blog and still I see a lot of people finding it useful. Let's see whether it helps someone outside RUnet :)

Bash-fu. Amount of virtual memory allocated by the process

I was needed a way to get amount of virtual memory currently used by the process. Came up with this solution (parsing from ps aux):

MEMORY_USED=`ps aux | awk -v pid="$PID" '{ if ($2 == pid) print $5 }'`

PID is the process identifier.

Home, End, Page Up and Page Down in Terminal.app

Currently I am doing a lot of iPhone development. That`s the reason for using Mac OS X a lot. Just found a fix to annoying Terminal application issue. By default Home, End, Page Up and Page Down are working completely wrong there. It is not that hard to google a fine solution. For instance, I found one here. However, it was not great still, 'cause Home and End still failed under some circumstances. Fixed these with info in someone's suggestion, so it is even works in vim.

So, you just need to go to «Keyboard» tab in app preferences. Find keys in long list there and change values to “send string to terminal:” with these strings:

Home \033[7~
End \033[4~
Page Up \033[5~
Page Down \033[6~

Suddenly, it works.

Geographical News 2012

Euro 2012 logo was revealed recently.

euro2012_logoLooks nice. Agree to Aleksey, it is much better the «Zochi2014dotru».

Also, see a funny presentation video. There is a map shown for couple of seconds with sign in place of Belorussia, which reads «Baltic Sea». Like this:

Continue reading

MySQL C++ Connector Fail

In current project I need to connect to MySQL DB from C++ code. MySQL developers provide different connectors for varios languages, including C++ one. It seemed like a good alternative to libmysqlclient, which was hard for direct usage.

That proved to be a bad idea. Random crashes of the most annoying type: caused by corrupted memory. I spent several hours trying to figure out where the problem was with no success. At this point I started to suspect problems in C++ connector. However, decided that bugs of such kind were unprobable in official library. Because they happen on rather simple test case. I decided to take a break at that point and first complete some essential functionality (deadlines, you know). So I did.

On the second stage of hunting down the bug I armed with hardware watchpoints and memory allocation utilities. More hours of debugging and I was sure about MySQL connector problem. Googling revealed the message on MySQL mailing list. Message poster lurked into the connector sources (that was I was going to do) and found serious memory allocation problems there. If you are interested in details, follow the link above.

So, I had the code harshly rewritten to work with libmysqlclient and was happy, since everything had worked fine.

Conclusion:

  1. Do not use MySQL C++ Connector. That`s a weird poorly maintained project.
  2. Never trust 3rd party code, even if it seems to come from reliable source.

UPD. BTW, there is also mysql++. Had no chance to try out, but looks good.