2006-09-10 20:15

September 10th, 2006 by Vasil Kolev

Sunday == laziness.

I tried cleaning up my ICQ contacts list… There was some progress, from 398 people it went to 300, but it’s starting to get weird where from have I found them :) Also it’s a bit bad, because the ICQ itself has a limit of 200 contacts – adding new is somewhat working, but for some reason the moving between groups is not. I wonder how can some more people be persuaded to switch to jabber…

Some whining – it’s a common mistake for most people to take one ntp server and use use it, without seeing it disappear later. I’ve seen ntp.fau.de, time.nist.gov (which still exists, but is far away) and in a cast at where I work – at.digsys.bg (which died recently) used. I have no idea why people don’t remember that there is pool.ntp.org, whose idea is not to drown one particular NTP server…
(which reminds me that I might enter marla or zver in pool.nto.org, because there still isn’t a Bulgarian server).

It’s also known that on the 20th I’m flying to L.A., on the 27th I’m flying back…

The reading of the Risks digest is going on slowly, but is full with fun pieces, one of which I just have to republish:

A comment on UNIX and C: Ken Thompson is one of the most brilliant designers and programmers ever to grace this earth. He developed UNIX and C primarily for his own pleasure. It is not HIS FAULT that UNIX is so widely used (e.g., because of its delightful facilities for program development and ease of adaptation), or — by extension — that it is used unwisely in hostile environments despite its not having addressed critical security concerns.

And Saturday on the anime meeting there was an interesting combination from a tape player on batteries, my laptop and one extremely weird converter from stereo jack to a tape – near the statue of the soviet army on the cubical thingy I was playing some interesting things, I even enlightened some people on what Tool is :)
(and the Piano tribute turned out to be horrible. The one playing it should be banned from touching a piano)

2006-09-10 20:06

September 10th, 2006 by Vasil Kolev

Неделя == мързел.

Хванах се да си почистя листа с контакти на ICQ-то… Има напредък, от 398 човека стана на 300, но започва да ми става странно откъде толкова много хора :) Също така е и малко неприятно, понеже самото ICQ има лимит на 200 човека – добавянето на нови хора се получава, ама по някаква причина местенето м/у групи – не. Чудя се как ли мога да убедя повече хора да минат на jabber …

Да измрънкам за нещо – редовно се случва хората да си харесат един ntp сървър и да го ползват, без да се усетят като изчезне. Така съм виждал да се ползва ntp.fau.de, time.nist.gov (който го има, ама е далече), и в един случай при нас – at.digsys.bg (което наскоро изпадна нейде). Не знам защо хората не се сещат, че има pool.ntp.org, чиято идея е точно да не се дави един определен NTP сървър…
(което ми напомня, че скоро може да включа marla или zver в pool.ntp.org, че май още няма български сървър).

Финално е и ясно, че на 20ти летя за L.A., на 27 летя наобратно…

Четенето на Risks digest върви бавно, но е пълно с бисери, един от които просто не мога да не спомена тук:

A comment on UNIX and C: Ken Thompson is one of the most brilliant designers and programmers ever to grace this earth. He developed UNIX and C primarily for his own pleasure. It is not HIS FAULT that UNIX is so widely used (e.g., because of its delightful facilities for program development and ease of adaptation), or — by extension — that it is used unwisely in hostile environments despite its not having addressed critical security concerns.

А в събота на anime срещата се направи интересна комбинация от един касетофон на батерии, моя лаптоп и един адски странен преходник от стерео jack до касетка – до паметника на съветската армия на кубчестото пусках разни интересни неща, та май просветих хората и какво е Tool :)
(а Piano tribute се оказа ужасен. Тоя, който го свири, трябва да му забранят да пипа пиано)

2006-09-07 21:16

September 7th, 2006 by Vasil Kolev

Life is good…

