Fixing IE6 W3C complience

June 21st, 2007 by Alexander Mamchenkov

No, no way you can completely fix IE6 to be compatible with W3C standards, but at least you can fix some (a lot) of them very easy instead of killing yourself all the time something goes wrong in IE6 while it works fine in FF and even IE7.

Today I had to do some tricky web-design related things and I was mostly checking the results in FF2 and IE7. When I opened the page in IE6, I found out a lot of problems, especially with absolute positioning and overflowing of DIV elements. Luckelly I found the IE7 JavaScript library which fixes the IE6 just by including 3 lines in your page (linking to this lib).

Check it yourself if you are having similar problems.

Posted in Technology, Links, Browsers, Firefox, Internet Explorer, Programming | No Comments »

Transparent background in Midnight Commander

June 13th, 2007 by Leonid Mamchenkov

Transparent background in Midnight Commander has been around for some time, but far too less people realize and use it. If you are one of those guys who just have to have everything transparent, then here is the quick fix for you.

Add these two lines to the end of your ~/.mc/ini file:


[Colors]
base_color=normal=,default:selected=,:marked=,default:markselect=,:menu=,:menuhot=,:menusel=,:menuhotsel=,:dnormal=,:dfocus=,:dhotnormal=,:dhotfocus=,:input=,:reverse=,:executable=,default:directory=,default:link=,default:device=,default:special=,:core=,:helpnormal=,:helplink=,:helpslink=,:

Now restart Midnight Commander, and you should be fine.

An extra tip for KDE users - edit your konsole settings and choose “Transparent for MC” schema.

That’s about it.

Posted in Technology, Linux, OS, Programming, Shell | No Comments »

RRDTool Graphing Tips

April 5th, 2007 by Alexander Mamchenkov

I’ve been working with RRDTool graphs a lot for the past few days and noted a couple of nice tips for myself which I want to share here:

Graphing Real Numbers as Integers

Sometimes your database contains number in real format (ex: 4.23) and you want to see only integer values on the graphs. For example the database keeps track of number of users sessions and computes AVERAGE, but since having 2.123 sessions number is not that nice (for me at least in this case), it is possible to round it up to integer and have 2 (or 3 if the original real number was more or equal to 2.5). For this, in the graph definition, you need to create a variable to store integer as follows (hate this postfix notation type):

CDEF:var_int=var_real,1,%,0.5,GE,var_real,CEIL,var_real,FLOOR,IF

In normal notation it would look like <code>var_int = (var_real % 1 >= 0.5) ? round_up(var_real) : round_down(var_real)</code> and would round the real var_real number to the upper or lower corresponding integer according to the value after the delimiter. So after such definition you can use var_int for graphing any shapes.

Graphing the Unknowns

It is a good practice to change the background of the graph parts where all variables are unknown. In order to graph such areas I first check if the all variables are defined and if not, I create two other variables, one with value from 0 to -unlimited and second from 0 to +unlimited and display them as AREAs of the same colors. So here we go:

CDEF:u=var1,var2,+,UN,INF,UNKN,IF creates a variable to indicate 0 to +unlimited if the sum of all actual variables is unknown

CDEF:u2=var1,var2,+,UN,NEGINF,UNKN,IF creates a variable for 0 to -unlimited under the same conditions as u.

AREA:u#FFFFB9
AREA:u2#FFFFB9

displays the AREAs with a color I like.

Examples

Let me just post couple of examples of graph definitions here:

<RRD::GRAPH firewall-Net:Traf-LAN.png -w 845 -s <RRD::CV period> -c BACK#FFFFFF -c SHADEA#FFFFFF -c SHADEB#FFFFFF -c FRAME#0000 00 -W 'IT Department' -v "Bits" --title="firewall - LAN Traffic"
DEF:up_rrd=firewall-Net\:Traf-LAN.rrd:up:AVERAGE
DEF:down_rrd=firewall-Net\:Traf-LAN.rrd:down:AVERAGE
CDEF:up=up_rrd,8,*
CDEF:down=down_rrd,8,*
CDEF:down_show=down,-1,*
VDEF:down_min=down,MINIMUM
VDEF:down_ave=down,AVERAGE
VDEF:down_max=down,MAXIMUM
VDEF:up_min=up,MINIMUM
VDEF:up_ave=up,AVERAGE
VDEF:up_max=up,MAXIMUM
COMMENT:' '
COMMENT:' Max'
COMMENT:' Ave'
COMMENT:' Min\n'
COMMENT:' \n'
AREA:down_show#00FF00:'Incomming '
GPRINT:down_max:'%8.2lf%Sb'
GPRINT:down_ave:'%8.2lf%Sb'
GPRINT:down_min:'%8.2lf%Sb\n'
AREA:up#0000FF:'Outgoing '
GPRINT:up_max:'%8.2lf%Sb'
GPRINT:up_ave:'%8.2lf%Sb'
GPRINT:up_min:'%8.2lf%Sb\n'
CDEF:u=up,down,+,UN,INF,UNKN,IF
CDEF:u2=up,down,+,UN,NEGINF,UNKN,IF
AREA:u#FFFFB9
AREA:u2#FFFFB9
>

