Sunday, November 25, 2012

I don't live here anymore

My new blog address is oz123.github.com.

My new blog has feeds for each category, so If you are only interested in following a certain topic that occupies me, and you don't want to hear about my radical opinions about cycling or politics, subscribe to the appropriate feeds:

http://oz123.github.com/tags/python/atom.xml
http://oz123.github.com/tags/debian/atom.xml

etc.

You are also welcomed to subscribe to my main feed:
http://oz123.github.com/atom.xml

Oz.

Thursday, August 09, 2012

GNU vs Canon

Linux does not exist in American conusmer market. At least not for Canon.


Fuck Canon USA
America is sometimes a very weired place.

Praise Canon Europe. Are they the same company???

Ich liebe Deutschland :D.

If you happen to use Canon products on Linux, look for their drivers for GNU\Linux in www.canon-europe.com.

Saturday, July 28, 2012

Working With Binary Data in Python

This puzzled me for quite a time, so here is a post explaining some of my findings.
First we define a bytes array:
 s = bytearray(b"Hello World")
 for i in s: 
     print i
 ...
 72
 101
 108
 108
 111
 32
 87
 111
 114
 108
 100

now, let's write this data to a file:
 f = open('helloword.bin','wb')
 for i in s:                                                                                                                                       
    f.write(struct.pack("I",i))
 f.close()

Let's inspect the file created:
 
 $ du -h points.bin
 4.0K    points.bin
 $ file points.bin
 points.bin: data
 $ less points.bin
 "points.bin" may be a binary file.  See it anyway?

Binary file sizes

let's us write "hello world" into a text file in a text form:

 f = open('helloword.txt")
 f.write("hello world")
 f.close()

Once again we can inspect the file:

$ du -h   helloworld.txt
 4.0K    helloworld.txt


Now, what happens if we make a longer binary array?


 s.split()
 s.append(33)
 bytearray(b'Hello World!')
 for i in range(10000): s.append(33)
 f = open('longhelloword.bin', 'wb')
 import struct      
 for i in s: f.write(struct.pack("I",i))
 f.close()
 f = open('longhelloword.txt', 'w')
 hello = "Hello World!"
 for i in range(10000): hello = hello+"!"
In a shell, examaining the file sizes:
 
 $ du -h longhelloword.bin
 40K     longhelloword.bin
 $ du -h longhelloword.txt
 12K     longhelloword.txt

Wait a minute ! Why is the binary file almost 4 times bigger?

The answer is: it depends on the format specifier in struct.pack.
Namely, we used an unsigned int, for each character we then reserved 4 bytes!.
When we saved the text, every character was assigned to the file exactly as a char which takes one byte only.

If we repeat the above with struct.pack("b",i) the sizes of the file won't differ:

 f = open('longhellowordwithchar.bin', 'w')
 for i in s: f.write(struct.pack('b',i))
 f.close()

and in the shell:

 $ du  longhellowordwithchar.bin
 12      longhellowordwithchar.bin
 $ du  longhelloword.txt       
 12      longhelloword.txt

Credits:
http://dabeaz.blogspot.de/2010/01/few-useful-bytearray-tricks.html
http://docs.python.org/library/struct.html#module-struct

Thursday, May 24, 2012

Why does the Billlion Dollar OpenSource Company does not matter or should not matter

Once in a while I bump into posts praising Red Hat for the fact that its Financial Worth in the Stock Market has crossed the 1 Billion Dollar. Every time I read these posts I shiver. And let me explain why.
It's not that I have something against the technical merits of Red Hat. In my daily work, I support mostly CentOS and Red Hat servers, and I enjoy using them. However, at home I use Debian almost exclusively. But my point is not that Debian is better or worse. I just want to use Debian as an example of how Open Source drives new economic models, while counting the stock market worth of Red Hat is old style economy. So let's see what I mean.
First, I shiver when I think "oh god, how short is people's memory". Just two years ago, the stock market collapsed and literally vaporized many many people's savings, but the same people who were "managing" this stock market industry went home without losing a cent, and today? The stock market is alive, and people keep buying stocks - and if the worthy of Red Hat is increasing, it's because people are willing to pay more for a tiny piece of Red Hat. But what is a Stock worth if the company has no real holdings - besides it's office buildings ?  Not much, unless you are promised that the company will pay you dividends, or that the stock price will go up. Unfortunately, the current stock market does not promise any of them. Red Hat directorate can decide to give you dividends, but you are not promised, and if you are living in California or Paris, I am not sure it's worth traveling to Virginia to stock holders public meeting and vote on giving dividends to yourself and other share holders.
Now, I am asking myself, what is the interest of all these technology writers promoting Red Had by yelling "Look, Red Hat is worth a billion dollar" besides making other people buy a Red Had stock, and making sure the price goes up. They, Technology writers, just promote what I call the Red Hat Bubble.

Tuesday, May 08, 2012

Ubuntu 12.04 Intrusive OS

I installed Ubuntu 12.04 on two laptops by now. and I must rant. Ubuntu developers are assuming two many things about me. First, there is this bug, which the 'migration-assitant' mounts existing partitions in READ-WRITE mode. I find it dangerous and not necessary for migration.
Then, today I installed Ubuntu 12.04 on IBM x121e and found out that my Bluetooth chip is disabled. After about 20 min of looking I discovered, it is because of a bug in the installer which messes around with the BIOS. So if you have IBM x120e with Intel Chipset, you need to reboot, restore the BIOS defaults and then Bluetooth works. 
That's all the ranting for now ...

Monday, May 07, 2012

GCC 4.7 Breaks 169 Packages in Debian ... my weired hobby ...

I have a weired hobby, checking very frequently the Release-Critical Bugs in Debian.
It's kind of a magic window to all this wonderful packages found in Debian. Sometimes I'm horrified to see so many bugs opened at once. Like now ... 169 FTBS introduced by GCC-4.7...



It's no reason to panic, but it's been a while since I've seen such a huge bump up...


Thursday, May 03, 2012

Ubuntu Rant! You need Ubuntu to install Ubuntu

Ubuntu "engineers" are probably dumber than that Enterprise Linux OS. I got a laptop from a friend who asked me to install the latest Ubuntu on it. My usual technique of make a live bootable usb faild.
So, I googled and found this evidence that Ubuntu engineers are retarded.
You need Ubuntu to install Ubuntu.
This reminds me a bit that Redmond company. What if I have another OS ? NOT Mac or Windows ? For example, Debian? can't you just write how to obtain that package ???