Skip to content

Instantly share code, notes, and snippets.

View chrisblakley's full-sized avatar
⚔️
Take that, entropy!

Chris Blakley chrisblakley

⚔️
Take that, entropy!
View GitHub Profile
@chrisblakley
chrisblakley / event-intent-click.js
Last active November 7, 2015 18:01
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/
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');
});
<noscript>
<iframe class="hidden" src="includes/no-js.php?h=HOME_URL&amp;p=PAGE_URI&amp;t=PAGE_TITLE" width="0" height="0" style="display:none;position:absolute;"></iframe>
</noscript>
<!-- Notes: Use server-side scripting to fill in the HOME_URL, CURRENT_PAGE_URI, and PAGE_TITLE. Be sure to encode the page title to avoid spaces! If you are using Wordpress, you can use the following snippet: -->
<noscript>
<iframe class="hidden" src="<?php echo get_template_directory_uri(); ?>/includes/no-js.php?h=<?php echo home_url('/'); ?>&amp;p=<?php echo get_page_uri(); ?>&amp;t=<?php urlencode(get_the_title()); ?>" width="0" height="0" style="display:none;position:absolute;"></iframe>
</noscript>
@chrisblakley
chrisblakley / cloudflare-dev-mode.js
Created October 3, 2015 02:16
This is a more complete Cloudflare admin bar functionality. Can definitely be more optimized, but it gets the idea across.
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 August 29, 2015 14:18
Mobile phone email addresses. This allows texting to a phone via email. Replace "5551234567" with the actual phone number (with area code).
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 / gearside_sickness_probability.php
Last active August 29, 2015 14:16
Visualize the probability of you being sick in Google Calendar by generating this .ics file.
<?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');
}
@chrisblakley
chrisblakley / gearside_url_components.php
Last active August 29, 2015 14:15
Easily pull the segment of a URL without constantly re-writing code. Documentation here: http://gearside.com/php-function-easily-return-url-components/
//Get the full URL. Not intended for secure use ($_SERVER var can be manipulated by client/server).
function gearside_requested_url($host="HTTP_HOST") { //Can use "SERVER_NAME" as an alternative to "HTTP_HOST".
$protocol = ( (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443 ) ? 'https' : 'http';
$full_url = $protocol . '://' . $_SERVER["$host"] . $_SERVER["REQUEST_URI"];
return $full_url;
}
//Separate a URL into it's components.
//See http://gearside.com/php-function-easily-return-url-components/ for documentation
@chrisblakley
chrisblakley / ooyala-bootstrap-modal.html
Last active August 29, 2015 14:12
Ooyala Player using Gumby and Bootstrap Modals. With Gumby, you're going to be fighting some default styles, so you'll want to use !important tags on the .video class for padding-bottom and height.
<style>
/* Responsive Ooyala Player */
.ooyalacon {position: relative; width: 100%; padding: 56.25% 0 0 0;} /* 56.25% = 16:9 ratio */
.ooyalacon .innerWrapper {position: absolute !important; top: 0; left: 0; width: 100%; height: 100%;}
.ooyalacon .video {position: absolute; top: 0; padding-bottom: 0 !important; height: 100% !important;}
</style>
<script src='http://player.ooyala.com/v3/MzZiMzc1ZDUzZGVlYmMxNzA3Y2MzNjBk'></script> <!-- Branding ID here -->
<script>
@chrisblakley
chrisblakley / .htaccess
Last active August 29, 2015 14:12
Spambot prevention snippets using .htaccess and PHP
SetEnvIfNoCase Referer semalt.com spambot=yes
SetEnvIfNoCase Referer econom.com spambot=yes
SetEnvIfNoCase Referer buttons-for-website.com spambot=yes
SetEnvIfNoCase Referer ilovevitaly.com spambot=yes
SetEnvIfNoCase Referer ilovevitaly.ru spambot=yes
SetEnvIfNoCase Referer darodar.com spambot=yes
SetEnvIfNoCase Referer 7makemoneyonline.com spambot=yes
SetEnvIfNoCase Referer myftpupload.com spambot=yes
SetEnvIfNoCase Referer priceg.com spambot=yes
Order allow,deny
@chrisblakley
chrisblakley / adblock_detect.html
Last active August 29, 2015 14:10
Detect if users are blocking your ads using jQuery
<style>
.hidden {display: none;} /* Just for reference. This should be in your stylesheet! */
</style>
<div class="extra_resources">
<!-- [AD_CODE_HERE] -->
</div>
<a class="blockdetection hidden" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=VALMBPW4PWH8S" target="_blank"><img src="donate_image.png" alt="Donate via Paypal" /></a>
@chrisblakley
chrisblakley / shortcode1.php
Last active August 29, 2015 14:09
Example shortcode function
add_shortcode('yolo', 'gearside_yolo_shortcode');
function gearside_yolo_shortcode(){
//Code will go here...
}