The above definition is for traffic monitoring

<RRD::GRAPH firewall-Net:Conn.png -l 0 -w 380 -s <RRD::CV period> -c BACK#FFFFFF -c SHADEA#FFFFFF -c SHADEB#FFFFFF -c FRAME#000000 -W 'IT Department' -v "Connections" --title="firewall - Established TCP Connections"
DEF:total=firewall-Net\:Conn.rrd:total:AVERAGE
CDEF:total_show=total,1,%,0.5,GE,total,CEIL,total,FLOOR,IF
VDEF:total_min=total,MINIMUM
VDEF:total_ave=total,AVERAGE
VDEF:total_max=total,MAXIMUM
COMMENT:' '
COMMENT:' Max'
COMMENT:' Ave'
COMMENT:' Min\n'
COMMENT:' \n'
AREA:total_show#0000FF:'Connections '
GPRINT:total_max:'%10.0lf'
GPRINT:total_ave:'%10.0lf'
GPRINT:total_min:'%10.0lf\n'
CDEF:u=total,UN,INF,UNKN,IF
CDEF:u2=total,UN,NEGINF,UNKN,IF
AREA:u#FFFFB9
AREA:u2#FFFFB9
>

And this one is showing the number of established TCP connections.

Note that both graphs use the <RRD::CV period> as a definition of the beginning of the graph period. I use this when viewing the graph by supplying the ?period=-1h or similar to display the graphs for different time periods.

Posted in Technology, Network, Programming | No Comments »

Backup and FTP clients

March 6th, 2007 by Leonid Mamchenkov

Today I needed a script that would backup selected directories on a filesystem (Linux box) and upload them to an FTP server.  It seemed like something I did several times and could easily visualize, but I didn’t have a handy solution.

A quick Google search helped me to locate an excellent backup script that did almost everything that I needed.  It does both filesystems and MySQL databases out of the box, weekly full and daily incremental backups, uploads backup files to FTP, and emails sysadmin if backup failed.  And it’s only a few shell lines long.

As I said, it did almost everything.  I still had to customize a few things.

First of all, I removed MySQL dumps, since I didn’t need them for that specific host.  Although it might come in handy next time.  Secondly, I changed it to always send email to administrator, not only when the job failed.  That’s just my personal preference.  Thirdly, I changed it to use FTP over SSL, rather than open FTP protocol.

That last thing took me some time to do right.  By default, the script is using NcFTP. But NcFTP, it turns out, does not support secure FTP transfers.  I needed something else.  Comparison of FTP clients Wikipedia page came in handy.  I tried using cURL, which kept complaining about malformed URL.  So, I tried yet another one - lftp - and it all worked out.
Now, with this knowledge it’ll take you only a couple of minutes to modify the original script to do a better job.

Posted in Technology, Linux, Network, FTP, OS, Security, Programming, Databases, MySQL, Shell, Backup | No Comments »

Database abstraction in PHP

February 25th, 2007 by Leonid Mamchenkov

If you often interact with databases from your PHP scripts, consider using ezSQL. It is a database abstraction layer, somewhat similar to Perl’s Class::DBI.  Here is a quote from the web site:

It is one php file that you include at the top of your script. Then, instead of using standard php database functions listed in the php manual, you use a much smaller (and easier) set of ezSQL  functions.

It automatically caches query results and allows you to use easy to understand functions to manipulate and extract them without causing extra server overhead.

It has excellent debug functions making it lightning-fast to see what’s going on in your SQL code.

Most ezSQL functions can return results as Objects, Associative Arrays, or Numerical Arrays.

Posted in Technology, Programming, Databases, PHP, Perl, MySQL | No Comments »