Csabi's blog

Software Craftsmanship, Agile, and other Ideas about Programming

Subscribe to RSS feed

Sticky post

Books I Read about Programming

, , , ...

Now Reading

Growing Object-Oriented Software Guided by Tests
This is a book with an actual application created step-by-step. I am about half way through it, maybe I will finish reading it this year.
The book's web site...





The Art of Unix Programming
This is a book of why and not how in programming, and more precisely why are programs made the way they are in the UNIX world. The book starts with a short history of UNIX, continued by a series of concrete, real world examples and the motivation behind their design. This is a must-read for any programmer, not just UNIX / Linux programmers.
Read the book online or order it here...


Read more...

Why 16:9 TV sets should've never been invented

In the pas 5 or so years all TV sets started to be produced in 16:9 aspect ratio instead of the older 4:3 standard. Though this move allows some extra content and opens the door for HD and Full HD, the transition and the lack of a world-wide unique standard for 16:9 aspect ratio made the new TV sets weird and annoying like hell.

The old 4:3 standard resolution 480i is a 704×480 area (Wikipedia Standard Definition), or an equivalent of 640x480 squared pixels display.

The newer standard 16:9 aspect ration would be 720×480 pixels. As you can see, there is actually extra content transmitted for wider screen. The width will be 16 pixels more and the height remains unchanged.

As a consequence, the best way for a standard definition transmission to be presented on a wide screen is when both the TV set and the transmission have the same 16:9 aspect ratio.



However this is, as simple as it may look, is quite rarely used in my country. That would be Romania. Some channels are 16:9 standard definition (SD) but others applied different tricks to deliver 16:9 content or abandoned the idea and are still transmitting 4:3.

So, what are the options on a 16:9 TV set for these cases?


On the left are the 4:3 resolutions. Our options are quite limited and ugly.

4:3 aspect ratio
  1. Place the 4:3 in the center of the 16:9 screen. This will lead to a lot of black bands on the sides. Image is small, 16:9 TV is not used at it's potential.
  2. Zoom in on the 4:3 image so that it fills the width of the TV. This is again problematic. You loose some content and subtitles become invisible. You also loose a significant amount of pixels on the vertical and the image quality degrades a lot.
  3. Finally you could squeeze the 4:3 into the 16:9 screen. This will preserve content and subtitles but ... c'mon! ... who can watch all that "fat" distorted people?

So, 4:3 on a 16:9 screen is a small disaster. None of the options is acceptable. However, when you do this vice-versa, and use a 4:3 TV for a 16:9 image, and zoom on the center of the 16:9 image, you loose very little or unimportant content and you still can see the subtitles. When you zoom a 16:9 TV on a 4:3 image, many times you end up with people's heads being cut in half. But on the sides there is little important content.

Other TV channels took another way to attack the 16:9 aspect ratio problem. They do the so called anamorphic transmission. I bet this is for cheap transition but it comes with a cost. See second column in the picture above.
16:9 anamorphic
  1. If you put the 4:3 image in the middle, you have "slim" sticks people. Not acceptable.
  2. If you zoom on the image, you get to fill in horizontal but you keep the same slimmed people.
  3. Finally, if you squeeze the image you are getting the correct aspect ratio and your 16:9 screen is filled. But remember the second paragraph. 16:9 should be wider and have more horizontal pixels. This artificial distortion and transmitting a physical 4:3 image leads to an observable quality loss on the horizontal. Yes you can actually see that very clearly.


So the anamorphic trick doesn't lead to good results either. It is better than plain 4:3 on a 16:9 screen, but worse than the native 16:9 resolution.

And finally, the horror of all possible solutions...

Some TV channels decided to transmit 16:9 content on top of a 4:3 image, effectively transmitting the black horizontal bands. I leave it to you to find a good way to put that on your 16:9 TV in a way that doesn't come with a huge quality loss and you can still see the subtitles which are on the bottom black band.

... and we did not even talk about HD and Full HD and 3D and whatever may be invented between writing this post and you reading it.

Until there will be an enforced standard for 16:9 resolution, world-wide, this hell is for all of us. Ah, and one more thing, there is no such thing as modern 4:3 TV set. At leas I couldn't find any.

Have fun watching you TV if you still can. Thanks for reading.

