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:2474608
Created April 23, 2012 23:37
responsive ads
<script type="text/javascript"><!--
google_ad_client = "ca-pub-3658299045266116";
/* top */
if ($(window).width()<728 ){
google_ad_slot = "4414183254";
google_ad_width = 320;
google_ad_height = 50;
}else{
google_ad_slot = "1020377061";
google_ad_width = 728;
@underdown
underdown / facebook-email-subscribe.php
Created May 1, 2012 18:06
facebook email subscribe
<div style="width:322;background-color:#efefef;border-left:1px solid #ccc;border-right:1 px solid #ccc;border-top:1px solid #ccc;padding-bottom:6px;padding-top:6px;padding-left:6px;text-align:center;font-weight:bold">Subscribe to Our Newsletter</div>
<div id="fb-root"></div>
<script src="https://connect.facebook.net/en_US/all.js#appId=116486985128746&xfbml=1"></script>
<fb:registration
fields="name,email"
redirect-uri="http://web-op.com/fblogin.php"
width="330">
</fb:registration>
@underdown
underdown / gist:2570159
Created May 1, 2012 18:10
facebook login flow
<?php
define('FACEBOOK_APP_ID', 'xxxxxxxxxxxxxxx');
define('FACEBOOK_SECRET', 'xxxxxxxxxxxxxxxxxxxxxxxx');
function parse_signed_request($signed_request, $secret) {
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
// decode the data
$sig = base64_url_decode($encoded_sig);
$data = json_decode(base64_url_decode($payload), true);
@underdown
underdown / gist:2907596
Created June 10, 2012 22:58
Set Cookie On Like/unlike (FBML)
<script>
function SetCookie(cookieName,cookieValue,nDays) {
var today = new Date();
var expire = new Date();
if (nDays==null || nDays==0) nDays=1;
expire.setTime(today.getTime() + 3600000*24*nDays);
document.cookie = cookieName+"="+escape(cookieValue)
+ ";expires="+expire.toGMTString();
};
FB.Event.subscribe('edge.create', function(response) {
@underdown
underdown / measurePageloadTimes.js
Created June 12, 2012 01:23 — forked from tmahesh/measurePageloadTimes.js
How fast is my site? integrate boomerang and google analytics
<script type="text/javascript">
BOOMR.init({
beacon_url: "/boomerang.gif",
BW: {
enabled: false
}
});
BOOMR.subscribe('before_beacon', trackInAnalytics);
var pageTitle = document.title; // customize this
@underdown
underdown / graphite-installation-ubuntu-11.04.rm
Created June 18, 2012 17:05
Graphite 0.9.10 on Ubuntu 11.10
########################################################################################
# adapted from http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/ #
########################################################################################
sudo apt-get update
sudo apt-get upgrade
wget http://launchpad.net/graphite/0.9/0.9.10/+download/graphite-web-0.9.10.tar.gz
wget http://launchpad.net/graphite/0.9/0.9.10/+download/carbon-0.9.10.tar.gz
@underdown
underdown / gist:3183328
Created July 26, 2012 17:26
Google Analytics - Adjusted Bounce Rate
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-1']);
_gaq.push(['_trackPageview']);
setTimeout("_gaq.push(['_trackEvent', '15_seconds', 'read'])",15000);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
@underdown
underdown / gist:3860141
Created October 9, 2012 17:16
Adwords - Simple split testing - redirect keeping auto-tagging in place for Analytics
<?php
/* bypass special offers for past visitors
must ad ?remark=x to ads' destination url */
if($_GET["remark"]) {
}else{
/* check to see if adwords sent visit */
if($_GET["gclid"]) {
@underdown
underdown / gist:3861198
Created October 9, 2012 20:23
Get Client IP Address
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else if (isset($_SERVER['REMOTE_ADDR'])) {
$ip_address = $_SERVER['REMOTE_ADDR'];
} else if (isset($_SERVER['HTTP_CLIENT_IP'])) {
$ip_address = $_SERVER['HTTP_CLIENT_IP'];
} else {
$ip_address = '';
}
@underdown
underdown / htaccess-template
Created October 23, 2012 18:04
Default htaccess
Options +FollowSymLinks
ServerSignature Off
IndexIgnore *
RewriteEngine on
RewriteRule (.*)php/$ /$1php [R=301,L]
RewriteCond %{HTTP_HOST} ^www.domain.com