Software Woes

Rants, tips and tricks



Monday, August 31, 2009



why Blogger engine sucks?

I got so frustrated writing blog entries here sometimes. I don't get it: Blogger is used by (presumably) millions of users, yet the most basic things don't work.

Example 1: Characters < and > do not get transformed to &lt; and &gt; when you switch between the HTML and Compose view. This means that and switching can be fatal to the contents. If you have a piece of C or C++ code with dozen #includes - it's horror.

Example 2: Shortcuts for Italics and Bold just don't work properly when you backspace. Here, I press Ctrl+b now. Then I delete that word. The indicatior (b letter at top of compose window) shows Bold is on. I press Ctrl+B to turn it off - indicator changes to off, but bold is actually ON. I start typing and bold letters appear.

I hope this reaches someone in Blogger team and they fix these trivial issues (I won't even mind if they delete this post afterwards when it's done).

BTW, all this using Firefox 2 and 3 on Linux.



Slamd64 and Firebird

I just installed Slamd64 version 12.2. I know that Slackware -current is 64bit and Slackware 13.0 is out, but out-of-the-box 32bit compatibility of Slamd64 is very tempting, so this is the first 64bit slackware I installed.

Install went fine, and KDE is running in a matter of seconds. Now, time to compile all the needed stuff for development. Basically, all I need is Firebird, FlameRobin and PHP extension for Firebird (i.e. InterBase).

1. Compiling Firebird

You could use the binaries on the website (which I learned later), but AMD64 seemed suspicious (I run Intel Core2Duo CPU), so I decided to compile. I downloaded the .tar.bz2 source package, unpacked it and run:

./configure --prefix=/opt/firebird

Well, I first ran --prefix=/opt, but that turned out to be a bad idea :(

Anyway, configure went fine, and then I ran make -j2 because I have two cores. However, this is not supported as some steps of build process are dependend on each other while that dependency is not listed in the Makefile. Alex Peshkov says this should be fixed for Firebird 3. So, make sure you only run

make

if you don't want to see any errors. Once build is complete, run:

make dist

to create .tar.gz (and .rpm) packages. Just like official ones. Further installation using this packages goes as usual (unpack + ./install.sh).


2. Compiling FlameRobin

This was the easiest step as everything works the same as on 32bit Slackware. Compile wxWidgets first and then FlameRobin - all as usual.


3. Compiling PHP extension for Firebird (InterBase)

Using the PHP 5.2.8 source and steps on this link:

http://www.firebirdfaq.org/faq191/

does not get you far because of some bug in PHP 5.2.8. Fix is rather trivial. Before you run make, edit the files:

/usr/include/php/Zend/zend.h

/usr/include/php/main/php.h


And comment this line:

//#include <unix.h>

Of course, PHP 5.2.8 still has a bug with decimal numbers, so make sure you align those zeroes in ibase_query.c and php_ibase_udf.c files.

After that, run all the steps (phpize, configure, make) and copy interbase.so to

/usr/lib64/php/extensions

Restart Apache and enjoy!



Thursday, August 06, 2009



CodeIgniter pagination

CI has a nice pagination class, which works nice, but has many shortcomings. It has not been designed with much flexibility in mind, so you might need to roll pagination on your own in the end. What are the problems?

Let's start with a minor one: when you have 4 pages, you get:

first(1) prev(1) 2 3 last(4)

Same link repeats twice. Similar when you navigate to 4th page in the same example.

Then, there's a problem that you cannot turn some of the "components" off. For example, I don't need PREV and NEXT, just first/last and a few pages in the middle (number of those is also NOT configurable, BTW). If you don't set array members in initialize function, it uses defaul values. Default values for start and end tags are not what the docs say, and some defaults are next to useless like

It would be much better if unset stuff defaults to DO NOT DISPLAY.

The interface for pagination class was desined by some narrow minded developer who only knows one way to do pagination. For example, I do not like pure text links, but would like to use nice rectangles. I managed to get something useful with SPANs and custom CSS rules, however, I had to do some workarounds. For example, all the links use simple and clean A tag without any interface to it. So, in order to have links of different color than rest of the links on the page, one has to add some CSS class to the outer element (create a span that floats to left, for example), and then define CSS rule:

'num_tag_open' => '',
'num_tag_close' => '
',

CSS:

.pagg a { color: #fcc }

Need to define all properties to make things look right on the screen is a real PITA.

Another problem is that it only supports determinate sets. I'd like to be able to have pagination without knowing the end record count. The reason for this is that many DBMS don't perform well with SELECT COUNT(*) FROM table1 WHERE some_complex_query.

So, I just fetch initial 100-200 records and display them, showing the users that there is "more" with a link to "next" or "next 5 pages". Of course, this would mean that there is no "last" link, which brings us back to the issue that this class only solves a narrow set of problems.

After completing a first real-world project with it, I get the impression that base stuff in CI is ok, but it hasn't been tested enough in the real world situations. Many features seem to be designed more as a proof of concept than flexible framework designed for real world usage. Poor desing is also shown in Unit Testing which seems to be there just to fill the checkbox in the feature list, and also in ActiveRecord implementation which goes into sillyness of where_not, or_where and whatnot. As if writing select('column1')->from('table1')->where_in('id'=>array(10,20)) is much clearer or flexible than get_where('select column1 from table1 where id in (?)', array(10,20)). IMHO, ActiveRecord should stay on the CRUD level.