Skip to content

Instantly share code, notes, and snippets.

View rafasashi's full-sized avatar
👍
Happy

Raphaël Dartigues rafasashi

👍
Happy
View GitHub Profile

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta name="keywords" content="your, tags"/>
<meta name="description" content="150 words"/>
<meta name="subject" content="your website's subject">
<meta name="copyright"content="company name">
<meta name="language" content="ES">
<?php
$link=mysql_pconnect($db['write']['host'],$db['write']['user'],$db['write']['pass']) or die ("Could not connect to datadase");
mysql_select_db($db['write']['name']) or die ("could not select database");
//patharray is an essentially an exploded $_SERVER['REQUEST_URI']
//for articles rss feeds it would be /rss/articles/categoryname
//so $patharray[0]='rss', $patharray[1]='articles' and $patharray[2]='categoryname'
const('SITENAME','Example.com');
const('WEBMASTER','[email protected] ([email protected])');

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

<?php
function custom_strlen($str=''){
$strlen=0;
if(is_string($str)){
if(function_exists('mb_strlen')){
$strlen= mb_strlen($str);
}
else{
$strlen= strlen($str);
function count_char($str='',$char=''){
$count=0;
if(function_exists('mb_substr_count')){
$count=mb_substr_count($str,$char);
}
else{
$count=substr_count($str,$char);
}
return $count;
}
function custom_trim($str,$trim=''){
if($trim==''){
$str=trim($str);
}
if($trim==' '){
$str=preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $str);
}
else{
$str=custom_ltrim($str,$trim);
$str=custom_rtrim($str,$trim);
function custom_substr($content='',$pos_start=0,$num_char=1){
$substr='';
if(function_exists('mb_substr')){
$substr=mb_substr($content,$pos_start,$num_char,CHARSET);
}
else{
$substr=substr($content,$pos_start,$num_char);
}
return $substr;
}
function custom_str_case($string='', $case='lower'){
$lower = array(
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u",
"v", "w", "x", "y", "z", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï",
"ð", "ñ", "ò", "ó", "ô", "õ", "ö", "ø", "ù", "ú", "û", "ü", "ý", "а", "б", "в", "г", "д", "е", "ё", "ж",
"з", "и", "й", "к", "л", "м", "н", "о", "п", "р", "с", "т", "у", "ф", "х", "ц", "ч", "ш", "щ", "ъ", "ы",
"ь", "э", "ю", "я"
);
$upper = array(
function custom_strpos($strpos_in='',$strpos_of=''){
$result=false;
if($strpos_of!=''){
$result=strpos($strpos_in,$strpos_of);
}
return $result;
}
@rafasashi
rafasashi / custom_ftok.php
Created April 27, 2015 09:30
custom ftok function for windows
function custom_ftok($pathname='', $proj=''){
$ftok=false;
if(function_exists('ftok')){
$ftok = ftok($pathname, $proj);
}
else{