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

Debian usb mouse freeze

October 5, 2009 by paragasu

you should have

Option "SendCoreEvents" "true"

inside the Section “Input Device”, Driver “mouse”

php add leading zero

October 3, 2009 by paragasu


echo $num; // 1
$str = sprintf('%02d', $num, 2);
echo $str; //01

php get the number of days between two dates

October 2, 2009 by paragasu


$timestamp = strtotime($end_date) - strtotime($start_date);
$days = round($timestamp / 86400);

this code only works on linux box.

global distribution system (CDS)

October 1, 2009 by paragasu

many website like tripadvisor.com or lastminutes.com pull the information from CDS. One free provider is Kayak.com but usage is restricted to 1000 queries/day.

kayak.com
airline reservation system
Hotel booking system