There’s something nice in that that most of the coups and in general politically significant events in Bulgaria have happened in the autumn (mostly September), so we can rest after the summer… Wednesday I had a nice rest and came back to my senses, today was the day of st. Moneypour Cashbringer, Tuesday I and the girlfriend separated (we’ve grown tired of each other), so the week was somewhat okay :) I’m now lying in the chair with the beer and listening to Irfan…

I’m looking for the Piano tribute to Tool, does someone know where can it be found? Also the normal tribute, if someone has it :)

Today Damyan gave me the Debian t-shirts, soon a photo will follow – they’re great :)

2006-09-07 21:11

September 7th, 2006 by Vasil Kolev

Животът е хубав…

Има нещо хубаво в това, че повечето преврати и въобще политически значими събития в България са се случвали есента (основно септември), да можем да си починем след лятото… В сряда си починах и поосвестих, днес пък беше деня на св. Паралей Кинтоносец, вторник се разделихме с жената (с която сме си поомръзнали), та седмицата се оказа приблизително поносима :) Лежа си в стола с биричката и си слушам Irfan…

Търся си Piano tribute to Tool, някой да знае откъде може да се открие? Също така и нормалния tribute, ако му се намира на някой:)

Днеска Дамян ми даде Debian-ските тениски, скоро очаквайте някоя снимка – страхотни са :)

2006-09-03 12:01

September 3rd, 2006 by Vasil Kolev

These are a few small tricks I use to gather stats and see how the data looks like…

(a note – this is mostly postgresql related, but is easily ported to another database)

Let’s say we have a table in the database, which looks like a log file, with two columns – timestamp and event_id, which is integer from 1 to 5. The tasks is to get in X minute intervals what type of event happened how much times and to draw them.

The first step is the following query:

SELECT  
	((EXTRACT(epoch FROM timestamp)::int/90)*90) AS period,
        SUM((event_id=1)::int) AS type_1,
	SUM((event_id=2)::int) AS type_2, 
	SUM((event_id=3 OR event_id=4 OR event_id=5)::int) AS type_rest,
	SUM(1) AS all
FROM
	log
WHERE 
	timestamp => '2006-08-28 00:00:00' AND timestamp < '2006-08-29 00:00:00'
GROUP BY
	period 
ORDER BY
	period ASC;

(thanks to Aqua for the testing ang the notes :) )

A short explanation - period is a timestamp rounded to 90 seconds (using integer division), which we use to do the grouping. For every such period we're counting how many of each event we have with the small trick with the typecast - true is 1, false is 0, which means that if the condition is satisfied, the sum will increase. This way we're counting what' in the table with one pass through it.

Some notes for the query:

1) date_trunc can be used instead of the EXTRACT trick, but it can't round to stuff different than a minute or hour.
2) In the older versions of postgresql (before 8) by default there's not typecast from boolean to integer, but in the documentation there's an example how to create one.
3) Instead of the trick with SUM() a grouping by event_id can be used, but to be able to combine a few event_ids again some boolean trick has to be used. Also getting the whole count and solving the problem for 0 count of some event_id for some period will be harder.
4) Instead of SUM(1) in the end COUNT(1) can be used, but I don't see a big difference.
5) BETWEEN can be used in the WHERE clause, but I like this more :)

To get the data in format, useful for drawing, we need the following line:

psql -A -q -t -F ' ' $DBNAME -c "$QUERY" > data

(what the options do, you can see in the man page :) DBNAME is the database, QUERY is the query from above)

We'll have one file with the following type of lines:

1156748310 23 12 6 41
1156748400 28 21 5 54
1156748490 32 15 2 49
....

Here gnuplot comes into the game, with the following commands to make a nice drawing:

set title "Events through the day, quantised at 90 sec. (fig. 1)"
set ylabel "number of events"
set xlabel "time through the day"
plot "data" using 5 with lines title  "all", "data" using 4 with lines title  "rest", \
	"data" using 3 with lines title  "type_1", "data" using 2 with lines title  "type_1"

And with putting these two lines in the beginning it will write the thing to file:

set terminal png font VeraSe 11 size 800,500
set output "test.png"

Of course, it would be great to write the hour underneath, but I still haven't thought up a way to do it :)

