Get category id in category.php

<?php
$category_id = get_cat_ID(single_cat_title("",false));
?>

Getting post thumbnail

<?php
if (has_post_thumbnail()):
 $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large');
 echo '<a href="'.get_permalink().'"><img src="'.get_bloginfo('template_url').'/timthumb.php? src='.$thumbnail[0].'&amp;amp;w=715&amp;amp;zc=1&amp;amp;q=95&amp;a=tl" width="715" alt="'.get_the_title().'" /></a>';
 endif;
?>
 <?php
                            if (has_post_thumbnail()):
                                $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large');
                            ?>
                            <a href="<?php echo $thumbnail[0];?>" class="modal"><img src="<?php bloginfo('template_url');?>/timthumb.php?src=<?php echo $thumbnail[0];?>&amp;w=218&amp;h=135&amp;zc=1&amp;q=95&amp;a=tl" class="frame_img" /></a>
                            <?php endif;?>

Earthquake experienced in Kathamandu

We experienced earth quake in kathmandu today.

str_word_count not counting numbers

I had problem where the str_word_count did not count the numbers as words.
resolved by adding numbers to the charlist

str_word_count($content, 0, '0123456789');

reportisp.com

Reportisp.com is a site to review and rate your isp. We know you have lots of complaints about your isp and all. their support sucks. Try reviewing your isp in this site and lets hope some ISP’s will listen.
link: www.reportisp.com

Better Session handling in php app

Have you ever wondered why your session are not properly working as expected? Well session depends on various server configurations. On this post I will show you better way to handle sessions in your php apps.

garbage collection max life time: This is to set the no of seconds you want your session to be live on your app. Can be around 1 -2 hrs to whole day depending upon you apps. default is 1400 secs which might now be what you want. These code goes to your bootstrap file or header file where your php app uses as setting environment for your app.

ini_set('session.gc_maxlifetime', 'replace this with no of seconds you want your session to be live');

If you have changed the above value then you will need to set a separate session directory for your app. which can be in your home folder.
So this will make sure it is not overridden by other apps setting.

ini_set('session.save_path', 'path to the session writable directory');  

After you set up this two settings in your apps. You will be better session handling in your php app. Make sure the session save path is writable. or you can also use saving session data to database approach as i have mentioned before here.

Why do i use elance?

I have been using elance for a year now.I am service provider for web development projects mostly. Been active from last 7-8 month. I have already done more than 35 successful projects on elance. I just like the way I can manage my projects on elance. I am secured by escrow payment system and collaboration tools they provide is awesome. Clients I made through elance are far more better than ones I used to get on other freelancing sites.
Elance just makes it easier to deliver work on projects on time. Invoicing, billing are snap. Working on a team is more than easier. You can better market your skills on elance with elance tests which shows your ranking among others elance users. Jobs and projects are of good budget.

Elance is better for service buyer aswell. Of what i have seen elance has one of the best service providers who are trust worthy and accountable. Elance can be used for lower price budget below $500 to any budget projects. You can also open hourly project where service buyer has to pay provider on hourly basis which can be tracked with a application called tracker that elance provides for guaranteed payment.
Please take time to read elance guide before you start so that you use elance on it’s maximum and get your works done.

Go to Elance | My profile at elance

simple youtube url to embed code function

function yt_link_embed($yt_link, $width = 425, $height = 349)
{
	$key = substr(str_replace('http://www.youtube.com/watch?v=','',$yt_link), 0, 11);
	$return = '<iframe width="'.$width.'" height="'.$height.'" src="http://www.youtube.com/embed/'.$key.'" frameborder="0" allowfullscreen></iframe>';
	return $return;
}
//example of calling function
yt_link_embed('http://www.youtube.com/watch?v=p-QotWyPynA');

This is a simple example for new embed code of youtube from youtube link.

Print_r function in javascript

So you frequently use print_r for debugging your php codes? are you in need of equivalent function in javascript? Yes i was and you might be too. It is really hard to debug the code without print_r functionality. Below is the code that you can use to make something equivalent in javascript aswell.

function dump(arr,level) {
		var dumped_text = "";
		if(!level) level = 0;

		//The padding given at the beginning of the line.
		var level_padding = "";
		for(var j=0;j<level+1;j++) level_padding += "    ";

		if(typeof(arr) == 'object') { //Array/Hashes/Objects
			for(var item in arr) {
				var value = arr[item];

				if(typeof(value) == 'object') { //If it is an array,
					dumped_text += level_padding + "'" + item + "' ...\n";
					dumped_text += dump(value,level+1);
				} else {
					dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
				}
			}
		} else { //Stings/Chars/Numbers etc.
			dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
		}
		return dumped_text;
	}

Place this function in your js code at top then to debug any variable object or array use this

alert(dump(variable));

That’s it I hope you find it useful coz it has really helped me a lot in my daily development works.

subisu internet sucks

I have been using subisu internet for a while. I was offered  3 months subisu internet for the rate of  NRs 3000 per month but the subisu cable internet I was offered was the worst I had ever experienced. I didnot expected subisu would ever do this to me. There was frequent down time in my area. At most there was 2 days down time. and for least there was 2 hrs down time a day. so what i asked subisu for refund was to extend the time of their subisu internet service for me. What they offered me was just 1 day extension. of subisu internet and this just sucks I expected for better customer satisfaction from subisu but this was the worst experience ever. I was satisfied with ntc ADSL and now I am sorry I even considered subisu. I will be never returning back to subisu again and will suggest everyone to stay away from subisu. because their service sucks. I am working on new site  reportisp.com where consumer will be able to repost about their ISP. I hope this will bring some awareness among consumers so that the provider won’t be able to tell any consumer to go mike around tudikhel and it would not effect them. I am strict and sure, don’t even consider subisu cable internet from subisu if you are serious about internet and want it to be available 24/7. I will even mike and share about my frustration with subisu with everyone i encounter and tell them to stay away from the subisu service. They really suck. ADSL is the best service if you want better internet for browsing. there are other ISP you can consider with. Don’t even consider subisu if you are serious about nternet. Try websurfer or himaltech


Tags