Search

Favourite Projects

Barsy

Ads

A little awk script to change encoding in parts of file.

March 24th, 2011 by lukav

We’re in the process of migrating our ancient CVS with the more modern GIT. However I stumbled in the following problem. We make the commits comment in Bulgarian language with windows-1251 encoding. Git uses utf8 although I’m not sure if it does this natively or the client determines the commends encoding. So I had to change all the commit comments from cp1251 to UTF8. I couldn’t  just change the hole file, because some of the files have already changed the encoding in the work process and I wanted to keep the history and current encoding intact.

One way was to use “cvs admin -m rev:comment” command which changes the comment for a given revision in CVS, but that would mean I have to write a script that goes over each file, get all the log, then tries to figure out each revision and comment and use the admin command. Further more it had to work with multi-row comments. Although it is possible it seamed to me too much trouble with many points of breaking the comments.

So I looked at the idea of modifying the RCV files directly. I needed a tool to figure out the parts in the RCV (that is ,v file) between the lines containing only “log” and “text” and change the encoding only for those part. It doesn’t seam complicated, but when I tried to use my favorite ‘sed’ it couldn’t call the external ‘iconv’ for just parts of the file. So I needed an alternative.

After googling around it turns out awk was the tool for the job. It has the ability of calling system() function that executed external program for certain line.

So here it is. A awk file that looks for /^log$/ and then start to execute iconv for each line until it finds /^text$/.

#!/usr/bin/awk -f

/^log$/ {
    flag = 1
    print
    next
}

flag == 1 {
    str = gsub(/"/,"\\\"")
    system("echo \""$0"\" | iconv -f cp1251 -t utf8")
}

flag != 1 {print}

/^text$/ {
 flag = 0
 next
}

Of course the file can be easily modified for different tasks.
Enjoy it.

Posted in EN, Tech | No Comments »

#p2pvt WebTech 2010 Veliko Turnovo

April 26th, 2010 by lukav

Another year has passed and yet we all gathered together in Veliko Turnovo for P2P WebTech conference. I was very pleased with this year edition. The lectors ware great and the lectures ware very interesting and useful … well may be with one or two exceptions 🙂

We made some new friends from Mozilla and MariaDB (the new MySQL so to speak). We spend a good evening exploring the great opportunity of our beautiful country – cheep alcohol 😉 ending in a local pub with a great band: Jerihon you should check them out.

I should also give my spacial thanks SuperHosting.bg for giving a way a brand new Laptop. They gave it away to ME 😀

Another interesting event was the DrumBeat competition. There ware 11 teams that had to propose an OpenSource Project idea in about 15 minutes. I was left out for the jury. I was very supprized that 6 or 7 of them had the same bases. If I should summarize the idea I would say “Self driven community knowledge educational program”. Obviously people realize that the current educational system suck and a very interesting and promising idea would be to implement the open community method (like wikepedia) to make better schoolbooks and test for the young generation. This certainly needs more investigation and tough.

Looking forward for the future whatever it may be …

Cheers

Posted in EN, Soul, Tech | No Comments »

History Import Kopete To Pidgin

March 30th, 2008 by lukav

Since I’ve switch to Kubuntu I’ve been using Kopete as an Instant Messaging client. I’ve wanted to test Pidgin, but I didn’t want to lose my history again. Unfortunatelly I couldn’t find a tool to transfer my history from Kopete to Pidgin, so I’ve write a little script to do the job.

So here is it:

history_import_kopete2pidgin.tar.gz

In order to use it you need to install xalan and then just run the script with your user.

The script was written for my Timezone, so it might be necessary to edit  history_import_kopete2pidgin_filename.xslt file and enter yours

Hope this is useful for someone

Posted in EN, Tech | 4 Comments »

HowTo install hpt374 raid driver in debian

February 22nd, 2008 by lukav

Over the year I had to compile and install several times hpt374 driver for the HighPoint IDE controller.

Although the hardware is very old and probably nobody use it anymore I decide to put down this howto, for anyone interested.

The last time we’ve upgraded debian to etch with kernel 2.6.18-6-686 so the instruction will assume this kernel version.

First install the kernel-headers package

apt-get install linux-headers-2.6.18-6-686

