# Thursday, February 28, 2008

Few words on Skype

I've always thought that whenever you distribute software or a service that does not need a central server that is under your control, people will always find ways to break that software or service for various reasons - to use it for free (think of Windows), use it for prohibited in the EULA purposes ( A good example would be ripping a movie or an Audio CD and distributing the ripped content).

I've always thought that even when having a central server but distributing clients (client applications) to the users would be hard to enforce the policy you want - ICQ guys (Mirabillis, now AOL if I'm not mistaken) would like you to use the official ICQ client because they sell ads (ads are shown in message windows), but I'm not using the official client and many others aren't.

So the perfect solution (in my opinion) would be to sell an online service - like what google is doing - search, gmail, ads, picasaweb, calendar, reader, gtalk are only a few that I'm using (without the ads). There are offline/thick client applications that google has, no doubt, but the majority is online with a thin client (browser).

Well guess what, there are companies that have a business with an offline client (thick client) that are doing their best to avoid all these problems.

All the other popular (and maybe unpopular) messenger networks have their protocol studied and many free and not so free clients written (trillian, pidgin, qip....., even online: meebo....). All of them, icq, gtalk, hotmail, yahoo, ... except for one - Skype.

Think, why is there no other client for the Skype network? Not even for chatting. There is no other that I know of. And I've searched.

Here's an article that explains why:
http://www.secdev.org/conf/skype_BHEU06.handout.pdf

It is kind of freaky - these guys have made everything they can think of to make it as hard as possible to reverse engineer the client, the protocol, the whole idea.

Skype is amazingly hard to debug and investigate - it has parts of it's code  compiled at runtime, it checks timestamps to see if there's a breakpoint. It calculates pointers at runtime to avoid debuggers. It has bogus code inserted, some code encrypted, all is really well obfuscated.

It's the same with the protocol - encrypted, hard to detect, hard to stop/filter by an administrator.

Even freakier - they have skype clients acting like proxies or routers for other clients - your client may be one. There are 20 000 worldwide.

The author says there is no antivirus that could detect a virus or a trojan if there was one. Skype client is the perfect blackbox - freaky.

They can read what ever they want from your machine and transmit it back to their servers and since the protocol is unreadable nobody would know.

Skype guys did a good job at protecting their business, but they created something far more capable that could be used for far more (how to characterize it) undocumented and unwilling-by-the-user things.
# Tuesday, February 26, 2008

My server got compromized today

Nothing serious, I just got careless.

Pictures in blog entries, part II

Part I is here
It's really annoying to have pictures in the blog.

Here are a few more reasons why I find it hard:

  1. dasBlog only allows adding pictures one by one. Of course I know were is it uploading them to, but this is cheating and I avoid doing it.
  2. Thumbnails have to be done manually.
  3. Making a picture a link (<a href...><img src../></a>) is quite hard (see this) - the raw html editor has to be used.
Of couse images can be linked from external sites, but I wouldn't want to depend on that because links can change.

I was thinking of directly copying thumbnails from picasaweb, but then all the styles also came through and broke the whole idea.

Another think I was thinking was to embed the flash picture viewer from picasa, but it only works if you read the entry from the website directly. Google Reader blocks it:

Picasaweb picture viewer (you have to read the blog entry directly - I have no idea which rss readers support it):

If someone has had the same issues, please share your experience and possible solutions.

Sharam, Cedrik and Yasen (Deep Dish in Sofia)

Half of Deep Dish was in Sofia. The party was great. Personally I enjoyed Cedric more than Sharam. Cedric made contact with the public and whenever the euphoria started to leave he took some action to bring it back, while Sharam started the beat and didn't care that much

Here are some pictures:

There was no one around eleven

       

Sharam and Cedric



This guy was constantly fixing something


Why were they at the party - I have no clue


Full size here

Pictures in blog entries

A really annoying lack of functionality in dasBlog is emerging in my mind.

