Saturday, March 20, 2010

ReBuild Pagination for Controller on CodeIgniter

this function is using for easily using pagination library in one line.
just insert this function in your controller, and the other function call it:

/**
 * set paging for easy use :)
 * @access private
 * @param string $url
 * @param int $total
 * @param int $perpage
 * @param int $numlink
 * @return void
 */
function setPaging($url='', $total=0, $perpage=20, $numlink=3){
 if(!is_numeric($total)){
  $total=0;
 }
 if(!is_numeric($perpage)){
  $perpage=20;
 }
 if(!is_numeric($numlink)){
  $numlink=3;
 }
 $this->load->library('pagination');
 $segment=explode('/',$url);

Wednesday, March 10, 2010

8 basics of regular expression that can make you expert

Well, regular expressions have been something that I was scared of when I started coding as a serious stuff. The string literals puzzled me like anything. preg_match, preg_grep, preg_split, preg_replace etc have been something I always wanted to avoid. But thanks to phpbuilder and php that I can now handle them with some ease. And this is for you guys who find regular expressions tacky.


VERY BASICS:
1. "^tech" : Searches a string that starts with tech.
2. "logy$" : Searches for strings that ends up in logy.
3. "a*b" : Looks for a string that has either zero or more a’s but exactly one b following a. (eg. b, ab, aab, aaab, aaaaaaaaaaaaaaaaab etc.).
4. "a+b" : Same as a*b but only difference is that atleast one a should be there in the string unlike a*b which can overlook a. (eg. ab, aab,aaaaaaaaab etc).

Sunday, March 7, 2010

How to Disabling "My Aptana" "Startup Page"

open menu:
Window -> Preferences

select tab:
Aptana -> My Aptana

select option:
Never display after startup

click [Apply] than click [OK]

thats all.