Skip to content

Instantly share code, notes, and snippets.

View underdown's full-sized avatar

Ryan Underdown underdown

  • Classy Closets
  • Phoenix, AZ
View GitHub Profile
@underdown
underdown / gist:1367825
Created November 15, 2011 18:07
PHP Google Scraping Function
function findranking($domain, $keyword) {
usleep(400000*rand(0,16)); //set random interval between checks
$url="http://www.google.com/search?q=".urlencode($keyword)."&num=100";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER,1); // set to 0 to eliminate header info from response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
$header = array();
$header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
<html>
<head><title>page speed test of background images</title></head>
<body>
<div>&nbsp;<img src="//images.autoglassguru.com/niform.png" /></div>
<div>&nbsp;<img src="//images.autoglassguru.com/insurers2.png" /></div>
<div>&nbsp;<img src="//images.autoglassguru.com/dots2.png" /></div>
<div>&nbsp;<img src="//images.autoglassguru.com/savemoney2.png" /></div>
<div>&nbsp;<img src="//images.autoglassguru.com/ni2.png" /></div>
<div>&nbsp;<img src="//images.autoglassguru.com/niformrcu.jpg" /></div>
</body>
<html>
<head><title>page speed test of background images</title></head>
<body>
<div style="background-image:url(//images.autoglassguru.com/niform.png)">&nbsp;<img /></div>
<div style="background-image:url(//images.autoglassguru.com/insurers2.png)">&nbsp;<img /></div>
<div style="background-image:url(//images.autoglassguru.com/dots2.png)">&nbsp;<img /></div>
<div style="background-image:url(//images.autoglassguru.com/savemoney2.png)">&nbsp;<img /></div>
<div style="background-image:url(//images.autoglassguru.com/ni2.png)">&nbsp;<img /></div>
<div style="background-image:url(//images.autoglassguru.com/niformrcu.jpg)">&nbsp;<img /></div>
</body>
@underdown
underdown / gist:1711750
Last active October 4, 2017 16:47
twilio - analytics call tracking
<?php
//http://www.vdgraaf.info/google-analytics-without-javascript.html
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$var_utmac='UA-45XXXX-1'; //enter the new urchin code
$var_utmhn='domain.com'; //enter your domain
$var_utmn=rand(1000000000,9999999999);//random request number
$var_cookie=rand(10000000,99999999);//random cookie number
@underdown
underdown / robots.txt
Created March 4, 2012 23:20
default robots.txt
User-agent: ia_archiver
Disallow: /
User-agent: dotbot
Disallow: /
User-agent: MJ12bot
Disallow: /
User-agent: AhrefsBot
Disallow: /
@underdown
underdown / noparchive
Created March 4, 2012 23:27
Noarchive meta tag
<meta name="robots" content="noarchive" />
@underdown
underdown / gist:2141718
Created March 20, 2012 21:59
quick & dirty split testing ppc visits
<?php
if($_GET["gclid"]) {
switch(rand(1,3)) {
case 1: header("location: /a/index.php");break;
case 2: header("location: /a/index2.php");break;
case 3: header("location: /a/index3.php");break;
}
}
?>
@underdown
underdown / gist:2141741
Created March 20, 2012 22:03
Split test only new visitors
<?php
setcookie("BTDT", "1", strtotime("+30 days"));
if(!$_COOKIE["BTDT"]) {
if($_GET["gclid"]) {
switch(rand(1,3)) {
case 1: header("location: /a/index.php");break;
case 2: header("location: /a/index2.php");break;
case 3: header("location: /a/index3.php");break;
}
}
<script>
(function(w, d, s) {
function go(){
var js, fjs = d.getElementsByTagName(s)[0], load = function(url, id) {
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.src = url; js.id = id;
fjs.parentNode.insertBefore(js, fjs);
};
load('https://apis.google.com/js/plusone.js', 'gplus1js');
load('https://server.iad.liveperson.net/hc/46830827/?cmd=mTagRepstate&site=46830827&buttonID=12&divID=lpButDivID-1271372870793&bt=1&c=1', 'livechat');
<script type="text/javascript">
$(document).ready(function() {
getAdSize() {
switch(true) {
case($(window).width()>400): $('#gadslot1').html('<sc'+'ript type="text\/javascript">
google_ad_client = "ca-pub-3658299045266116";
google_ad_slot = "4414183254";
google_ad_width = 320;
google_ad_height = 50;
<\/sc'+'ript><sc'+'ript type="text\/javascript" src="http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js"><\/sc'+'ript>');