Skip to content

Instantly share code, notes, and snippets.

View boffey's full-sized avatar

Michael Boffey boffey

View GitHub Profile
@boffey
boffey / FacebookLikeTracking.js
Created January 30, 2013 10:14
Facebook Like Tracking
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : 'YOURAPPID', // App ID from the App Dashboard
channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File for x-domain communication
status : true, // check the login status upon init?
cookie : true, // set sessions cookies to allow your server to access the session?
xfbml : true // parse XFBML tags on this page?
});
@boffey
boffey / TwitterTracking.js
Created January 30, 2013 10:17
Twitter Tracking JS
window.twttr = (function (d,s,id) {
var t, js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return; js=d.createElement(s); js.id=id;
js.src="//platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js, fjs);
return window.twttr || (t = { _e: [], ready: function(f){ t._e.push(f) } });
}(document, "script", "twitter-wjs"));
twttr.ready(function (twttr) {
twttr.events.bind('tweet', function(event) {
// Track Twitter
/* change data-onsuccess="linkedInShare" to data-onsuccess="yourFunction" */
<script src="//platform.linkedin.com/in.js" type="text/javascript"></script>
<script type="IN/Share" data-counter="right" data-onsuccess="linkedInShare"></script>
<script>
function linkedInShare() {
// Track Linked In
}
</script>
@boffey
boffey / GooglePlusTracking.html
Last active December 11, 2015 22:49
Google + Tracking
// Change googlePlusShare to your function name
<div class="g-plusone" data-callback="googlePlusShare"></div>
<!-- Place this tag after the last +1 button tag. -->
<script type="text/javascript">
window.___gcfg = {lang: 'en-GB'};
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
@boffey
boffey / paramterize.php
Created January 21, 2014 13:34
Conversion of Rails parameterize function in php
function parameterize($string, $sep = '-') {
# Get rid of anything thats not a valid letter, number, dash and underscore and
# replace with a dash
$paramterized_string = preg_replace("/[^a-z0-9\-_]/i", $sep, $string);
# Remove connected dahses so we don't end up with -- anyhwere.
$paramterized_string = preg_replace("/$sep{2,}/", $sep, $paramterized_string);
# Remove any trailing spaces from the string
@boffey
boffey / prevent-roboto.js
Last active October 1, 2022 12:01
Prevent Google Maps from loading the Roboto font.
var head = document.getElementsByTagName('head')[0];
// Save the original method
var insertBefore = head.insertBefore;
// Replace it!
head.insertBefore = function (newElement, referenceElement) {
if (newElement.href && newElement.href.indexOf('https://fonts.googleapis.com/css?family=Roboto') === 0) {
return;