Timisoara - Piata Unirii incepe sa arate decent

, ,

Am fost azi la o mica plimbare prin centrul orasului si am constatat cu placere ca au mai terminat de renovat o cladire in piata Unirii. Incet-incet incepe orasul sa ia un aspect mai civilizat. Mai ramane insa mult pana la finalizare, sper doar ca aceasta candidatura la "Capitala Culturala Europeana" va stimula municipalitatea sa ia mai multe decizii in favoarea Timisoarei si al aspectului centrului istoric.

The Opera Experiment - Conclusions

Well, I decided to continue using Opera instead of Chrome. Not a big surprise because I am an old-time Opera user. However it was really interesting to consciously and open-mindedly try out another solution.

My decision to continue using Opera obviously had been influenced by my subjective view and day-by-day workflow.

So here are my ideas about the matter as a whole:

  • Chrome can be used even if you are used to work in "Opera style". It will take some time, but with enough effort and time you can make Chrome to behave as you wish - most of the time.
  • Opera on Android is not as fast as Chrome, but the difference is neglijable
  • Opera, even on Android, can use urlfilter.ini, so no more ads on website. Sorry Chrome, you can't do that, this was probably the feature that convinced me to choose Opera on Android.
  • Gmail App has some nice tricks but it's lack of configurability and the fact that Samsung made a really good email client on top of the default Android email client makes Gmail's app a looser.
  • Chrome is just too slow on Linux. Period.
  • Using Gmail's web interface is acceptable, but a dedicated mail client on the desktop is much better. There is no reason not to use Opera's client. I even does "push mail" (IMAP Idle) pretty well.
  • I gave up any Twitter client application on the desktops. Having a pined tab in Opera for Twitter is enough. The phone can still use the official Twitter App.
  • Another great application on the Android is Samsung's calendar / planner. It can use Google Calendar very well and it has cool features for the S Pen and a much better look. On the Linux desktop, KOrganizer is acceptable, but most of the time I just access the calendar with a browser if I don't have my phone at reach.


My conclusion is that you can live happily without Google apps and only using their services. A few exceptions stay, Google Maps and Google Goggles have non alternatives I know of.

The Opera Experiment - Goals

The Opera experiment will be a little bit different from the Chrome experiment. I am planning to do it for a week or so, the same way I did with Chrome.

However, if I would just try to use Opera, that would be too easy. I am an Opera fan, where is the experiment in there? And no, I can't be objective, because the whole experiment is for me and it has it's value in my subjective view of the two technologies.

The goal is not just only using Opera as the browser, but on the desktop also as the mail client and rss reader. Than, I will have to find a way to manage Google Calendar and Tasks. Maybe contacts also. So I will try to find and use 3rd party applications for mail, rss, contacts and so on. I will have to live without Google applications, only with Google services.

So, this is it. No more Google apps on the phone and as little as possible webapps in the browser. Next blog post will be when the experiment is over but until than you can follow me on twitter and get the progress as it happens.

The 7 Days Chrome Experiment

Those who know me are aware of the fact that I am a huge Opera fan. I started using Opera about 10 years ago and it is one of the most important applications I use each day.

However, since on the Android the well known Chrome browser is very nicely optimized, and I have to admit faster than Opera, I decided to make an experiment. I used only Chrome for the past 9 days (originally I planned only one week, thus the title).

For the experiment to be as complete as possible, I decided to use Chrome on all of the computers and phones I work on. These would be:
  • My HP home computer - Sabayon Linux 64 bits
  • My MacMini work computer - MacOS X Lion 32 bits (I think)
  • My Galaxy Note 2 phone - Android 4.1.1


Before entering into installing extensions and configuration my first impressions were these: Chrome was faster and better integrated on the Note 2, about the same on the MacOS and visibly slower on the Linux PC.

The next thing I looked at was the synchronization capability each browser offered. I could make an extensive comparative list here, but I will not. The thing is that both browsers are about the same. They both sync a lot of things but not necessary the same things. Chrome has the plus of synchronized tabs while Opera has synchronized notes in plus.

The rest of the experiment was about having a set of features working on Chrome which I consider core to my style of working. Some or many of these may be totally irrelevant for many of you and I perfectly understand your point of view, but for me it was really important to have at least some of them.