then download the driver in this case hpt374-opensource-v2.17-1114
extract to some folder, for example: /usr/src/hpt374-2.6.18-6-686/

compile the driver

make KERNELDIR=/usr/src/linux-headers-2.6.18-6-686

you should now have hpt374.ko. Copy this file in the kernel modules directory

cp hpt374.ko /lib/modules/2.6.18-6-686/kernel/drivers/ide/pci/

We need to populate the modules dependencies

depmod -r 2.6.18-6-686

add hpt374 to /etc/initramfs-tools/modules if it is not already there

echo hpt374 >> /etc/initramfs-tools/modules

update the initrd image so the module gets loaded on system start up

update-initramfs -u -k 2.6.18-6-686

And thats it. You should now be able to reboot and use the new kernel with the raid

P.S. I’ve wrote this in a hurry, so I’ve may missed something.

Posted in EN, Tech | 1 Comment »

IE css float print problem

August 28th, 2007 by lukav

The latest discovery on IE problems was that when you use float divs and you decide to print, IE either ignore the floats or to be more precise, if you don’t explicitly specify width it just expands them to 100%.

There are some posts on the network, but all of them suggest to not use floats when printing. However this was no good for me, cause I arranged my forms with css and no tables. The solution to fix the width of floats was also no good, since I have different internationalization and some text differ in length.

So since I couldn’t find any css solution I had to make a simple JS hack.

In turns out IE has two useful events – onbeforeprint and onafterprint. So I just used those to go over all my floating elements and set the width before printing:

// We try to fix printing styles because IE is has problems
if (OAT.Browser.isIE) {
 OAT.Event.attach(window,"beforeprint",function() {
 	var elm = IB.PageContent.getElementsByTagName('div');
 	for (var i=0;i<elm.length;i++)
 		if (OAT.Dom.isClass(elm[i],'right') || OAT.Dom.isClass(elm[i],'left')) {
 			var size = OAT.Dom.getWH(elm[i]);
 			elm[i].style.width = size[0] + 'px';
 		}
 	}
 });
}

The example uses the OAT library, but you can guess what it does.

This fix works fine with the little exception that the divs move a little before print, but I can live with this for now.

Posted in EN, OAT, Tech | 2 Comments »

Joost review

May 7th, 2007 by lukav

Well, it seams my blog isn’t doing so well, since I didn’t get an invitation. However http://joost-invite.blogspot.com/ ware nice enough to send me one. Thank you very much.

So as I suspected the guys have done a pretty good job. Joost has a nice, simple and elegant interface, whitout the fuss of tons of options. I can describe it as “only what you need” interface, which are becoming widely used. It has some flaws, but they are more because of my preferences not of stupidity. I have to say the interface is pretty good. I’m almost jealous :).

As far as performance goes, I run it on my laptop hp nw8000 1.7 Mhz Intel Pentium with 1GB Ram. And it runs pretty smooth. There are some vary VARY small and rare delays, but I still can not determine if it is my PC speed or because of my ISP speed.

One thing that is missing are subtitles. People would like to have subtitles as with Divx movies. But this could be added pretty easily, I think. Someone can make a plugging that would allow playing user subtitles. That way the community could take care for the translation, timing and so on, where the content providers would continue to produce the main content. The translators can be rated, so the other users are able to choose the best translation from all.

As overall, so far I’m quite impressed and see great potential in this. For example: if anyone can become a content provider, young talents would be able to produce a program or movie, present it to a wide audience and collect the benefit without the stopper in the big networks chains.

Not to mention that it is quite nice to choose what you want to watch and to be able top pause at anytime.

Uraaa, no more waiting for the commercials to go to the bathroom 😉

Keep with the goos work guys.

P.S. If anyone wants an invitaion, post a comment.

Posted in EN | 3 Comments »

Joost Invitation, please – or – how is my blog doing.

May 5th, 2007 by lukav

Hi all,

Today my colleague and partner turned my attention to the next service from the founders of Skype called Joost. It sounds very interesting and shows how “the network” is slowly overtaking the “the networks”. By this I mean that each day I find that people are using the Internet for staff that they thought are only available by other means. For example before 7-8 years the source for reliable information was the newspaper or TV. Today the Internet Network is not considered less reliable source and is perfectly normal to say “I found on the net” or “I read in the Internet”.

