bug comparison in PHP

December 22, 2009 by paragasu

php do not be able to compare large int and float reliably.


$val1 = 0.2; $val2 = 0.2;
if($val1 < $val2){ echo 'it is true';}

one workaround for equal comparison is to cast the value to string type.


comparison of float value in PHP

compile midlet j2me in debian linux

November 30, 2009 by paragasu

I can’t get the ktoolbar running on my debian squeeze. Found a very good makefile from Hexist

J2ME Midlet Programming on Linux

PHP get file extension

November 24, 2009 by paragasu


$ext = pathinfo($filename, PATHINFO_EXTENSION);


get file extension comparison

debian testing + iceweasel install flash player

November 11, 2009 by paragasu


#apt-get install flashplugin-nonfree

should be working. but in my debian testing it isn’t. I have to manually create a symlinks


#ln -s /usr/lib/flashplugin-nonfree/libflashplayer.so /usr/lib/iceweasel/plugins/libflashplayer.so

to make it work.

jquery click li to activate a

November 6, 2009 by paragasu

<ul class="menu">
<li><a href="/"> Home </a></li>
</ul>

to activate the link when user click on li

$('.menu li').click(function(e){
location.href = $(this).find('a').attr('href');
});

Now, user doesn’t have to click on the “Home” to activate the link.

mysql cache SQL_NO_CACHE

November 3, 2009 by paragasu

enable query cache (maybe default depends of the server configuration)

SELECT SQL_CACHE SUM(points) FROM account;

turn off mysql query cach

SELECT SQL_NO_CACHE SUM(points) FROM account;


the mysql query cache

javascript disable back button

November 3, 2009 by paragasu

add this code in the HTML head section


<script type="text/javascript">
history.forward();
</script>

php how to replace many space with one space

October 25, 2009 by paragasu


$str = preg_replace('/\s+/', ' ', $str); //" \n\n\n" will end up as " \n"
$str = preg_replace('/\x20+/', ' ', $str); //only space

how to detect ajax request

October 20, 2009 by paragasu

ajax request will send additional header

if($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')
echo 'ajax';

stackoverflow

The page you are looking for is temporarily unavailable. Please try again later.

October 14, 2009 by paragasu

server configuration php5-cgi, php5-tidy nginx, debian etch.
Tidy configuration tab-size=>0 can trigger this error. Just change the tab-size value to be greater than 0 to fix

tab-size => 1