JavaScript: Convert String to Integer (int)

To convert strings (text) to integer (number) in JavaScript use the parseInt function.

For example:

document.write(parseInt("23 years"));

Will return the number 23, the function ignores the string “years” and return the integer 23 only.

Another common example is:





 

If you enter 4 and 5, the script will return “45”  instead of 9.  To fix use the parseInt function as follows:






 

 

PHP: Check If Two Strings Are Similar

In php, to check the similarity between to strings (text) use the similar_text for example:

Here’s a PHP function that’ll help you check if two strings (texts) are similar. If the strings are 50% similar then the function will output “Duplicate Entries”.

 0) {
	if (count($result)>(count($array1)/2)){
		echo "Duplicate Entries";
	};

};
}

issimilar ( "Hello World Foo Bar Baz", "Hello Foo Bar Baz");

?>

Regular Expressions: Remove Links Hashes & Mentions from Tweet

Use this regular expresion to remove URLs (http://…) hashes (#ahash) and mentions (@amention) from Tweets or any other block of text for that matter.

For PHP code use:

/(@|#|http\:\/\/)([a-zA-z0-9\.\/])+/

 

For JavaScript:

^(@|#|http\:\/\/)([a-zA-z0-9\.\/])+$

 

 

Text Effects Using CSS

► CSS Text Gradients


 

► Create a Letterpress Effect with CSS Text-Shadow

 

 

► Text Embossing Technique With CSS

 

► CSS Gradient / Glossy Text Effect

 

► Add grunge effect to text using simple CSS

 

► Text-Shadow Exposed: Make cool and clever text effects with css text-shadow 

 

 

► CSS Text-Shadow in Safari, Opera, Firefox and more

 

► CSS Drop Shadows 

 

 

► How To Use Any Font You Wish With FLIR

 

► Two simple ways to create text embossing effect

 

 

► Using CSS Text-Shadow to Create Cool Text Effects

JSON: Tweets from Multiple Twitter Users

Use the following JSON URL to access tweets from multiple twitter users. Of course, you can parse this JSON response using JQuery, PHP or any other language to display these tweets however you want.

http://search.twitter.com/search.json?q=from%3acnnbrk+OR+from%3anpratc+OR+from%3bbc+OR+from%3abc

PHP: Get Folder Size & File Count

Here is a little PHP code you can use to get the size and file count of an entire directory including sub-directories

$filename){
  if($filename!=".." && $filename!="."){
   if(is_dir($dir."/".$filename)){
    $new_foldersize = foldersize($dir."/".$filename);
    $count_size = $count_size + $new_foldersize[0];
    $count = $count + $new_foldersize[1];
   }else if(is_file($dir."/".$filename)){
    $count_size = $count_size + filesize($dir."/".$filename);
    $count++;
   }
  }
  
 }
 
 return array($count_size,$count);
}

$sample = foldersize("SAMPLE_DIRECTORY");

echo "Folder Size : " . $sample[0] . " Bytes 
" ; echo "File Count : " . $sample[1] . " Files " ; ?>

The Five Marketing Environments – An Example

When planning a marketing campaign marketers have to take into account the changes in the marketing environment, including the competitive, social-cultural, technological, economic and political-legal environments. Here is an example of the changes that happen in these environments and their effect on Anheuser-Busch’s Budweiser marketing strategy.