I see the future where TV, video and radio are only both for convenience not for necessity. If my parents bought а TV so they can stay informed and up to date – they spare the money on computer because ‘their boy (me)” was interest in that new thing. IMO lets say in 5 years time parents will buy a computer so they can stay up to date – Watch TV, read articles and books listen to the radio etc and would buy a TV just to make it more easy and to get the kid off the PC.

So the revolution that started 10 years ago have not yet finished and there are things yet to see and come.

I’m very excited to try out joost, but I need someone to send me invitation. So if you read this and you have one please PLEASE send it to me.

If I actually get one by this blog, then my blog is not doing so bad 😉

Posted in EN, Other, Tech | 3 Comments »

Test a page in various browsers.

April 24th, 2007 by lukav

There is a very interesting service out there:

http://browsershots.org/

It makes a screenshot of a page with various browsers like: Dillo 0.8, Epiphany 2.14, Epiphany 2.16, Firebird 0.6, Firebird 0.7, Firefox 1.0, Firefox 1.5, Firefox 2.0, Firefox 3.0, Flock 0.7, Galeon 2.0, Iceweasel 2.0, Konqueror 3.5, Mozilla 1.0, Mozilla 1.1, Mozilla 1.2, Mozilla 1.3, Mozilla 1.4, Mozilla 1.5, Mozilla 1.6, Mozilla 1.7, Navigator 4.8, Opera 9.2, Opera 9.10, Phoenix 0.1, Phoenix 0.2, Phoenix 0.3, Phoenix 0.4, Phoenix 0.5, SeaMonkey 1.0, SeaMonkey 1.1, Windows MSIE 5.0, MSIE 5.5, MSIE 6.0, MSIE 7.0.

Great idea and a vary usefull one.

I’ve test it with my blog you can have a look here:http://browsershots.org/website/http://lukav.com/wordpress/

Posted in EN, Tech | No Comments »

Multiple IE on a single machine

April 24th, 2007 by lukav

Hi, I’ve been using a Virtual machine for some time now to test with IE6 (Microsoft Internet Explorer) and IE7. However this machine was taking valuable resources just to have IE6 running, which was very inefficient. So I’ve look for another solution and found it.

http://tredosoft.com/Multiple_IE

Thank you. THANK you vary VARY much. TredoSoft.

They made an installer that installs IE versions: 3.0, 4.01, 5.01, 5.5 and 6.0 (by the time of this writing) on a single PC as a standalone app.

So far it works like a charm.

Posted in EN, Tech | No Comments »

Firefox firebug and synchronos calls problem

April 12th, 2007 by lukav

For those of you that have discovered that when you have Firebug installed and are developing some synchronous XMLHttpRequest everything works, and when you disable it it stops: here is the problem.

Believe it or not it is a bug in Firefox NOT in Firebug. It turns out that Firefox doesn’t call onreadystatechange when the you set the 3 parameter (async) to false in open. Probably FF expects that when a call is synchronous the developer will process the result in the lines following the send call. May be this make sense, but if you want to quickly test async/sync calls or use a library that doesn’t take care of this, you be in trouble.

I can say for certain (I’ve committed the code myself) that the next release of OpenLink AJAX Toolkit won’t have this problem and will make no difference if you have Firebug or not.

I use the following to catch the situation where Firebug is not installed or is installed but disabled:

if (OAT.Browser.isGecko)
{
  try {
    if (!xhr.options.async && xhr.obj.onreadystatechange == null) {
      OAT.AJAX.response(xhr);
    }
  } catch (e) {
    if ((e.message && e.message == 'Permission denied to create wrapper for object of class UnnamedClass') ||
         e == 'Permission denied to create wrapper for object of class UnnamedClass')
      OAT.AJAX.response(xhr);
 }
}

OAT.Dom.isGecko() – return true if it mozilla and derivatives
OAT.AJAX.response – is the function that is normally called when the request finish.
xhr.options.async – is holding if the call is async or not
xhr.obj.onreadystatechange – is the original Firefox XMLHttpRequest object instance, since the code above works in the context of OAT

Posted in EN, OAT, OpenLink, Tech | 32 Comments »

« Previous Entries