2006-09-03 11:23

September 3rd, 2006 by Vasil Kolev

Това са няколко дребни трика, които ползвам за вадене на статистики и да видя кое как изглежда…

(предварително да кажа – това се отнася за postgresql, но се пренася за каквато и да е база доста лесно).
Да кажем, че имаме една таблица в базата данни, която ни е като log файл, с две колони – timestamp и event_id, който е integer и е от 1 до 5. Задачката е да извадим в по X минутни интервали от кой тип event колко са се случили и да ги нарисуваме на една графика.

Първата стъпка е следната заявка:

SELECT  
	((EXTRACT(epoch FROM timestamp)::int/90)*90) AS period,
        SUM((event_id=1)::int) AS type_1,
	SUM((event_id=2)::int) AS type_2, 
	SUM((event_id=3 OR event_id=4 OR event_id=5)::int) AS type_rest,
	SUM(1) AS all
FROM
	log
WHERE 
	timestamp => '2006-08-28 00:00:00' AND timestamp < '2006-08-29 00:00:00'
GROUP BY
	period 
ORDER BY
	period ASC;

(благодарности на Aqua за тестването и забележките :) )

Кратко обяснение - period ни представлява timestamp, закръглен до 90 секунди (чрез целочисленото деление), по който групираме. За всеки такъв период броим от кой event_id колко имаме с дребния трик с typecast-а - true е 1, false е 0, което значи, че ако условието е изпълнено, самата сума ще се увеличи, ако не - няма. Така реално погледнато преброяваме какво се среща в таблицата с едно преминаване през нея.

Няколко забележки към заявката:
1) Може да се използва date_trunc вместо трика с EXTRACT, но не може да се закръгля на неща различни от минута или час.
2) В по-старите версии на postgresql (преди 8) няма по подразбиране typecast от boolean към integer, но в документацията има някъде един пример как може да се напише тоя typecast.
3) Вместо номера със SUM() може да се ползва и групиране по event_id, но за да се обединят няколко event_id-а пак трябва да се прибегне до някакъв boolean трик. Също така ще стане по-сложно взимането на общата бройка и решаването на проблема с 0 срещания на някой event_id за даден период.
4) Вместо SUM(1) накрая може да се ползва COUNT(1), но не вярвам да има особена разлика.
5) Може да се ползва BETWEEN в WHERE клаузата, но на мен така повече ми харесва :)

За да си докараме данните във вид, подходящ за рисуване, ни трябва следния ред:

psql -A -q -t -F ' ' $DBNAME -c "$QUERY" > data

(какво правят опциите може да видите в man-а:) DBNAME е базата, QUERY e заявката от по-горе)

Ще се озовем с един файл data, в който ще имаме следния тип редове:

1156748310 23 12 6 41
1156748400 28 21 5 54
1156748490 32 15 2 49
....

Тук влиза в действие gnuplot-а, който със следната команда ще ви направи една доста приятна рисунка:

set title "Events through the day, quantised at 90 sec. (fig. 1)"
set ylabel "number of events"
set xlabel "time through the day"
plot "data" using 5 with lines title  "all", "data" using 4 with lines title  "rest", \
	"data" using 3 with lines title  "type_1", "data" using 2 with lines title  "type_1"

А с добавката на тези два реда в началото ще ви напише графиката във файл:

set terminal png font VeraSe 11 size 800,500
set output "test.png"

Разбира се, би било хубаво да можеше да се напише и часът отдолу както си трябва, но още не съм измислил как :)

2006-09-02 16:29

September 2nd, 2006 by Vasil Kolev

Another tiring week, in which one of the days got stretched until 12:30 in the evening…

Friday was a day for some drinking and eating at Halbite with Velin and chervarium, after which we went to Velin’s to hear his new audio system…

Here I can try getting out with the words ‘you have to hear it to understand it’. In short, it’s the first time I’m listening to something so clear (like in Carmina Burana in the beginning you can hear that one of the instruments is a big bell), the volume is ok (the wall vibrates a bit) and in the end I’m thinking about such system. There seems to be a difference between the transistor and lamp amps :) (his is right now 1.5W (no, that’s not a spelling mistake)).

