Archive for the ‘Uncategorized’ Category

Gentoo Portage: libxcb and broken libraries

Saturday, November 14th, 2009

When using the Gentoο distribution, updating all your installed packages should be as easy as:
# emerge -avDuN world

But, when I tried it yesterday, It wouldn’t work: It could not emerge media-libs/xine-lib.

I tried running revdep-rebuild to find any broken libraries and it found a lot of them, all missing files from libxcb. I tried to emerge it, but I realized it was part of the packages “emerge world” had already emerged.

After doing some googling, I found Gentoo libxcb 1.4 Upgrade Guide. It says you have to manually run a bash script, then revdep-rebuild and finally remove an outdated shared library file.

So, be careful when you upgrade libxcb, world or any package that depends on libxcb (I think the new Xorg >= 1.6 is one of them).

However, when things like this happen, I always wonder: Why do I have to read upgrade guides and run things manually? Isn’t emerge supposed to do this for me? I’m sure there is some kind of explanation, but isn’t there some way to get around this? Maybe an option on emerge?

Even the annoying “eselect news” doesn’t inform you about this important guide. Instead, it keeps popping up every time it finds an article that you will surely not be interested to read (an exception was the new article about KDE 3.5 and the sunset overlay).

Bring functional programming to IEEExtreme!

Tuesday, September 1st, 2009

IEEExtreme 2009 competition registration opens today, 1st of September.

This competition seems very interesting, and some kamibu members are thinking about participating!

Languages supported are: Microsoft Visual C++/C#, C/C++, C# and some “surprises”.

I would really like to see some functional programming language getting on to that list, like Common Lisp, Haskell or my favourite: Scheme!

Functional programming may be very handy some times, and a lot of fun!

For example, I tried solving last year’s “Merging IP’s” problem (see IEEEXtreme 2008 Competition booklet, pdf) using Scheme.

The goal is to merge a list of IP intervals (e.g. 192.168.1.1 – 192.168.1.60), so that you only keep a list of the minimum required intervals.

Example Input:
3.0.0.0 – 3.100.0.0
3.99.0.0 – 3.255.0.0
10.1.0.0 – 10.200.0.0
10.2.0.1 – 10.5.99.99
10.200.0.1 – 10.225.225.0

Example Output:
3.0.0.0 – 3.255.0.0
10.1.0.0 – 10.225.225.0

Let’s build the main loop for the program (without input and output functions).

Suppose we have 2 functions ready: (should-merge int1 int2) that is true only if intervals int1 and int2 should be merged (one of them starts in the middle of the other and ends after it), and (precedes int1 int2) only if both addresses of interval1 “precede” interval2 (e.g. 5.0.0.0 – 6.0.0.0 precedes 6.0.0.5-7.0.0.0).

Now, we can write a function (merge-intervals intervals merged) that will recursively merge all intervals. Intervals parameter should be a list of intervals that have to be merged, sorted by their first address.
Merged should be a list of intervals that are always totally merged. In the beginning it should be an empty list, and in the end the solution of the problem.

(define (merge-intervals intervals merged)
  ; important! intervals must be sorted
  (cond ((null? intervals) merged) ; all intervals are merged. return merged list
          ((null? merged)
            ; just started, merged is empty
            ; remove first of intervals and add it to the merged list
            merge-intervals (cdr intervals) (list (car intervals)))
          ((should-merge (car intervals) (car merged)) 
            ; the two intervals should be merged
            (merge-intervals (cdr intervals) 
              (cons 
                (merge (car intervals) (car merged)) 
                (cdr merged))))
          ((precedes (car merged) (car intervals))
            ; add the first of intervals to the top of merged
            (merge-intervals (cdr intervals) (cons (car intervals) merged)))
          (else
            ; the first of intervals starts after the last merged
            ; and ends before the last merged ends
            ; ignore it
            (merge-intervals (cdr intervals) merged))))
 
; We also used the merge function, that has a pretty straightforward definition
; returns an interval that starts at the start of int1 and ends at the end of int2
(define (merge int1 int2)
  (interval-create
    (interval-start int1)
    (interval-end int2)))

Of course, there are no built-in functions to handle intervals in Scheme, you have to write them (interval-create etc) on your own. A pair is perfect for representing an interval.

Notice that an iterative implementation would not (or at least it shouldn’t) be faster than the recursive impementation used here, as Scheme implements tail-recursion.

