Skip to content

Instantly share code, notes, and snippets.

@ciaranmahoney
ciaranmahoney / Google Sheets MX Lookup
Last active November 21, 2023 23:09
Google Apps Script to Run MX Lookups on domains from Google Sheets
function MXLookup(domain) {
try {
var url = "https://dns.google.com/resolve?name=%FQDN%&type=MX".replace("%FQDN%",domain);
//var url = "https://dns.google.com/resolve?name=e-mercy.com&type=MX"; // USED FOR TESTING ONLY
Utilities.sleep(100);
var result = UrlFetchApp.fetch(url,{muteHttpExceptions:true});
var rc = result.getResponseCode();
@ciaranmahoney
ciaranmahoney / Extract naked domain from full url
Created August 18, 2016 21:59
Formula for extracting naked domain from full url in Google Sheets.
=iferror(trim(REGEXEXTRACT(REGEXREPLACE(REGEXREPLACE(A2,"https?://",""),"^(w{3}\.)?","")&"/","([^/?]+)")))
@ciaranmahoney
ciaranmahoney / PocketWP Background Image Hack CSS
Last active January 19, 2016 05:41
Add this to your CSS file to replace the grey square with an image of your choice.
p.pwp-featured-image-placeholder {
background: url('http://image-url-here.jpg');
background-size: cover;
background-position: 50% 50%, 50% 50%;
}
@ciaranmahoney
ciaranmahoney / mixpanel-page-linktracking-wordpress.php
Last active March 24, 2017 15:12
This gist inserts MixPanel link click and pageview tracking scripts into a WordPress blog. It is intended to be included in footer.php so it can track pageview and clicks for all pages. In order for this to work, you must have a Mixpanel account and have Mixpanel tags setup on your website.
<!-- MixPanel Link click tracking - track clicks for all links -->
<script type="text/javascript">// <![CDATA[
mixpanel.track_links("a", "Link Click", {
"referrer": document.referrer
});
// ]]>
</script>
<!-- MixPanel Pageview tracking -->
<?php if( is_page()) { // Sets page type to Page for all pages ?>
@ciaranmahoney
ciaranmahoney / show phone number on click
Last active March 9, 2018 10:28
Click to Show Full Phone Numer - Jquery
<span id="clickToShow">xxx-xxx-xxxx</span>
<script>
var shortNumber = $("#clickToShow").text().substring(0, $("#clickToShow").text().length - 5);
var onClickInfo = "_gaq.push(['_trackEvent', 'EVENT-CATEGORY', 'EVENT-ACTION', 'EVENT-LABEL', VALUE, NON-INTERACTION]);";
$("#clickToShow").hide().after('<button id="clickToShowButton" onClick="' + onClickInfo + '">' + shortNumber + '... (click for full phone number)</button>');
$("#clickToShowButton").click(function() {
$("#clickToShow").show();
$("#clickToShowButton").hide();
});
</script>
@ciaranmahoney
ciaranmahoney / gforms-aus-address
Last active August 29, 2015 14:03
Adding Australian specific address fields to Gravity forms
add_filter("gform_address_types", "aus_address", 10, 2);
function aus_address($address_types, $form_id)
{
$address_types["australia"] = array(
"label" => "Australia",
"country" => "Australia",
"zip_label" => "Postcode",
"state_label" => "State",
"states" => array("NT" => "NT", "ACT" => "ACT", "NSW" => "NSW", "QLD" => "QLD", "VIC" => "VIC", "WA" => "WA", "SA" => "SA", "TAS" => "TAS")
);