I finished reading “The mortification of the mind…”, turned out really good. One of these days I’ll go to BAS to find “The court on the historians” at the bookstore of the publishers (I even believe myself, knowing how bad my schedule is).

I’m thinking about writing a small article here on some small tricks which I use almost constantly (like a sum of boolean expressions, typecast to integer), and some small stuff about gnyplot (which is a really useful tool to understand some data).

2006-09-02 16:10

September 2nd, 2006 by Vasil Kolev

Поредната уморителна седмица, в която единия от дните се разпъна до 12:30 вечерта…

Петъкът беше отделен за прилично напиване и наяждане в Халбите с Велин и червото, след което отидохме до Велин да му чуем новата озвучителна система…

Е тук вече мога да пробвам да се измъкна с лафа ‘ами трябва да го чуете, за да го разберете’. Накратко, за пръв път слушам толкова ясна каквато и да е музика (например на Carmina Burana в началото може да се разпознае, че едно от нещата е камбана), силата е приятна (леко вибрира стената) и изобщо мисля и аз да си взема нещо такова. Имало то разлика между транзисторните и ламповите усилватели :) (неговия в момента е около 1.5W (не, няма правописна грешка)).

Изчетох “Усмиряването на разума…”, оказа се доста добра книга. Ще ходя тия дни до БАН да си потърся “Съдът над историците” в книжарницата на издателството (даже си вярвам, въпреки че се знам как съм със времето).

Мисля днес/утре да напиша и една малка статийка за тука на тема някои дребни номера, които прилагам почти постоянно (например сбор от boolean изрази, typecast-нати към integer), както и малко неща около gnuplot (който си е бая ценен инструмент за осъзнаване на разни данни).

2006-08-25 22:04

August 25th, 2006 by Vasil Kolev

I slept two days. And will do the same for the coming two :)

I took some vacation before freaking out and I’m feeling how good the laziness is for me. I’m sleeping, reading a bit, watching some stupid stuff, and outside isn’t that hot :). I even managed to go out and get new shoes (because the old ones were trying to fall of my feet).
(of course, there are still some work-related calls and even an hour ago I was working on something, but there’s no escaping from some things)

I bought an interesting book about BAS (“Mortification of the mind. The reorganisation of the Bulgarian academy of sciences 1944-1953” by Nadya Zhivkova) and because of it I’m wondering where can I find “The court on the historians” by V. Mutafchieva (the publishing house of BAS has a catalogue since 2000, and the book was published 1995).
(and is it just me, or that in principle the books related to the newest history are really hard to find?)

2006-08-25 21:58

August 25th, 2006 by Vasil Kolev

Два дни спя. И следващите два пак това ще правя :)

Взех си малко отпуска преди съвсем да полудея и усещам колко добре ми се отразява мързела. Спя си, чета си по малко, гледам разни глупости, а навън (изглежда в моя чест) не е толкова горещо :). Успях даже да си взема нови обуща (понеже старите се опитваха усилено да се разпаднат).
(разбира се, пак ми се звъни по разни въпроси и преди малко работих в/у един проблем, ама няма как…)

Взех си и една доста интересна книжка за БАН (“Усмиряване на разума. Преустройството на Българската академия на науките 1944-1953” на Надя Живкова) и заради нея се чудя откъде мога да си намеря “Съдът над историците” на В. Мутафчиева (издателството на БАН има каталог само от около 2000, а книгата е издадена 1995).
(изобщо само на мен ли ми се струва, или по принцип историческите книги, свързани с най-новата история са много сложни за откриване?)

2006-08-20 18:41

August 20th, 2006 by Vasil Kolev

Heat, lazyness…

The week passed OK (and I’m thinking about taking two days off in the next one and getting the rest of the needed sleep :) ). At last I decided and bought a trackball, because I was really annoyed by the touchpad – a good logitech one, with a big ball and with a wheel (which was one of the things I really missed).