For those not familiar with Scheme or Lisp,
(car l) can be interpreted as returning the first item of list l
(cdr l) as returning all the items but the first of list l, and
(cons item l) as pushing item to the beginning of the list l,
although that’s not exactly what they do.

Implementing should-merge and precedes function is a piece of cake if you represent the IP addresses as an integer (like ip2long of PHP or python iptools).

Bring Scheme to IEEExtreme 2009!
Bring functional programming to IEEExtreme 2009!

P.S.: Thanks to Ted for pointing out IEEExtreme to the team :)

Frontend optimizations

Sunday, June 15th, 2008

In Excalibur Phoenix one aspect we are giving major attention to is frontend.

In contrast to Excalibur Reloaded (the previous version) we try not only to provide a user-friendly interface but we also want it to be as fast as possible for the client. The latter is mostly a need that came up as more and more users started using Zino. Furthermore, through the process of optimization we learn new techniques we weren’t keen with, that extend by far our knowledge especially on the way the browsers render a page and the lower level mechanisms that play a major part when there is a greater need for speed (the term is stolen from Google Blog :P ). So I want to write a few lines for some optimizations we started implementing in the new version.

1) Lessen HTTP requests

One of the most important aspects is to lessen the HTTP requests that are needed for a page to show properly. Till now, our pages had icons, images, many stylesheets and scripts. Each of those needed a separate HTTP request in order to download since all these files were separated. For example, we used to have the stylesheet for the user profile on a different file from the one for the frontpage. What we do now, is combine all the scripts in one file, all the stylsheets in another and so we use just two separate files for all our styling and javascript. Another thing we did is known with the term “spriting”. We combined all of our background images into one bigger image file. Everytime we need to show an icon, we use this image we created as a source and through the background-position we specify exactly which icon we want to be visible. Those are the most common and effective ways we are currently using in Phoenix

2) Cache content

Another way of reducing HTTP requests and the weight of downloading for the client is to use caching. More specifically caching with far-future headers set. To make things a bit clearer if the browser has cached some of the needed components he has to check whether those are valid according to the Last-Modified header in the response. If the component hasn’t been modified there is no need to download it, so the size of the download decreases. Though a request has been made, that could have been avoided if we used an Expires header. When we set an expires header, we are actually telling the browser to use the components in its cache till a specified date. Until this expiry date the browser uses its cached content without the need to ask for modification of the content. This is more useful with static data such as javascript, stylesheets and icons.

3) Minification

In projects where great amount of javascript is in use, minifying the code makes a lot sense. With the term minification we mean the elimination of spaces, line breaks and comments from the original code. In other words all unnecessary stuff is removed in order to lessen the size of the data the client will download. This technique can also be used for stylesheets but is not so effective. Stylesheets optimization is a bit more complex, as you can get the most of it if you find duplicate rules for elements and remove them. Some developers go a step further with obfuscation but I believe it’s not worth. In obfuscation variable and function names are changed automatically to shorter ones, in order to reduce even more the size. Another reason for using obfuscation is to make the code unreadable to others. Implementing this technique is not as simple as minification and using it should be examined carefully as bugs are likely to appear because of core function name substitution.

4) Gzipping content

One last technique worth mentioning is to use gzip compression. The use of this technique is pretty obvious. Compression reduces download sizes leading to faster downstreaming times for the client. Gzipping is supported by almost all modern browsers so it doesn’t need further browser compatibility thoughts. This technique is more effective when combined with the others described. Minification combined with gzip compression decreases significantly the size of the content. To use it though the web server should be configured properly.

Last but not least few simple things to look after are: avoiding duplicate script inclusion, loading stylesheets at the beginning of the document, scripts at the bottom and sometimes clever content preloading that will be needed later on, while the user is interacting with other parts of the page.

Zino Phoenix mockups

Thursday, April 10th, 2008

A sneak preview of the new Zino version!

Userprofile

Frontpage

Kamiblog :-)

Sunday, May 27th, 2007

Hey welcome to kamibu blog! :D

My name is Aleksis or “abresas”, and I’m honored to write the first post. Other members of the team:

Dionyziz – The big boss,

Izual – “Internet Explorer, I’m watching you”,

Kostis90gr – “I will goto..” and

Dimitris – aka Gatoni.

I am pretty excited about kamibu, and the things we are doing, but most of all excited about being member of such a team.

I’m sure everyone else is excited too!

Edit: Now we have 2 new members:

Makis – Doctor M.
and
Rhapsody – (bow), chinese not japanease