Skip to content

Instantly share code, notes, and snippets.

View phillipadsmith's full-sized avatar

Phillip Smith phillipadsmith

View GitHub Profile
@phillipadsmith
phillipadsmith / abstract-tracking.js
Created February 28, 2020 18:45
abstract-tracking.js
var adCampaignPicoHandler = function(){
var REGISTERED_EVENT_CAPTURED = "ad-reg-event-captured";
var PAID_EVENT_CAPTURED = "ad-paid-event-captured";
function setCookie(name,value,days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days*24*60*60*1000));
expires = "; expires=" + date.toUTCString();
}
@phillipadsmith
phillipadsmith / download_user_data_from_slack.js
Created November 13, 2019 18:41
Quick and dirty client-side script to download names and titles from a Slack channel
// In the Web UI for Slack, navigate to a channel, click on "See All Members"
// and then scroll until you've hit the end of the list
// Open your browser's console and run this
var NameAndTitles = document.getElementsByClassName('c-base_entity__text-contents')
var NamesData = [];
for (var i=0; i < NameAndTitles.length; i++) {
var title = NameAndTitles[i].getElementsByClassName('c-member__title')[0];
@phillipadsmith
phillipadsmith / .htaccess
Created November 19, 2015 19:46
Example .htaccess for prerender.io
<IfModule mod_headers.c>
#RequestHeader set X-Prerender-Token "YOUR_TOKEN"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
<IfModule mod_proxy_http.c>
RewriteCond %{HTTP_USER_AGENT} baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator [NC,OR]
<?php $args = array(
'numberposts' => -1,
'offset' => 0,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'custom_post_type_here',
'post_status' => 'draft',
'meta_query' => array(
array(
'key' => 'custom_field_key_name',
if ($_SERVER['REMOTE_ADDR']=='127.0.0.1') {
define('WP_ENV', 'local');
} elseif ($_SERVER['HTTP_HOST']=='develop.project.com') {
define('WP_ENV', 'develop');
} elseif ($_SERVER['HTTP_HOST']=='master.project.com') {
define('WP_ENV', 'develop');
} else {
define('WP_ENV', 'production');
}
@phillipadsmith
phillipadsmith / gist:4126431
Created November 21, 2012 17:47
A hack that let's the Wordpress JSON-API plug-in play nicely with Co-authors Plus
diff --git a/wp-content/plugins/json-api/models/post.php b/wp-content/plugins/json-api/models/post.php
index 4a8c492..c5b28cb 100644
--- a/wp-content/plugins/json-api/models/post.php
+++ b/wp-content/plugins/json-api/models/post.php
@@ -18,7 +18,6 @@ class JSON_API_Post {
var $modified; // String (modified by date_format query var)
var $categories; // Array of objects
var $tags; // Array of objects
- var $author; // Object
var $comments; // Array of objects
@phillipadsmith
phillipadsmith / gist:2714986
Last active August 4, 2016 05:55
Meta tag example from The Tyee, following the boilerplate posted earlier.
<meta name="bricolage-log" content="1" />
<meta name="robots" content="noindex, nofollow" />
<meta name="generator" content="Bricolage 2.1.0" />
<meta name="bricolage-id" content="57988" />
<meta name="bricolage-uuid" content="5C333394-9E45-11E1-9FD5-92BA81F25826" />
<meta name="bricolage-title" content="The Future of Education Is Here..." />
<meta name="bricolage-enable-comments" content="1" />
<meta name="bricolage-days-comments" content="5" />
<meta name="bricolage-publish-date" content="2012-05-16 00:10:00.000000" />
<!-- General properties -->
@phillipadsmith
phillipadsmith / chartbeat.html
Last active July 14, 2016 22:31
Chartbeat weirdness
<script type='text/javascript'>
var _sf_async_config = _sf_async_config || {};
/** CONFIGURATION START **/
_sf_async_config.uid = #####; //CHANGE THIS
_sf_async_config.domain = 'YourDomain.com'; //CHANGE THIS
_sf_async_config.useCanonical = true;
_sf_async_config.sections = 'Change this to your Section name'; //CHANGE THIS
_sf_async_config.authors = 'Change this to your Author name'; //CHANGE THIS
/** CONFIGURATION END **/
(function() {
@phillipadsmith
phillipadsmith / geocoder-british-columbia.pl
Created August 29, 2012 20:52
Example of using Google Maps geocoder and the Represent API to return a provincial riding name based on a partial address string
#!/usr/bin/perl
use strict;
use warnings;
use v5.14.2;
use Google::GeoCoder::Smart;
use LWP::Simple;
use JSON;
use Data::Dump qw(dump);
@phillipadsmith
phillipadsmith / gist:3124464
Created July 16, 2012 19:16
Invite all friends on FB to an event
javascript:var x=document.getElementsByTagName("input");for(var i=0;i<x.length;i++) {if (x[i].type == 'checkbox') {x[i].click();}}; alert('Done, all your friends have been selected');