I’ve began reading the whole RISKS digest, it’s really interesting thing (when you skip some of the boring topics).

The heat should be banned. It’s 37 degrees Celsius today, and even though at home it’s somewhat ok, it’s still not easy to breathe. Yesterday I spent the day at Slaveykov, and the heat was murderous, when I got down in Don Domat to eat a bit I felt alive again…

And Grigor has written a great and interesting story. It fits perfectly with the spam which I receive (and most probably not only I) in the last months.

2006-08-20 18:31

August 20th, 2006 by Vasil Kolev

Жега, мързел….

Седмицата мина в общи линии прилично (а следващата мисля да си взема два дни да си доспя :) ). Най-накрая се реших и си купих trackball, понеже ми писна от touchpad-а – един приличен logitech-ски, wireless, с прилично голямо топче и с търкалце (което беше едно от нещата, които сериозно ми липсваха).

Хванал съм се да изчета целия RISKS digest, доста забавно четиво се оказва (като се прескочат някои от скучните теми).

Жегата трябва да я забранят със закон. Днес е 37 градуса, и въпреки че вкъщи е прилично хладно, пак се чувства задуха… Вчера прекарах деня на Славейков, и определено се усещаше горещината, като слязох за малко до Дон Домат да хапна и се почувствах отново жив…

A Григор е написал един страшно интересен разказ. Определено много добре се връзва със спама, който получавам (май не само аз) в последно време.

2006-08-16 21:22

August 16th, 2006 by Vasil Kolev

…And today Debian becomes 13 years old :)

Looks like also that we’re getting older with it, this year looks like there won’t be a party with beer and cake…

2006-08-16 21:21

August 16th, 2006 by Vasil Kolev

…А днес Debian става на 13 години :) Да ни е честито :)

Както изглежда, и ние остаряваме с него, май тая година няма да има запой с бира и торта…

2006-08-12 11:34

August 12th, 2006 by Vasil Kolev

I’m a bit foggy on details about what I did through the week.

The time is getting stretched for me, it seems like it has been two weeks instead of one :) I mostly was taking care of the stabilising of the project from last week (there were some more things to be fixed, we’ll be finishing it next week) and writing a plan for the movement of the servers of a client, because of who I’ll have to go again to Los Angeles.

I don’t feel really good about the flight, looking at the last crap about the restrictions on what you can take on board, and I have no idea what other bullshit will they think of in the next 1-2 weeks… I’m starting to wonder if it won’t be easier to go there on a ship, but have no idea how long will that take :)

2006-08-12 11:31

August 12th, 2006 by Vasil Kolev

Малко ми се губи какво точно съм правил през седмицата.

Изобщо пак ми се разтегля странно времето, все едно са минали две седмици вместо една :) Основно се занимавах със закрепяне на оня проект от миналата седмица (имаше още дреболии за оправяне, следващата седмица ще го доубиваме) и писане на план за местенето на сървърите на един клиент, заради който и пак ще трябва да ходя до Лос Анджелис.

Не ми се мисли как ще летя до там, като гледам последните простотии около ограниченията какво може да се носи на борда на самолета, не знам каква простотия ще им хрумне в следващите 1-2 седмици… Започвам да се чудя няма ли да е по-лесно да се кача на кораб дотам, и колко време ще ме лашка :)

2006-08-04 23:22

August 4th, 2006 by Vasil Kolev

This was a horrible week… In the first three days we fought with a software of ours which was still being developed and had to be deployed in production (and the problems was from last week), so in the end we were able to fix it with removing of a lot of problematic components and with a few really dirty hacks on related applications… Those were days of going to bed at 1 and getting up at 9 with no lunch breaks (because then there were no users and we had some more freedom to work). Thursday morning it all started working, and I spent the day finishing some small stuff and got the Friday off.

