Skip to content

Instantly share code, notes, and snippets.

Avatar
⚔️
Take that, entropy!

Chris Blakley chrisblakley

⚔️
Take that, entropy!
View GitHub Profile
@chrisblakley
chrisblakley / google-maps-js-api.php
Created Apr 13, 2017
A too in-depth implementation of Google Maps JS API
View google-maps-js-api.php
<script>
jQuery(document).on('ready', function(){
mapInfo = [];
mapActions();
jQuery.getScript('https://www.google.com/jsapi?key=' + nebula.site.options.nebula_google_browser_api_key, function(){
google.load('maps', '3', {
callback: function(){
getAllLocations();
}
@chrisblakley
chrisblakley / once.js
Created Feb 21, 2016
A function that allows other functions to be called only one time per page load.
View once.js
function once(fn, args, unique){
if ( typeof onces === 'undefined' ){
onces = {};
}
if ( typeof fn === 'function' ){ //If the first parameter is a function
if ( typeof args === 'string' ){ //If no parameters
args = [];
unique = args;
}
@chrisblakley
chrisblakley / admin_functions.php
Last active Jun 26, 2018
Business Hours Custom Field Group without ACF
View admin_functions.php
<?php
//Add Open/Closed info to location listing columns
add_filter('manage_edit-location_columns', 'schc_location_hours_columns_head');
function schc_location_hours_columns_head($defaults){
$defaults['openclosed'] = 'Open/Closed';
return $defaults;
}
add_action('manage_location_posts_custom_column', 'schc_location_hours_columns_content', 15, 3);
function schc_location_hours_columns_content($column_name, $id){
if ( $column_name == 'openclosed' ){
@chrisblakley
chrisblakley / active_users_metabox.php
Last active May 13, 2019
Get data about active WordPress users on your site as well as list when they were last online.
View active_users_metabox.php
<?php
/*==========================
This snippet shows how to add an active user count to the WordPress Dashboard.
Copy these contents to functions.php
===========================*/
//Active Users Metabox
add_action('wp_dashboard_setup', 'gearside_activeusers_metabox');
function gearside_activeusers_metabox(){
@chrisblakley
chrisblakley / event-intent-click.js
Last active Nov 7, 2015
Reduce the amount of speculation when making insights in Google Analytics by using context clues to determine the event intent from user interactions. https://gearside.com/event-intent-using-context-clues-determine-user-intention/
View event-intent-click.js
jQuery('a.some-link').on('mousedown tap touch', function(e){
eventIntent = ( e.which >= 2 )? 'Intent' : 'Explicit';
ga('set', 'dimension3', eventIntent);
ga('send', 'event', 'Category', 'Action', 'Label', 'Value');
});
@chrisblakley
chrisblakley / cloudflare-dev-mode.js
Created Oct 3, 2015
This is a more complete Cloudflare admin bar functionality. Can definitely be more optimized, but it gets the idea across.
View cloudflare-dev-mode.js
function cloudflareDevModeToggle(toggle){
if ( !toggle ){
toggle = 'on';
}
jQuery('.devmodeicon').removeClass('fa-bolt fa-medkit').addClass('fa-spin fa-spinner');
jQuery.ajax({
type: "POST",
url: bloginfo["admin_ajax"],
@chrisblakley
chrisblakley / phone_emails.txt
Last active Aug 29, 2015
Mobile phone email addresses. This allows texting to a phone via email. Replace "5551234567" with the actual phone number (with area code).
View phone_emails.txt
AT&T: 5551234567@txt.att.net
Sprint: 5551234567@messaging.sprintpcs.com
T-Mobile: 5551234567@tmomail.net
Verizon: 5551234567@vtext.com
3 River Wireless: 5551234567@sms.3rivers.net
ACS Wireless: 5551234567@paging.acswireless.com
Alltel: 5551234567@message.alltel.com
AT&T: 5551234567@txt.att.net
@chrisblakley
chrisblakley / common_referral_spambots.txt
Last active Nov 6, 2016
Common referral spambots that appear in Google Analytics reports. More information on how to use this list: http://gearside.com/stop-spambots-like-semalt-buttons-website-darodar-others/
View common_referral_spambots.txt
100dollars-seo.com
4webmasters.org
7makemoneyonline.com
aliexpress.com
anticrawler.org
best-seo-offer.com
best-seo-solution.com
bestwebsitesawards.com
blackhatworth.com
buttons-for-website.com
@chrisblakley
chrisblakley / trello_styles.css
Last active Sep 23, 2018
Custom CSS to enchance Trello.
View trello_styles.css
/* Show the move cursor to demonstrate drag/drop scrolling on the interface. */
#board {
cursor: move;
}
#board .list {
cursor: default;
}
/* Change the background to a texture while maintaining board color. */
@chrisblakley
chrisblakley / gearside_sickness_probability.php
Last active Aug 29, 2015
Visualize the probability of you being sick in Google Calendar by generating this .ics file.
View gearside_sickness_probability.php
<?php
// http://gearside.com/calendars/sick.php
$debug = 0; //Enable forced debug mode here
if ( $debug == 0 && !array_key_exists('debug', $_GET) ) {
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: attachment; filename=sickness_probability.ics');
}