Monthly Archives: November 2011

Repair MongoDB

run this on terminal as mongodb user

sudo rm /var/lib/mongodb/mongod.lock
sudo -u mongodb mongod -f /etc/mongodb.conf --repair
sudo start mongodb

Apache Benchmark

Login to Linux/bsd desktop computer and type following command:

$ ab -n 1000 -c 5 http://localhost/project

Hello world!

<div id="foo">
<?php
  function foo() {
    echo "Hello World!\\n";
  }
?>
</div>

SLUG

Create SEO-friendly URL titles

function slug($str)
{
	$str = utf8_encode(html_entity_decode($str));
	$str = str_replace('&', 'e', trim(strip_tags($str)));
	$str = preg_replace('/&([A-Za-z]{1,2})(grave|acute|circ|cedil|uml|lig|tilde);/', '$1', htmlentities($str, ENT_NOQUOTES, 'UTF-8'));
	$str = preg_replace(array('([\40])', '([^a-zA-Z0-9-])', '(-{2,})'), array('-', '', '-'), $str);
	$str = str_replace('-acute', '', trim($str));
    	return strtolower($str);
}
Page 1 of 11