Friday was nice. I slept through the morning (Mira woke me up at some point to ask me if I’m not going to work), went to fix some stupidities with one of the banks, went with my mother to get her bike, which I used after that to get home (somewhere from Pliska). Found out that I haven’t forgotten how to ride it, that I’m not really good at it and that the traffic in Sofia is not really friendly to the bikers.

I also went to bring my backpack for some maintenance and they really got on my nerves – their main office ( A.T.G. ltd, the official representative for Bulgaria) is at the end of Sofia and they explained to me that they have to send it to Belgium to be fixed there, which will take at least two months, and weren’t sure if my problem was covered by the warranty (and they should know). In the end the possibilities are to ether take it to be fixed somewhere here, or to give it to a better representative in some other country while travelling (the warranty is international).

I slept through the rest of the afternoon. Dreaming of the software we fixed through the week.

2006-08-04 22:51

August 4th, 2006 by Vasil Kolev

Изкарах ужасна седмица… В първите три дни борихме проблем с един наш софтуер, който още се дописваше и трябваше да пуснем в production (а проблема беше още от миналата седмица), та накрая успяхме да го оправим с орязване на кило проблеми неща и няколко мръсни hack-а по няколко свързани с него приложения… Бяха дни на лягане към 1 и ставане към 9 с липса на обедна почивка (защото точно тогава user-ите ги нямаше и имахме малко повече свобода на действие). В четвъртък сутрин всичко тръгна, а аз прекарах деня довършвайки разни дреболии и си взех отпуска за петък.

Петъкът беше приятен. Сутринта си отспах (е, Мира ме събуди да ме пита няма ли да ходя на работа :) ), ходих да оправя няколко глупости с едната от банките, отидохме с майка ми да и вземем колелото, с което аз после се прибрах до вкъщи (някъде от Плиска). Открих, че не съм забравил да карам, че не се справям чак толкова добре и че София по принцип движението не е особено приятно за колоездачите.

Ходих и да си нося раницата на ремонт и бая ме издразниха – главния им офис (на А.Т.Г. ООД, представителя на Samsonite за България) е на майната си на околовръстното, и ми обясниха че по принцип трябва да я пратят до Белгия да се ремонтира там, което ще отнеме поне 2 месеца, и не е ясно дали ще признаят проблема за гаранционен (а точно на тях трябва да им е ясно). В крайна сметка вариантите са няколко – или да си я дам на ремонт някъде като пътувам в някоя държава с по-голямо представителство на Samsonite (гаранцията е международна), или да си намеря някой локален майстор да ми я оправи…

Следобеда пак проспах. Сънувайки софтуера, дето оправяхме през седмицата.

July 29th, 2006 by Vasil Kolev

Yesterday we celebrated the sysadmin day. It began really properly with a hard day with tons of problems which marked the beginning, after which we went to Krivoto for the celebration.

A lot of people gathered, some of which I haven’t seen in a long time, like ecloga, schz, Chorbadzhiyski, dobber, zaphod, Budata, Shteryana, etc… We ate, drank, spoke on tons of stuff, it was great as usual :) Ecloga has made some photos from the event.

Then we went home, walked to Orlov most, from where I and ecloga went at my place, where we finished ourselves (well, at least I did) with some of the raspberry rakia.

And today’s the day of the sysadmin’s hangover…

2006-07-29 14:16

July 29th, 2006 by Vasil Kolev

Отпразнувахме вчера деня на системния администратор. Съвсем подобаващо със тежък ден с сериозно количество проблеми като за начало, след което се замъкнахме към Кривото за самото празнуване.

Събрахме се бая хора – някои от които не бях виждал от много време, като ecloga, schz, Чорбаджийски, Мъро, dobber, zaphod, Будата, Щеряна и т.н… Ядохме, пихме, говорихме си за купчина неща, въобще прекарахме си правилно :) Ecloga е направил малко снимки от там.

После тръгнахме да се прибираме, повървяхме до Орлов мост, оттам аз и ecloga се занесохме до у нас, където се довършихме (е, поне аз) с малиновата ракия.

А днес е деня на махмурлука на системния администратор…