So, after all these 9 days I managed to find extensions for a lot of things that can at leas approximate what I want:
  • Speeddial
  • Pin tabs and prevent them from closing - not working very well but bettern than nothing
  • I configured and use GMail web client - acceptable but not as good as Opera's builtin M2 client
  • Google Reader - nice concept, I could get used to it.
  • Custom keyboard shortcuts - yes, you actually need an extension for that. I found a couple of them capable of assigning basic shortcuts. Opera's builtin shortcuts are a clear winner on this category
  • Forward slash search - there are actually a couple of extensions for this and they work really well
  • Scratchpad - can be used instead of Opera's built-in notes


And here are the pieces that I still miss:
  • Mouse gestures are just not working on Linux or MacOS
  • A better mail client
  • Make sure pinned tabs can not be closed
  • A working spell checker


And yes, after all these 20 or so extensions were installed, Chrome was much slower than Opera with about the same functionalities available both on MacOS and Linux.

As for the Android integration what I like with Chrome is the sync tabs feature and the ability to copy/paste text and links. Speed wise Chrome loads pages clearly faster but the difference is not that much.

Final conclusion is that I could live with Chrome. I could get used to or find solutions for what I still miss. However I am not convinced so I will start the Opera Experiment (see next blog post for more details).

Buburuza

Click image to zoom.



Click image to zoom.

All pictures by Patkos Csaba published on this blog are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Cu Capul in Nori

Transalpina 2012 la peste 2100 metri inaltime.

Transalpina 2012

Creative Commons License
All pictures by Patkos Csaba published on this blog are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

 

 

Desktop Recording with avconv (Formerly Know as ffmpeg)

, , , ...

I am always getting down to this. If you want to do anything more complex or advanced than the options of a simple GUI application you are back to the CLI.

So, record your desktop and encode the output on-the-fly, even on an old dualcore like my computer:
avconv -f x11grab -show_region 1 -video_size hd720 -framerate 24 \
-i :0.0 -threads 2 -q 1 -bt 8000000 -b 8500000 ./test.mkv 

Explanation:
  • -f x11grab - take as imput the X11 screen
  • -show_region 1 - mark the recorded legion on the screen so you know exactly what you are recording
  • -video_sie hd720 - recorded video size, it can be specified as absolute size, like 1280x720 or as hd720 hd1080, if you wish to place it somewhere else than the top left corner, specify +x+y like this 1280x720+100+150
  • -framerate 24 - how mane frames per second to record
  • -i 0:0 - the display to record
  • -threads 2 - number of threads to use; if used without a value it will try to guess an optimal value
  • -flags2 - extra flags, see official documentation for more details
  • -q 1 - quality, as good as possible
  • -b 8500000 - bitrate set to about 8.5mbps
  • -bt 8000000 - bitrate tolerance set to abot 8mbps - this will allow variable bitrate to be between about 500kbps up to 16mpbs. This ensures best possible quality, at leas for my 720p recordings.


If you have to speed it up, or slow it down, here is a nice trick you can apply after the recording is done. This example will transcode the movie at 130% speed, compared to the original 24fps. Note, that this is a trick, the resulting movie will have 24fps but it will play as if it had 32fps. You can also slow down movies with the same trick.
avconv -i test.mkv -f yuv4mpegpipe - | yuvfps -s 32:1 -r 32:1 | \
avconv -f yuv4mpegpipe -i  -  test_fast.mkv

Coolest Opera Bug Ever!

Reported as: DSK-371190

If you access a page with a domain name having 9 characters and using ajax requests, browser.js will match it as 'staple.com'. The result is an awful error:

Error thrown at line 733, column 8 in <anonymous function>():
    var elms=doc.getElementsByTagName('*'),elm,i=0
called from line 1679, column 6 in <anonymous function: initialize>(request) in https://csabastore/js/prototype.js?1343230935:
    var xml = transport.responseXML;
called from line 101, column 6 in klass() in https://csabastore/js/prototype.js?1343230935:
    this.initialize.apply(this, arguments);
called from line 1595, column 4 in <anonymous function: respondToReadyState>(readyState) in https://csabastore/js/prototype.js?1343230935:
    var state = Ajax.Request.Events[readyState], response = new Ajax.Response(this);
