Friday, April 18, 2008

how to use xHTML tags with XSLT

on my current task i started to use XSLT heavily. i have a set of XML-files and when anybody viewing them, browser applies specified XSLT-file.

as more than i used combinations of this technologies, was very impressed how things can be done easily.

today i got some issue. i had some code portion in XML that contains xHTML tags.

XML content:

<output><![CDATA[
<em>err assertFalse</em>
out assertFalse
failure assertFalse(junit.SimpleTest1): error message
]]></output>


XSLT formatting:

<pre>
<xsl:value-of select="output"/>
</pre>


so i need to show this output content to user using inside xHTML tags, so first line expected to be emphasized. but it not! all because, XSL processor escaping special characters by default ("<" to "&lt;") to make valid output.

i found helpful links on Dev Shed forum. all you need, is to add disable-output-escaping="yes".


<pre>
<xsl:value-of select="output" disable-output-escaping="yes"/>
</pre>


btw, it's working only in IE-family and Safari. it's funny discussion at FF bugzilla started 2001-09-04 and to thus far.

Friday, April 11, 2008

get firefox or opera, not IE

Saturday, March 15, 2008

ideal web environment structure tips

why to compile


i think, you should do this cause this way you can enable only required stuff for all your programs (such apache web server, mysql, php, etc).


for example, i don’t need all default modules in my apache that eat more memory than application can use. same thing — php.



configuration files


vi is good. i even know how to use it. but i prefer to make symbol links to my config files (httpd.conf, my.conf, etc) to some place where it automatically backup’d and i can access via windows editors to change, copy, share them. this files only read by daemons on startup. while windows still default os in many companies…



to be contunied…

Thursday, March 6, 2008

mysql performance tips

INSERT DELAYED ...

The DELAYED option is very useful if you have clients that cannot or need not wait for the INSERT to complete. This is a common situation when you use MySQL for logging and you also periodically run SELECT and UPDATE statements that take a long time to complete. It gets an okay from the server at once, and the row is queued to be inserted when the table is not in use by any other thread. Also inserts from many clients are bundled together and written in one block.

Wednesday, March 5, 2008

mysql dba queries

this post is small refcard of useful queries to understand your database and find some problems. list will be updated constantly with new ones.

--- mysql-dba-queries.sql --------------------------------

SHOW DATABASES;

SHOW PROCESSLIST;
SHOW FULL PROCESSLIST;
SELECT VERSION();

/* http://dev.mysql.com/doc/refman/5.0/en/mysqld-server.html */
SHOW VARIABLES;
SHOW VARIABLES LIKE '%innodb%';

/* http://dev.mysql.com/doc/refman/5.0/en/show.html */
SHOW STATUS;
SHOW GLOBAL STATUS;

SHOW GRANTS;
SHOW GRANTS FOR 'viewer';

SHOW ENGINES;
SHOW CHARSET;
SHOW COLLATION;

/* Find total number of tables, rows, total data in index size for given MySQL Instance */

SELECT
COUNT(*) `tables`
, CONCAT(ROUND(SUM(`table_rows`)/1024, 2), ' K') `rows`
, CONCAT(ROUND(SUM(`data_length`)/1048576, 2), ' M') `data`
, CONCAT(ROUND(SUM(`index_length`)/1048576,2), ' M') `idx`
, CONCAT(ROUND(SUM(`data_length`+`index_length`)/1048576, 2), ' M') `total_size`
, ROUND(SUM(`index_length`)/SUM(`data_length`), 2) `idx_frac`
FROM
`information_schema`.`TABLES`;


/* Find biggest databases */

SELECT
`table_schema`
, COUNT(*) `tables`
, CONCAT(ROUND(SUM(`table_rows`)/1024, 2), ' K') `rows`
, CONCAT(ROUND(SUM(`data_length`)/1048576, 2), ' M') `data`
, CONCAT(ROUND(SUM(`index_length`)/1048576, 2), ' M') `idx`
, CONCAT(ROUND(SUM(`data_length`+`index_length`)/1048576, 2), ' M') `total_size`
, ROUND(SUM(`index_length`)/SUM(`data_length`), 2) `idx_frac`
FROM
`information_schema`.`TABLES`
GROUP BY
`table_schema`
ORDER BY
SUM(`data_length`+`index_length`) DESC
LIMIT 10;


/* Data Distribution by Storage Engines */

SELECT
`engine`
, COUNT(*) `tables`
, CONCAT(ROUND(SUM(`table_rows`)/1024, 2), ' K') `rows`
, CONCAT(ROUND(SUM(`data_length`)/1048576, 2), ' M') `data`
, CONCAT(ROUND(SUM(`index_length`)/1048576, 2), ' M') `idx`
, CONCAT(ROUND(SUM(`data_length`+`index_length`)/1048576, 2), ' M') `total_size`
, ROUND(SUM(`index_length`)/SUM(`data_length`), 2) `idx_frac`
FROM
`information_schema`.`TABLES`
GROUP BY
`engine`
ORDER BY
SUM(`data_length`+`index_length`) DESC
LIMIT 10;


--- mysql-dba-queries.sql ----------------------------EOF-

Thanks to:
— Peter Zaitsev and his MySQL Performance Blog
MySQL Documentation