That's what MS Word has:
(the pictures are into the text, which is quite nice)



Here's how it's done in MS Word:



In the dasBlog text editor such functionality is missing. Of course, there's raw html editor, but that's too burdensome (I'm lazy).

Even the border in the upper pictures is done via the raw html editor - It's only setting the border from 0 to 1, which is not that hard, but for something more complex I'd rather use a rich text editor.

So if someone knows how to tweak this, please give me a call.

Florist, part II

One of the victims:


These are the new six:
The guy who sold them,  

said that four of them should have access to direct sunlight,
3 of them should be watered more often than the others.


The problem is... that I don't remember which ones.

Full size here
# Monday, February 25, 2008

Unhappy tree

      

Holy crap, I have a virus

I was warned by my good friend Google:

dasBlog and emails

dasBlog can be made to send emails on every single event - comments, edits, referencing, ....
A good practice would be to have a separate email for the blog, at least that's what I did. Then if there's SMTP Server (google mails is perfect for that), the application sends messages to a designated email for every defined event. Perfect.

Another great thing: if your mail account has POP3 (google mail again), then the application (dasBlog) can be defined to check the mail regularly and if there's a mail with a subject containing a secret word, like that:

Subject:
ALABALA  I just passed my exams
Body:
I got an A in <b>Marketing</b> and F in Accounting....
Then the title of the new blog entry would be "I just passed my exams", and the body would be the message body, keeping the formatting. Of course ALABALA should be defined as your secret word in dasBlog settings.

They say, that they support inline images and attachments, but I haven't tried it yet.


There's a small chance for dasBlog to delete all your emails in that account (a special option in settings, that strangely enough is enabled by default), that's why it's better to have a separate account.



Google Analytics in dasBlog

Create an account here: analytics.google.com, get the script and paste it here:
dasBlog_DIR/themes/[your theme]/homeTemplate.blogtemplate just before the </body> tag. That's it.

И с ударение

Как се пише "и с ударение":
Предполагам имаш предвид "ударено и", защото с краткото видимо нямаш проблеми. За твое успокоение, "ударено и" липсва дори при БДС подредбата. Има Unicode знак U+045D (според Unicode спецификацията това е CYRILLIC SMALL LETTER I WITH GRAVE, води се македонски знак blink.gif ), но фигурира в много малко шрифтове на Windows, в това число Tahoma, Microsoft Sans Serif и Palatino Linotype. Липсва в най-широко използваните шрифтове като Arial, Georgia и Verdana. В ANSI кодовата таблица CP1251 (или Windows-1251) такъв знак изобщо не фигурира.

Все пак начин има - уверяваш се, че имаш легален Windows, сваляш си Microsoft Keyboard Layout Creator (изисква валидация и .NET 2.0), след което с негова помощ модифицираш съществуващата наредба и си слагаш "ударено и" където пожелаеш. Имай предвид обаче това за шрифтовете. Пусни си Character Map (Programs -> Accessories -> System Tools -> Character Map) и сменяй шрифтовете за да видиш, кои го имат и кои - не. Като цъкнеш отметката "Advanced view" се появява едно поле "Go to Unicode", в което можеш да въведеш "45D". Ако в мрежата от символи отгоре видиш заградено "ударено и", то шрифтът го съдържа. Ако видиш заградено "кратко у" - не го.

Някъде бях чел, че може да се произвеждат ударени символи посредством комбиниране на гравис (AltGr+`) и буквата. AltGr е десният Alt на повечето клавиатури. Не съм сигурен как точно се прави, тъй като при мен не работи във виртуална машина.

Източник: http://forums.megalan.bg/...


Моят опит показва, че ако този знак (U+045D: Cyrillic Small Letter I with Grave) го няма в използвания шрифт, браузърът го изписва със шрифт, който го съдържа, ето пример:
Майка ѝ каза, че...
firefox: забележете как и-то изглежда по-различно - просто е с друг шрифт

Току що пробвах и с Internet Explorer 6, оказва се, че той не го заменя и се вижда квадрат!
Updated: пробвах и с Internet Explorer 7, там всичко работи, даже изглежда сякаш не сменя шрифта, не знам как го прави.

Във форума на уикипедия пък, използват U+300: Combining Grave Accent, което поставя ударение на буквата преди този знак (http://bg.wikipedia.org/wiki/... и http://bg.wikipedia.org/wiki/...), записва се ето така в html ("и" плюс уникод запис във формат &#ХХХХ;) "
и&#768;" (768 е десетичното на 0х300), ето как изглежда:

ѝ       стои малко накриво (доста нагоре и надясно)

Updated:
тук ударението се вижда само във firefox, в IE6 слага квадрат върху буквата "и", в IE7 слага квадрат до буквата "и"

Този вариант не се води стандартен, защото ударението не е част от кирилицата (вижте дискусията в уикипедия - линковете по-горе)


Явно идеално решение няма. Аз ще използвам първия, тъй като е стандартен, макар и точно този знак да е с друг шрифт.
За жалост той има още един проблем - търсенето по цели фрази ще се провали, защото това е друг знак, но то май и при втория вариант търсенето ще се провали.

Както и да е, писнало ми е да пиша чисто и или "и кратко" затова за мен решението ще е
U+045D: Cyrillic Small Letter I with Grave


Updated:
В html това най-лесно се пише така:
&#x45D; (шеснайсеттично) или &#1117; (десетично), ето пример:
...<body><p> Майка &#x45D; се скара</p></body>... и излиза:
<body><p> Майка ѝ се скара</p></body>

New theme

A better theme.
Updated: this theme is definitely pretty, but it overrides all fonts defined in an entry, which is kind of annoying

Amazing, search Google Images for "picasaweb"

While checking the logs to see what's going on (yea, now it's documented - I do have one reader), I found out that when doing a Google Images search for picasaweb one of the pictures in the blog (the blog entry with the picture - here) appeared in the first search page:


Strangely enough, the picture is not hosted at picasaweb, although there is a copy of it in one of my albums.

Weird.

Duplicate entries in Search

While I was updating to dasBlog 2.0 I found out that search displayed duplicate entries (every entry is displayed 3 times). I though I broke it while I was updating.

After doing a clean install and testing the search bug appeared again so I decided to look for the problem in dasBlog itself. I found another blog using the 2.0 version and it too had this bug.

So now I'm happy the "problem is not in my TV".

I'll try to contact the guys and file a bug entry.

And then there's nothing better but to wait for an update.

Newer version

I just updated the software (dasBlog 2.0.x).

While doing so I decided to start the blog at http://blog.stoynov.com and blogging from that address.

Well, I managed to delete two blog entries and to send an updated feed for another 10, which would fill the blog readers people are using.

DEAR READER (I know you're only one), I APOLOGIZE


I think now everything is stable, http://blog.stoynov.com is only a forward.

Old Bulgarian Phonetic keyboard for Windows Vista

Copy of Phonetic Keyboard For Windows Vista for better indexing

Както всички, които са ползвали поне малко Windows Vista, са забелязали - няма я старата фонетична подредба. Аз лично я ползвах доста. Вместо нея има сложена една "стандартизирана от БАН" фонетична подредба, на която обаче няколко букви са разместени. Примерно Ж е на мястото на W, което на мен не ми харесва.

Имаше някъде спор из нета относно коя да бъде - старата или новата, но ме мързи да търся.
Аз си харесвам старата и открих един инструмент от Майкрософт (тук ще ги похваля), с който сравнително лесно могат да се пренаредят клавишите (едно време имаше нещо подобно във FlexType (моля ви, не си слагайте FlexType - Инженерът ще се кара)).
Инструментът се казва Microsoft Keyboard Layout Creator. Работата с този инстурмент не е толкова елементарна колкото изглежда, аз няколко пъти оплесквах нещата.

Та а използвайки тоя инструмент си направих фонетична подредба.

Update: във фонетичната на БАН забелязах нещо интересно: Shift + ь = ѝ. Тоест малка оптимизация. Ер малък се използва само като малка буква. Главна такава буква в Българския език няма. На мястото на главната буква те са сложили "и с ударение". И с ударение също няма главна буква, тоест ѝ трябва само една позиция на клавиатурата. За "и с ударение" имам малко инфо тук.
Та аз реших да направя същата оптимизация и направих нова версия на класическата фонетична за Виста.

Инструкции за инсталация:
  1. от zip файла с инсталатор цъкнете на setup.exe, следвайте инструкциите.
  2. Клавиатурата сама се "пъха" в активните, така че веднага е готова за употреба.
  3. Ако все пак искате да цъкате ръчно разни неща: "Regional and Language Options" в Contol Panel -> "Keyboards and Languages" -> "Change keyboards..."
  4. Фонетичната на Виста/БАН се казва "Bulgarian (Phonetic)", моята излиза като "Bulgarian (Phonetic) - REAL"
  5. Ако имате старата ми версия инсталирана, по-добре я махнете, тъй като и старата и новата излизат с еднакво име. В списъка с инсталирани програми се различават по версията, обаче.
Поддържани хардуерни платформи: i386 (32 bit), ia64 (64 bit), amd64, wow64 (дори не знам какво е това).

Това е фонетичната подредба за Windows Vistа (в архива има инсталатор):
Bulgarian (Phonetic) - Old School (by Mihail Stoynov).zip (253.38 KB)      (без оптимизацията за "и с ударение")
Bulgarian (Phonetic) - Old School (by Mihail Stoynov) v2.0.zip (252.92 KB)       (с оптимизацията за "и с ударение")

Ето и самата подредба (ако някой иска да си играе с нея, не е никак елементарно):
Bulgarian (Phonetic) - Old School (by Mihail Stoynov).keyboard layout.zip (2.26 KB)      (без оптимизацията за "и с ударение")
Bulgarian (Phonetic) - Old School (by Mihail Stoynov) v2.0.keyboard layout.zip (2.33 KB)     (с оптимизацията за "и с ударение")
# Thursday, February 21, 2008

Imagine a project, part II

Part I was a description of a crazy project where requirements' changes were on a daily basis.

How do you handle such a component?

The most important thing would be to make sure that after every change, every completed task, the project's code is consistent, there is no left-out code, and all tests run.

Automation, daily builds and good code coverage (in terms of unit tests) become your best friend.

Imagine a project

    Imagine you're in a project whose sole purpose is to mediate between a handful of really large systems. Even worse, the application is a front-end for the user, handling his money - so if something goes wrong, guess who gets blamed. In the beginning you investigate and develop a plan how to implement such system. You write an architecture, detailed design, do estimations.
    After a campaign for gathering capital, you start the project.
    Imagine that most systems you depend on, have different rules on how to connect with you - some require you to install systems on-site and these systems to be active, some expect you to implement an interface, and just wait for a call :)
    Imagine you neglected the legal part of the thing and you have to compensate that mistake by going through the user interface with a lawyer who changes a significant part of it, which on it's turn changes the business logic.
    Imagine you have a marketing office that says that in order to profit more you again have to change how user interacts with the system.
    Imagine that you're in the middle of development and have to meet a deadline with version one just in few months.

    Imagine there's a component in that system that handles communication between other components in the project. This component is affected by every single change in the whole project - requirements change daily, not to mention the domain model that this component serves.


    ...now imagine you're the team leader of that component...

Firefox's spell checker

Recently (it took me quite a while) I found firefox's spell checker - it's a great thing, but it's not enabled by default

Maybe it's not a bad idea to say a few words for guys that still do not use it (like me).

How to enable it:




Also by default, there are no dictionaries, how to install a few:



then:




I installed Eng and BG, the bulgarian one works well enough:



Oddly enough, I had quite a lot of errors on the blog, by average 2 per blog entry. All fixed now.

Transformations between Domain Models, OOP fails, no such Design Pattern

The issue:
There are 3 (three) Domain Models (Object hierarchies, groups of objects). They are parts of different tiers of an application. Their hierarchy trees are nearly the same.
Why we have three DM is another issue, but is not in the focus of the following discussion.

The task is to convert objects from one Domain Model to another. As I said, the objects are nearly the same, data objects, no logic.

Until now there were static methods that do that. It's ugly - there's another class, inheritance is impossible - logic has to be extracted like this

public static M2Object convertM1toM2(M1Object) { /* logic */ }


becomes

public static M2Object convertM1toM2(M1Object m1) { convertM1toM2(m1, result); }

private static void convertM1toM2(M1Object m1, M2Object m2) { /* logic */ }


because the result is now an inheriting class and cannot reuse M2Object convertM1toM2(M1Object), but can reuse void convertM1toM2(M1Object m1, M2Object m2).


What I proposed was to put converters in one of the Domain Models, M2 was chosen.
so now M2 has

new M2Object(M1Object)
new M2Object(M3Object)

M1Object toM1()
M3Object toM3()


Inheritance with constructors is working smoothly. The problem comes from the toXXX() methods. Inheritance is difficult because the super toXXX() creates the result (base M1/M3 class), but the result in inheriting toXXX() method should be inherited M1/M3 class.


So now I'm thinking of (M2InheritedObject):
protected final void convertTo(M1InheritedObject m1) {
   super.convertTo(m1);   // convert base class properties (reuse happens here)
   /* +extra logic */     // convert inherited class properties
}
public M1InheritedObject toM1() {
       
M1InheritedObject result = new M1InheritedObject();
        this.convertTo(result);
        return result;
}

This method is gonna be reused, inheritance is weird  - this is actually kinda unclean, but the best I can think of.


I'm thinking of some design pattern, (Adapter for example), but that good for objects, not object hierarchies.

If somebody thinks of something, I'd appreciate it.
# Wednesday, February 20, 2008

Me, the florist

Here are some pictures of my reborn (I had neglected it for a while) passion:
 

            

Comparing source code on check-in and check-out

A great practice I follow is to do compare when checking in and out some source code.

When in a new project (my current situation) it's really fast to find out what code is hot - heavily changed, and how it is changed. Even when into the project, the new guy can follow what others are doing, can find out if someone accidentally overrides something (it happens more often than you think), and generally keep track of what everybody's doing.

There's an overhead involved - the whole procedure needs some time. I try to commit (check-in) relatively often, and on every sync I do compare. This way the committed code by others could not pile up.

There are also tricks to optimize the process - if the comparator highlights horizontally changed code (most of them do comparison only vertically - line by line) you can ignore code formatting changes faster, because no code is highlighted. If some refactoring takes place, you could ignore the changes in subsequent files after you've seen them in the first one. Example (only spaces and quotes changed):


A good reason for frequent commits is that a frequent update would be easier - when you update a file you see a single change.


Comparing code on commit (check-in) makes some bugs obvious and helps avoid typos. Frankly I don't do it always.


Two additional things I would recommend: when committing, write a description (it helps others understand what's going on) and do atomic commits - commit a single task as one thing (select all changed files and commit them together with an understandable description - it's really helpful for the guy after you.
Note: not all repositories support atomic commits, but still it's a good habit.

The second thing is always to update before commit - avoid partial commits and breaking the build accidentally.

Don't make me think

Today I was on a lecture - http://www.devbg.org/seminars/seminar-Software-Engineering-20-February-2008/

Mihail Mihailov had a great lecture on rapid development (based Steve McConnell's book).

It seems I'm gonna have to check out Steve's less popular books - Rapid Development, and something about estimations.

Because of participation I won a copy of "Don't make me think":


It seems like a book I would enjoy reading and that would have the same way of thinking as I do.

It was signed by Mihail, and funny enough Mihail's signature is something like M2:
Cool, I like it.
# Monday, February 11, 2008

Laptop overheating comes out to be a Vista Search issue

My laptop started heating more and more until at some point I had to start forcing it to "Sleep". (it has Vista on it)

At some point I got really aggravated by that fact and started investigating. Forums revealed that the issue could be linked to heavy processor usage.

Process Explorer showed that I had some wierd behavior even when the machine was idle (Indexing service is disabled - dummest thing ever) - explorer.exe taking 100% for 5-10 seconds.

Repeatedly.

There was a wierd dll doing that (SHLWAPI.DLL):



At some forum I found out that this was related to the start menu search. WTF?

It comes out that the start menu search (which I find one of the few useful things that come with Vista) does a search in the index first and then goes the the hard drive.

We don't want that.

There is an option in the start menu settings which stops that - problem solved.


The good thing is that while searching at the forums I found a pretty useful tool - Dell fan control - one can see everything and EVEN control fans:



dell fan control.png (78.88 KB)
# Sunday, February 10, 2008

DNS Configuration issue - partly solved

A while ago I had an issue with accessing gateway machine by its external network address as discussed here: DNS Configuration issue

The solution with the local DNS server kinda worked - now there is a local DNS server with local names (machine1, machine2...) and mapping the domain names (stoynov.com) with the local addresses. It works pretty well.

The only problem is synchronizing the sub-domains (msdnaa.stoynov.com) with the local DNS server - now they should be added by hand. Kinda sucks. The good thing is that there aren't too many of them.

# Wednesday, November 28, 2007

DNS Configuration issue

There's this problem I've been having for some time.

I have a small server (http, mstsc, file-, ...) at home. It has a real IP address. It also acts as a gateway (AP, lan, bluetooth lan) and shares it's internet connectivity. For that reason that machine acts as a DNS and a DHCP server and has an internal IP address.

There's a domain name resolving to the external (real) IP address.

The problem is seeing the the stuff that should be seen from the outside world from the internal network. All that stuff works when using the internal IP to access that machine, so it's not a firewall issue.

What works and what not: pinging the external address works, telnetting to external IP:80 fails as with any other port.

A simple site wouldn't mind internal or external address.
My blogging application on the contrary would fail because the resources (pictures) are with FQN URLs.
And I would like to make this work in a pretty way.

One solution - local DNS server supplying the internal IP address for that domain name.
This works now, but my local DNS has to have an entry for every single domain/sub-domain - this approach sucks. I also have different services exported on the two different IPs and this local DNS approach break that.

I have seen this problem with the networks of midsize companies. Example with deploying a product inside that network (have to supply internal names).

I'm looking for a better solution.

Anyone?

# Tuesday, November 27, 2007

Car accidents' day, part II

Look here for part one.
I had promised myself until the end of the day to use only first and second gear - I didn't do it.

So what happened until that notorious day was over.
It was snowing all day and after work I decided to go to a nearby mountain (Vitosha) and test my driving skills on an empty road. At some point I parked outside the cleared road to see the view to night Sofia. ...and I couldn't get out of there - the car was stuck in high snow. Digging was necessary. To dig I used a thing I bought for cleaning my windshield - it did an amazing job and I got out.

Few turns and a lot of drifting after that I lost control and got stuck (again!) in ditch stopping just a few inches from a tree. The car was inarguably unable to get out of there on it's own. I was just imaging how now I should start calling friends (it was around 12 o'clock already) which would arrive at least an hour after I called them, when I saw some lights. I got out and raised my thumb and these guys stopped. I had a rope and a Subaru 4x4 got me out in no time. And the car wasn't damaged at all. What a day.

I definitely believe in god now.

Unfortunately there isn't a single picture of all the stuff that happened.