July 31, 2012

Database Optimization Experience – Rackspace Cloud

Database Optimization Experience – Rackspace Cloud Conversation: Hello, It has come to our attention that the database xyz has been running some queries that take an extremely long time to complete and have started to become detrimental to the shared resource that the database is hosted on. At this time, we have not imposed any […]

July 23, 2012

MySql – how to remove on update current_timestamp

Example: Table Name: tbl_user Field Name: user_created Solution: ALTER TABLE tbl_user CHANGE `user_created` `user_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP

July 10, 2012

Fetch your tweets with PHP

Fetch your tweets with PHP PHP Function: Filename: tweets_code.php function tweets() { $q=’phpFlex’; $tweets = file_get_contents(‘http://search.twitter.com/search.json?q=’.$q.’&rpp=2&include_entities=false&with_twitter_user_id=true&result_type=recent’); $tweets_obj = json_decode($tweets); $return = array(); if(count($tweets_obj)>0) { if(isset($tweets_obj->results) && count($tweets_obj->results)>0) { foreach($tweets_obj->results as $key=>$result) { $return[$key][‘text’] = $result->text; } } } echo json_encode($return); } Javascript Functions:   function get_tweets() { var tweets_url = ‘tweets_code.php’; $.get(tweets_url, function(data) { var […]

June 20, 2012

javascript regular expression for alphabets and space

js regular expression for alphabets and space Note: A useful javascript function which i mostly use to manage names and related fields validation. function checkName(field,title) { var val = $(“#”+field).val(); var re = /^([a-zA-Z _-]+)$/; if(val.length<1) { $(‘#error_’+field).text(title+’ is required.’); $(‘#error_’+field).addClass(‘error-msg’); return false; } else if(!re.test(val)) { $(‘#error_’+field).text(‘Please enter a valid name.’); $(‘#error_’+field).addClass(‘error-msg’); return false; […]

June 15, 2012

Codeigniter Error Reporting – Intelligent Fix

Codeigniter Error Reporting – Intelligent Fix Description: This little fix will help you to manage the error reporting automatically that if you ever will go online so error reporting will be disabled and when you will import you database in localhost and development phase will be continued so no headache of changing this ENVIRONMENT constant […]

June 13, 2012

Linked In Share Button Customization

<a href=”http://www.linkedin.com/shareArticle?mini=true&url={your_url}&title={your_caption}&summary={your_message}&source={your_source}” target=”_new”>Linked In</a> Note: Linked In text can be replaced by image tag or you can customize it in your own way because basic hurdle was the URL you were finding. I will update this post further regarding the POST Image .

June 4, 2012

preg_replace to replace specific tag in string

preg_replace to replace specific tag in string if ( ! function_exists(‘clean_this’)) { function clean_this($tag_name,$html) { return preg_replace(“/(<“.$tag_name.”>.+?)+(<\/”.$tag_name.”>)/i”, ”, $html); } } Keep hyperlink text and remove href $cart_item = ‘<a>’.preg_replace(“/\<a(.*)\>(.*)\<\/a\>/iU”, “$2”, $cart_item).'</a>’;

May 31, 2012

jQuery AlphaNumeric

jQuery AlphaNumeric $(obj).alphanumeric(); eval(function(p,a,c,k,e,d){e=function(c){return(c<a?””:e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!”.replace(/^/,String)){while(c–){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return’\\w+’};c=1};while(c–){if(k[c]){p=p.replace(new RegExp(‘\\b’+e(c)+’\\b’,’g’),k[c])}}return p}(‘(2($){$.c.f=2(p){p=$.d({g:”!@#$%^&*()+=[]\\\\\\\’;,/{}|\\”:<>?~`.- “,4:””,9:””},p);7 3.b(2(){5(p.G)p.4+=”Q”;5(p.w)p.4+=”n”;s=p.9.z(\’\’);x(i=0;i<s.y;i++)5(p.g.h(s[i])!=-1)s[i]=”\\\\”+s[i];p.9=s.O(\’|\’);6 l=N M(p.9,\’E\’);6 a=p.g+p.4;a=a.H(l,\’\’);$(3).J(2(e){5(!e.r)k=o.q(e.K);L k=o.q(e.r);5(a.h(k)!=-1)e.j();5(e.u&&k==\’v\’)e.j()});$(3).B(\’D\’,2(){7 F})})};$.c.I=2(p){6 8=”n”;8+=8.P();p=$.d({4:8},p);7 3.b(2(){$(3).f(p)})};$.c.t=2(p){6 m=”A”;p=$.d({4:m},p);7 3.b(2(){$(3).f(p)})}})(C);’,53,53,’||function|this|nchars|if|var|return|az|allow|ch|each|fn|extend||alphanumeric|ichars|indexOf||preventDefault||reg|nm|abcdefghijklmnopqrstuvwxyz|String||fromCharCode|charCode||alpha|ctrlKey||allcaps|for|length|split|1234567890|bind|jQuery|contextmenu|gi|false|nocaps|replace|numeric|keypress|which|else|RegExp|new|join|toUpperCase|ABCDEFGHIJKLMNOPQRSTUVWXYZ’.split(‘|’),0,{}));