E-cigarettes / Vaping

e-cigaretteA friend of mine showed me these cool little ecigs a while ago. I found them, as my first introduction to vaping, quite good. A little bit of throat hit (not much) and the same effect of drawing smoke back seemed like a great gimmick at the time.

So a month or so later, I revisited investigating ecigarettes and vaping, and bit the bullet.

I have been vaping now for just over 4 weeks. Not one analog cigarette in that time. In fact, I haven’t bought real cigarettes for 5 weeks.
As a pack a day heavy smoker, that means I have saved myself about $100 per week.

Am feeling a lot better, although nobody told me that this vaping lark (buying assorted shinies) is almost as addictive as cigarettes!

http://www.deregular.com/wp-content/uploads/2013/06/e-cigarette-300x225.jpgDigg ThisShare via email
Submit to reddit

Clock for Motorcycle

It was getting a little annoying having to take off a glove to look at my watch or struggle with my zippers with gloves on to take out my mobile phone in order to check the time when on the road with the bike.

So I came up with a quick and dirty way to put a clock on the instrument panel.

At first I wanted to find a cheapo watch with a velcro band to attach to the bars, but alas, I could not find one, after spending the entire day hunting around cheap as chips, and similar stores.

What I did find however was what was called a “Silicon Watch”, at “The Reject Shop” for a couple of dollars.

These watches are fairly stretchy, made of silicon obviously, and best of all have a digital display board inside of them. Much to my joy, I found once I’d taken the digital display out of the stupid silicon band, that it was actually wrapped in hard heat shrunk plastic!

 

It was originally clear when I took it out, but I gave it a tickle up with a black permanent marker.

Then attached a little stick-on velcro to the back of it.

Stuck the other part of the velcro to my instrument cluster…

And whala!

Not sure how this will work at night time, perhaps the light from the instruments might give me enough to see it. Not sure yet.

 

http://deregular.com/wp-content/uploads/2012/10/clockforbike2-224x300.jpgDigg ThisShare via email
Submit to reddit

Bing Rank Checker: PHP function to get Bing rank for keyword

Here is the Bing rank function kids. Bing Rank Checker.

Enjoy!

/* Function to get ranking position of domain for given keyword.
 * var $keyword [string]
 * var $domain [string] | www.domain.com | domain.com
 * Whichever you expect your domain to be listed with or without www prefix.
*/
function bingrank($keyword,$domain){

	$rank = '0';
	$urls = array();

	for($i=0;$i<5;$i++){

		$rn=$i=='0'?'':$i;

		$query = "http://www.bing.com/search?q=".urlencode($keyword)."&first=".$rn."1";

		$result_page = file_get_contents($query);

		preg_match_all('/class="sb_tlst"><h3><a href="(.*?)"/',$result_page,$matches);

		foreach($matches[1] AS $url){
			$urls[] = $url;
		}

	}

	for($i=0;$i< count($urls);$i++){

		if(stristr($urls[$i],'http://'.$domain)){

			$rank = $i +1;
			break;

		}

	}

	return $rank;

}
Save on DeliciousDigg ThisShare via email
Submit to reddit

Yahoo Rank Checker: PHP function to get Yahoo rank for keyword

Here is the function to get Yahoo rank for your keyword and domain. Yahoo Rank Checker.

