Sunday, June 28, 2009

Cross browser Horizontal Rule (hr-tag)

What:

hr {
background:#d0d0d0;
color:#d0d0d0;
margin:15px 0;
height:1px;
border:none;
}

Why:
  • because Chrome creates some borders
  • because FireFox set color from css background value
  • but IE set color from css color value

Thursday, June 18, 2009

Installation of Mac OS X and iPhone SDK to Intel PC

This is a very quick note about installing of Mac OS X and iPhone SDK to my Intel PC.
  1. Install Kalyway 10.5.2, follow this detailed guide
  2. Upgrade to version 10.5.3 required by iPhone SDK 2.2, for details see forum topic on insanelymac.com (Upgrading to 10.5.3 part)
  3. Install NVinject extensions if you have NVidia card (like me) to enable high screen resolutions
  4. Install iPhone SDK (can be taken from Apple's web site)
Have fun!

Wednesday, January 21, 2009

swfmill compilation problem

You can get compilation error when compile swfmill (http://www.swfmill.org) with GCC-4.3.x or higher. Mostly it will look like:

swft_css.cpp:197: error: 'strcmp' was not declared in this scope

The reason is GCC-developers have split some header files. So some functions are in other header files now. More about it is here: http://gcc.gnu.org/gcc-4.3/porting_to.html (see section header Header dependency cleanup).

To resolve the problem open file src/swft/swft_css.cpp in an editor and add the line in the top of the file:

#include <cstring>

The same problem also exists for file src/swft/swft_import_mp3.cpp and the solution is the same.

Friday, December 5, 2008

How to make native SQL queries in Doctrine ORM

Sometimes you have situation which require writing of native SQL query in project fully based on Doctrine ORM. Doing DQL queries is very easy, but simple SQL queries maybe difficult to execute because you have to reuse database connection opened inside Doctrine.

Example given below is easy to understand and use in your project(s). Enjoy!
// get Doctrine_Connection object
$con = Doctrine_Manager::getInstance()->connection();
// execute SQL query, receive Doctrine_Connection_Statement
$st = $con->execute("...............");
// fetch query result
$result = $st->fetchAll();

Friday, November 14, 2008

Cross browser min-height (IE6 and others)

IE6 ignores CSS 'min-height' property. Fortunately it works with 'height' property exactly like other modern browsers with 'min-height'. That's why there is a possibility to write cross browser CSS, here it is:

min-height: 100px;
height: auto !important;
height: 100px;
Three lines instead of one, but it works excellent in all major browsers including IE6. Modern browsers accept 'min-height', then second line set 'height' to be automatic because there is !important keyword, which makes third line ignored. Now IE6: it ignores first line, then make height automatic but due to IE6 bug it also ignores !important keyword. That's why third line overwrites automatic height property and IE6 shows desired result.

This technique is actually well known by many web developers and very effective as you see. So I hope this help someone to save valuable time, and it's worth to place this post as part of blog knowledge base.

Friday, May 16, 2008

Logging in Shell Scripts

This post describe two methods of setting up logger when doing shell scripts. First method is useful when your script has permission to write in system log.
# setup
log='logger -t logger-id'
# usage
$log "log message..."
Second method use redirect of standard output to your log file.
# setup
function log() {
echo "`date +'%Y-%m-%d %H:%M:%S'` [$$] $1" >> script.log
}
# usage
log "log message..."

Dynamic TinyMCE / TinyMCE and AJAX

Quick note about adding and removing TinyMCE editor when working with AJAX style pages. Standard initialization tinyMCE.init() is not accepatable but we can use another function to add/remove editor dynamically.

// add editor
tinyMCE.execCommand("mceAddControl", true, elementId);

// remove editor
tinyMCE.execCommand("mceRemoveControl", true, elementId);