called from line 1545, column 6 in <anonymous function: onStateChange>() in https://csabastore/js/prototype.js?1343230935:
    this.respondToReadyState(this.transport.readyState);
called via Function.prototype.apply() from line 391, column 6 in <anonymous function>() in https://csabastore/js/prototype.js?1343230935:
    return __method.apply(context, a);


The problem is this if in browser.js:
LINE 728: } else if(hostname.endsWith('staples.com')){ .... }

And hostname.endsWith does:
 LINE 32: endsWith:function(str){ return this.value.length==this.value.indexOf(str)+str.length;

What actually happens here is that a domain name's length is represented by this.value.length.
The variable "str" is 'staple.com' ans str.length equals 10.
Now, if you do a this.value.indexOf(str) that will return -1 for any domain not having 'staple.com' in it's name.
As a result 'endWith' will return true, code in the if applies and messes up the otherwise correct code on the specific site.

Opera surely will soon fix it, until then you can set browser.js to not be used, or yo can access the particular site by IP, or you can tweek the browser.js (just don't update after the tweeking).

Building a Router from Scavanged Hardware - Tweeking the Hardware

So, my Little Fellow was working nice, all hardware check, but as any little guy it was noisy. Not very annoying, but enough to bother you at night in a silent room. Alternatives were needed.

The HDD, being a laptop disk, was almost perfectly silent. No problem there. On the other hand, this little fan, turning at 7000 RPM (that's right, BIOS said seven thausand) was emitting a continuous noise.

I concluded that if little fan = big noise than big fan = little noise.

I fixed the new fan over the cooler, put on the case, started up the system ... horror! It was at max RPM making twice as much noise as the little fan. The little fan kept the CPU at a constant 37.5 C. The big fan at max RPM kept it at 35 C. As you can see the connector of the fan has only 3 wires. That means no pwm and no fan speed control. The solution was unaccepted, because I wanted to get rid of the noise. A moderate rise of the CPU's temperature was exapted. This CPU works well up until 70 C. Higher than that would be risky. So my target was 50 C in idle because I know spikes would be relatively rare and would take only a couple of minutes ... or maybe 10 minutes. Even if temperature would have gone over 70 C for a few minutes, it would have been acceptable if the system did not crash.

I started to look for alternatives within the mountain of old hardware at work still expecting to be thrown out. This was a good candidate, but too high and too wide, couldn't mount it.

So I wen smaller.

This one fit in, but only above the current coolers. It looked cool when it was mounted and the case could be almost perfectly closed. So I screwed in all the srewes, the case was closed, placed where it will be when it's done. Started it up... 40 C ... 45 C ... 50 C ... 55 C ... 58 C ... with idle CPU. I stopped at this point because the case was already almost too hot to be held in my hands.

Than I remembered! I have an old, broken, passively cooled NVidia GForce FX 8600GT.

Cool. The cooler fitted in width and higth but guess what? It was too long. Another failure.

I was back in square one ... I mean square zero. No more alternatives at hand.  When nothing you have works, you start thinking about what you can do to what you have so it will fit as close as possible to what you want. One of the alternatives was to start cutting big coolers in pieces, not really my taste, pretty messy and I have no proper tools for this job.

The only option left was to make somehow the big fan to turn slower. In fact, I've read a few articles about the cooling needs of the Via C7 CPU and all it needs is a little moving air. I went back to scavenging and I found a pair of broken headsets which had a nice volume control.

Niiiice! And in working condition. I went on testing.

It was not turning, but it looked feasible. I continued by welding the wires of the fan directly to the plate of the potentiometer.

The test went well, the fan was turning. Only one little step left to be done. Remove the little fan and squeeze all the new stuff in.

All nice and cool. And I mean cool as in 36.5 - 37.0 C in idle mode with lowest possible RPM the fan can don. I started by stopping totally and slowly rising the "volume" on the potentiometer until the fan started to move. Unfortunately this fan is not compatible with the speed reading chip on the board, so I can only guess it's speed. Based on the noise level and an educated optical guess based on comparing it with other fan's I know how fast they turn, this should be about 500-600 RPM, maybe less.

That's it folks. I did all I could to make it as silent as possible. There are only two other possible ways to further remove noise and reach absolute zero. An SSD and a proper big fanles cooler that is made for cases like this. None of the options is available now for free, and this is about thrown-away-hardware, I intentionally want to invest no money in hardware.

I hope you liked this stage, I was pretty excited. It was a challenge to find something that works and I had to also read quite a few technical sheets and forums to find out how to achieve silent coolness.

See you next time with choosing the operating system.

 

Building a Router from Scavanged Hardware - Resetting the BIOS

I named the machine. It's official. From now on I will call it "Little Fellow".

So, I messed it up. I was playing around with different settings in BIOS and I set a wrong BUS speed ... nothing starts any more.

Luckily I found this documentation about the board and BIOS and I am now investigating the situation.

Notice the 3 jumpers on the right side, near the IDE connector, there is where I have to work.

After some trial and error and setting on-off jumpers it's alive again. I am not sure which jumper made it clear the CMOS because they are not clearly marked on the board. So, I just randomly switched on-off or to pins 2-3 from 1-2 all 3 jumpers in that block. Luckily nothing blew up and it works again.

It can even say how the system feels right now ... but about temperatures and hardware tweekeng in another post.

Right now I am just happy to be back on track with it.

Building a Router from Scavanged Hardware - Introduction

Hi folks!

We did some summer cleaning at work and came across a lot of old hardware. Basically several kind of mini motherboards with VIA Cx processors. While selecting what to keep and what to throw out, one candidate for being discarded catched my eyes.

It is an old hardware for some experiments the company made while trying to implement wireless support for one of it's products. The feature never saw the light of day but som hardware was produced.

This little fellow here is based on a SBC8A810 Rev. A2-RC board featuring a VIA C7 CPU at an "amazing" 1GHz. It is single core and x86 compatible. I do not know precisely, but people say it's i686 equivalent and has a performance similar to a P3. On the board there is a 256MB RAM module.

Under the hood there is also a laptop HDD heaving 80GB in capacity and IDE connection to the system.

For communicating with the exterior, the board provides 4 UTP network ports, 1 WiFi, 1 serial port, 1 VGA output and 2 USB ports.

This being said, the introduction is over. In some upcoming blog posts I will detail ste-by-step the process of turning this machine into a router with Wi-Fi, PPPoE, DHCP and other network related services enabled and running.

I named the machine. It's official. From now on I will call it "Little Fellow".

Solving Problems on MacOS X vs. Linux

When I have a problem on MacOS X I am frustrated.
I look for a solution.
Most of the time there is none, or it is much too complicated and hackish.
I give up after 30 minutes or so.
I learn to leave with the problem, being a little bit unhappy each time I can't do that particular thing.

When I have a problem on Linux I am frustrated.
I look for a solution.
Most of the time there is one, and it is relatively easy to implement.
It takes me 30 to 60 minutes to fix the problem.
I learn to leave without the problem, being a little bit happier each time I can do what I want and how I want on my own computer.

Why should I use MacOS X, ever?

Timisoara - 2


Creative Commons License
All pictures by Patkos Csaba published on this blog are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Motorina Standard si Top Sunt Identice

Tocmai am descoperit, pe site-ul Petrom ca nu exista nici o diferenta intre compozitia criteriul de testare dupa care se califica Motorina Euro5 Standard si Motorina TOP Euro 5 (extra) .

Imi poate spune si mie cineva de ce cel "Top" sau "Extra" costa mai scump?

Din seria "Cartierul Meu" - 5

Creative Commons License
All pictures by Patkos Csaba published on this blog are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Roses - 5

Creative Commons License
All pictures by Patkos Csaba published on this blog are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Parcare de "Be-Em-Vist"

Creative Commons License
All pictures by Patkos Csaba published on this blog are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Timisoara - 1

Creative Commons License
All pictures by Patkos Csaba published on this blog are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Roses - 4


Creative Commons License
All pictures by Patkos Csaba published on this blog are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Din seria "Cartierul Meu" - 4


Creative Commons License
All pictures by Patkos Csaba published on this blog are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Roses - 3

Creative Commons License
All pictures by Patkos Csaba published on this blog are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Din seria "Cartierul Meu" - 2

Creative Commons License
All pictures published on this blog by Patkos Csaba are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Roses Bouquet

Creative Commons License
All pictures published on this blog by Patkos Csaba are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.