As with the Googlerank function in the previous post, if you want the function to search through more yahoo pages
change the for($i=0;$i<5;$i++){ line in the code.

Enjoy!

Next will a function to get your ranking in “Bing”.

/* Function to get ranking position of domain for given keyword.
 * var $keyword [string]
 * var $domain [string] | www.domain.com | domain.com
 * Whichever you expect your domain to be listed with or without www prefix.
*/
function yahoorank($keyword,$domain){

	$rank = '0';
	$urls = array();

	for($i=0;$i<5;$i++){

		$rn=$i=='0'?'':$i;

		$query = "http://search.yahoo.com/search?p=".urlencode($keyword)."&b=".$rn."1";

		$result_page = file_get_contents($query);

		preg_match_all('/class="yschttl spt" href="(.*?)">/',$result_page,$matches);

		foreach($matches[1] AS $url){
			$urls[] = $url;
		}

	}

	//print_r($urls);exit();

	for($i=0;$i< count($urls);$i++){

		if(stristr($urls[$i],'http://'.$domain)){
		$rank = $i +1;
		break;
		}

	}

	return $rank;

}
Save on DeliciousDigg ThisShare via email
Submit to reddit

Google Rank Checker: PHP function to get googlerank for keyword

Ok kids, I’m going to break these down into functions so it’s easier and you can put them in your projects rather than me recreating an entire application to run them all at once.

This one is a PHP function to return your ranking for a keyword in Google. The Google Rank Checker.

  1. Provide your keyword and domain in the form.
    (make sure you use the correct suffix for your domain – www.domain.com or domain.com
  2. Hit the button
  3. The function returns the ranking position

(NOTE: This function only goes through the first 5 pages of the google index, meaning x50 results. If you want it to go higher it will take longer to run, but you can do it by altering the below part, just alter the “5″ for how many pages you want to run through.)

for($i=0;$i<5;$i++){

Ok here is the full function, enjoy:

/* Function to get ranking position of domain for given keyword.
 * var $keyword [string]
 * var $domain [string] | www.domain.com | domain.com
 * Whichever you expect your domain to be listed with or without www prefix.
*/
function googlerank($keyword,$domain){

	$rank = '0';
	$urls = array();

	for($i=0;$i<5;$i++){

		$rn=$i=='0'?'':$i;

		$query = "http://www.google.com.au/search?q=".urlencode($keyword)."&start=".$rn."0&sa=N";

		$result_page = file_get_contents($query);

		preg_match_all('/<h3><a href="(.*?)"/',$result_page,$matches);

		foreach($matches[1] AS $url){
			$urls[] = $url;
		}

	}

	for($i=0;$i< count($urls);$i++){

		if(stristr($urls[$i],'http://'.$domain)){

		        $rank = $i +1;
		        break;

		}

	}

	return $rank;

}
Save on DeliciousDigg ThisShare via email
Submit to reddit

Useful PHP functions to get website statistics from Google, Yahoo and Alexa

Ok so nobody really wants a full blown tool to check their stats on Google, Yahoo, and Alexa.

But I figured that since I looked for something like this quite a while ago I’d give you guys some small functions to use in whatever scripts you’re building so you can grab backlink numbers, pages indexed and Alexa ranking.

It might save someone some time trying to figure out the regex etc..

It’s not the be all and end all, but it works and does the job.
It goes out and grabs:

  • Google Inlinks amount
  • Google Backlinks amount
  • Yahoo Inlinks amount
  • Yahoo Backlinks amount
  • Alexa Ranking

If it stops working, don’t blame me, the SE’s quite often change their layouts, but put a comment on this post and I might have a quick look and post an update.

For those of you familiar with curl, you can probably swap out the ‘file_get_contents’ in favour of using the Curl library with Proxy attached in order to avoid getting your IP blocked. Although you’d have bad data due to different country specific IP’s.

It should be fine without if you don’t use it too much.

Enjoy!

function googleindexed($domain) {
		$results='';
		$query="http://www.google.com/search?q=site:".urlencode($domain)."";
		$results=file_get_contents($query);

		preg_match("/About (.+?) results/", strip_tags($results), $match);

		if(isset($match) && isset($match[1])) {
			$sub_google = $match[1];
		}else{
			$sub_google='0';
		}

		return $sub_google;

    }

    function googlebls($domain) {
		$results='';
		$query="http://www.google.com/search?q=link:".urlencode($domain)."";
		$results=file_get_contents($query);

		preg_match('/<div id=resultStats>(.+?) result/ism', $results, $match);

		if(isset($match) && isset($match[1])) {

			$sub_google=str_replace('About ','',$match[1]);
		}else{
			$sub_google = '0';
		}

		return $sub_google;

    }

    function yahooindexed($domain) {
		$results='';

		$query="http://siteexplorer.search.yahoo.com/siteexplorer/search?ei=UTF-8&p=".urlencode($domain)."&bwm=p&bwms=p&searchbwm=Explore+URL";
		$results=file_get_contents($query);
		preg_match("/Pages \((.+?)\)/", strip_tags($results), $match);
		@$matchtrimmed=array_walk($match,'trim_value');

		if(isset($match) && isset($match[1])) {
			$tmp=str_replace("about","",$match[1]);
			$sub_yahoo = trim($tmp);
		}else{
			$sub_yahoo=0;
		}

		return $sub_yahoo;

    }

    function yahoobls($domain) {
		$results='';

		$query="http://siteexplorer.search.yahoo.com/siteexplorer/search?ei=UTF-8&p=".urlencode($domain)."&bwm=p&bwms=p&searchbwm=Explore+URL";

		$results=file_get_contents($query);
		preg_match("/Inlinks \((.+?)\)/", strip_tags($results), $match);

		if(isset($match) && isset($match[1])) {
			$tmp=str_replace("about","",$match[1]);
			$sub_yahoo = trim($tmp);
		}else{
			$sub_yahoo=0;
		}

		return $sub_yahoo;

    }

    function alexa($domain){
    	$results = '';
    	$query = 'http://www.alexa.com/siteinfo/'.$domain;

    	$results=file_get_contents($query);

    	preg_match('%<img src="/images/icons/globe-sm.jpg" alt="Global" style="margin-bottom:-2px;"/>(.+?)</div>%ism', $results, $match);

		if(isset($match) && isset($match[1])) {
			$sub_alexa = trim($match[1]);
		}else{
			$sub_alexa=0;
		}

		return $sub_alexa;

    }
Save on DeliciousDigg ThisShare via email
Submit to reddit

PHP functions that you may not know about

I use PHP everyday, it is my scripting language of choice for web applications.  While I am a fairly advanced user and OO advocate, there are still things that I learn everyday.

Here I have compiled a bunch of functions that I have found useful that you probably have never heard of.

1. strstr() stristr()
Used to compare a partial string to a full string and find a match.
Note: strstr is case sensitive, and stristr is not.
Usage:

if(stristr('PHP is a great scripting language.','PHP')){
        echo 'Match found.';
}

2. ip2long() long2ip()
This can be used to store ip addresses as integers instead of strings.
This can speed up your database by not having to store the extra chars.

3. checkdnsrr();
This function can check that a domain name exists and resolves to an IP address.

4. Get remote IP address
The below snippet will retrieve the users ip address, unfortunately this will not work if the user is behind a proxy, but there is a script below it that will get the real IP address.

function getRemoteIPAddress() {

        $ip = $_SERVER['REMOTE_ADDR'];
        return $ip;

}
function getRealIPAddr(){

	if (!empty($_SERVER['HTTP_CLIENT_IP'])) { 
                //check ip from share internet
		$ip=$_SERVER['HTTP_CLIENT_IP'];
	}elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { 
                //to check ip is pass from proxy
		$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
	}else{
		$ip=$_SERVER['REMOTE_ADDR'];
	}
	return $ip;

}

5. sort()
This function sorts the elements of an array in ascending order. String values will be arranged in alphabetical order. Other sorting functions also exist — asort(), arsort(), ksort(), krsort(), and rsort().

$data = array("g", "t", "a", "s");
sort($data);
print_r($data);
-------
Output:
Array
(
[0] => a
[1] => g
[2] => s
[3] => t
)
Save on DeliciousDigg ThisShare via email
Submit to reddit

The newspaper stand of the future!

Ok so we all know that books will age and disappear making room for the ‘e-reader’ or tablet such as Apple’s IPAD, but what will happen when newspaper stands are no longer needed?

Take a look at this, it shows an interactive application whereby you place your tablet on top, it is instantly recognized and you can shop right there by dragging the image of the magazine right to your own tablet.

\
Save on DeliciousDigg ThisShare via email
Submit to reddit