jQuery dataTable and FancyBox

Just a short note as an addon to my post some time ago about fancybox and ajax: in case a you have a table where one of the columns contains links to fancybox popups or something like that and this table is also wrapped into jQuery dataTables, do the init of fancybox prior to init of dataTables, since if you do dataTables first, all elements that are not on the current page will not be properly initialized with fancybox and thus, the links will be broken if you navigate to the next page of dataTable.

The point is that when dataTable is initiated, all elements that do not fit on a single page of a table are hidden via removal from DOM and thus not visible for fancybox init function, while if you do other way around, first fancybox is correctly set to all elements in the table and then hidden elements are removed, so when you change a page and elements are inserted back – they are already inited with fancybox and will work perfectly well.

Inception real life

Some time ago saw a real inception concept in technology. This had to do with activation process of pre-paid cards for a distributor of such cards within cards provider. Whenever a distributor needed to activate a batch of pre-paid cards (prior for those cards to be sold out), he needed to perform the following steps:

  1. Open a web page and login to distributors area on the site
  2. Click a button to launch a java applet which would open an RDP client and connect to a window server
  3. In the given RDP session click on shortcut, which would open IE with a web page of some intranet, accessible only from that RDP session
  4. In the given intranet, enter a part of LIKE SQL statement with parts of the serial number of cards to be activated and click the query button
  5. Select all/some checkboxes next to result rows of a query and press activation button

That looks pretty much like a scenario of a recent movie :)

I won’t give out any names of companies or whatsoever, just wanted to show how a simple task can be over-complicated…

Gnome3 Fallback Mode

After working for a while on Xfce, I found out about Gnome 3 fallback mode. That is almost exactly what I needed – old style Gnome. Obviously not completely like Gnome 2.x, but very very close to it.

Will work in Gnome 3 under this mode for a while to see. At least I have all my menus, applets, proper system tray and whatever else I am so used to in their correct places :)

SQL GROUP BY with max in subgroups

It’s been few times I needed to select a set of records from SQL table grouped by one column, but sorted by another within a group. For example selecting a list of log entries with the last entry per user or something like that. It is pretty simple when one needs a maximum value of a particular column per key, but what if I need all cells of a record with the biggest/smallest/whatever value of one column, and all those grouped per another column.

Finally the solution was found here and the point there is to do sorting in subquery for group select. In simple it would look like (taking example above):

SELECT * FROM (SELECT * FROM logs WHERE level=’critical’ ORDER BY created DESC) tmp_table GROUP BY user_id;

This will give me the last entry from the log with level=’critical’ per user. It is also possible to all kinds of joins and whatever in subquery. The things is that first we gather all data needed and sorted properly, and then the outed select groups it accordingly.

One additional note which has nothing to do with a query itself, but I found it out during my works related to this task. While running the above-type query on a pretty large table, I got an error from MySQL

ERROR 126 (HY000): Incorrect key file for table ‘/tmp/#sql_NNNN_x.MYI’; try to repair it

By looking around I realized that the hosting company which provided the server set up the /tmp directory of a system as a separate partition of a pretty small size and while MySQL was trying to do the requested task, it was running a bit out of space, causing a corruption of a temporary table. Specifying tmp=/var/tmp (or any other directory with some more space) in /etc/my.cnf (depending on your setup though), setting up correct permissions and restarting MySQL fixed the problem.

Visual Basic and Visual Studio

It’s been quite a while since last time I touched Visual Basic along with it’s default IDE – Visual Studio. Yesterday I had a quick chance to see it again, since I needed to help on the project which is under development in this environment.

What I can say – things are still as ugly as they used to be (IMHO). So few notes about things that pissed me off:

Auto indent in visual studio is more harmful rather than helpful. Auto completion is very annoying (it tries to complete everything I type instantly and with things different from what I want). All the time I was fighting with these two. I guess there are options to disable/enable features like that or configure different behavior, but in default configuration it sucks. Syntax highlighting is very poor (only highlights few reserved words with one different color).

Now with regards to Visual Basic: it is very interesting to see a language with uses “_” (underscore) to indicate that the line will continue after newline (VB does not use semicolons to indicate the end of statement, instead all statements are one per line), and uses ” ‘ ” (single parenthesis) to start comments. I know languages which are dependent on new lines, but more classical sign to show a continuation of line would be “\” (backslash), while for comment, either “#” (hash) or // (double slash) or /* */ (combination of slashes with starts for long comments) is used.

I had some other thoughts on function names and other, but I will leave this one out :)
Don’t trying to blame anything here, just my view of things as I touched them by accident after using Vim for coding PHP/Perl/C for a while.