This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
setlocale(LC_ALL, 'en_US.UTF8'); | |
function slugit($str, $replace=array(), $delimiter='-') { | |
if ( !empty($replace) ) { | |
$str = str_replace((array)$replace, ' ', $str); | |
} | |
$clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str); | |
$clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $clean); | |
$clean = strtolower(trim($clean, '-')); | |
$clean = preg_replace("/[\/_|+ -]+/", $delimiter, $clean); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Rewrite WordPress URLs to match Blogger permalinks exactly. | |
* | |
* This script is intended for one time use only after importing Blogger | |
* content into WordPress and should be removed from the server immediately | |
* after the script has run one time. It shouldn't be needed again after the | |
* initial rewrite. | |
* | |
* @version 0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$bin = $_POST['bin']; | |
$length = $_POST['length']; | |
if ( $length == 0 ) | |
$length = 16; | |
if ( $bin != '' ) | |
$cardNumber = completed_number( $bin, $length ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This is PHP function to convert a user-supplied URL to just the domain name, | |
// which I use as the link text. | |
// Remember you still need to use htmlspecialchars() or similar to escape the | |
// result. | |
function url_to_domain($url) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I took my chance to provide full .htaccess code to pass on Google PageSpeed Insight: | |
1. Enable compression | |
2. Leverage browser caching | |
# Enable Compression | |
<IfModule mod_deflate.c> | |
AddOutputFilterByType DEFLATE application/javascript | |
AddOutputFilterByType DEFLATE application/rss+xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function parseTitle($html) { | |
// Get the text in a <title> | |
$matches = array(); | |
preg_match("/<title>(.*)<\/title>/is", $html, $matches); | |
if (count($matches) > 1) { | |
return trim($matches[1]); | |
} else { | |
return null; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@media (min-width:320px) { /* smartphones, iPhone, portrait 480x320 phones */ } | |
@media (min-width:481px) { /* portrait e-readers (Nook/Kindle), smaller tablets @ 600 or @ 640 wide. */ } | |
@media (min-width:641px) { /* portrait tablets, portrait iPad, landscape e-readers, landscape 800x480 or 854x480 phones */ } | |
@media (min-width:961px) { /* tablet, landscape iPad, lo-res laptops ands desktops */ } | |
@media (min-width:1025px) { /* big landscape tablets, laptops, and desktops */ } | |
@media (min-width:1281px) { /* hi-res laptops and desktops */ } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.htaccess flag list | |
C (chained with next rule) | |
CO=cookie (set specified cookie) | |
E=var:value (set environment variable var to value) | |
F (forbidden - sends a 403 header to the user) | |
G (gone - no longer exists) | |
H=handler (set handler) | |
L (last - stop processing rules) | |
Last rule: instructs the server to stop rewriting after the preceding directive is processed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var linkList = [ | |
"https://google.com", | |
"https://yahoo.com", | |
"https://facebook.com", | |
"https://twitter.com", | |
"https://ebay.com", | |
"https://youtube.com" | |
]; | |
var randomLink = linkList[Math.floor(Math.random()*linkList.length)]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function AdblockDetector(){ | |
} | |
AdblockDetector.prototype.run = function() { | |
var ad = document.querySelector("ins.adsbygoogle"); | |
if(ad && ad.innerHTML.replace(/\s/g, "").length == 0) { | |
//Adblock detected | |
if(typeof ga !== 'undefined') { | |
ga('send', 'event', 'AdBlock', 'True', {'nonInteraction': 1}); //event hit will not be used in bounce-rate calculation. | |
}else if(typeof _gaq !== 'undefined') { | |
_gaq.push(['_trackEvent', 'Adblock', 'True', undefined, undefined, true]); //event hit will not be used in bounce-rate calculation. |
OlderNewer