Skip to content

Instantly share code, notes, and snippets.

View adrianspeyer's full-sized avatar

Adrian Speyer adrianspeyer

View GitHub Profile
@adrianspeyer
adrianspeyer / cookie-consent-example.html
Last active October 8, 2018 02:11
GPDR Opt In to Tracking Google Analytics
@adrianspeyer
adrianspeyer / User Role
Created February 15, 2018 20:50
Add to your theme hook to always have user roles.
public function base_render_before($sender) {
if(!val('UserRoles', $sender->Data)) {
$user = val('User', Gdn::controller());
if (!$user && Gdn::session()->isValid()) {
$user = Gdn::session()->User;
}
$userRoles = [];
if ($user) {
$userID = val('UserID', $user);
$userRolesData = Gdn::userModel()->getRoles($userID);
@adrianspeyer
adrianspeyer / autotrack
Last active November 3, 2020 19:16
Automatic Tracking Of Outbound Links for gtags.js
<head>
<!--Need gtag.js code and jquery already in page -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
@adrianspeyer
adrianspeyer / blockstack proof
Created November 14, 2017 00:24
blockstack proof
Verifying my Blockstack ID is secured with the address 1NNXj6puA2pw8dQyat6wLxs9AN5wvUtmZ8 https://explorer.blockstack.org/address/1NNXj6puA2pw8dQyat6wLxs9AN5wvUtmZ8
@adrianspeyer
adrianspeyer / ghostery_hubspot_message.js
Created January 11, 2017 19:26
How to handle Ghostery blocking your HubSpot forms. This appends a message asking user to add your site to whitelist. Just add it to the footer in any HubSpot COS page.
$(window).load(function () {
if($("[id^='hs_form_target_module']").html() == "") {
$( ".hs_cos_wrapper.form-title" ).append( "<h6>If you are seeing this message you may have Adblock or Ghostery enabled. Please consider whitelisting our site to download the content.</h6>" );
}
});
@adrianspeyer
adrianspeyer / hubspot-character-count-form.js
Last active January 13, 2017 05:13
If you are using the standard Hubspot forms on your landing pages and you need to limit the text area character count to ensure a Salesforce sync, as the limit is 255 characters. Add the following Javascript to your footer.
$(window).load(function() {
$('textarea').keypress(function(){
if(this.value.length > 255){
return false;
}
});
});
@adrianspeyer
adrianspeyer / conditional_vanilla_category
Last active August 29, 2015 14:09
Conditional for Vanilla Forums to Add Search Bar on Index.
<div class="Column ContentColumn" id="Content">
{if $BodyID =='vanilla_categories_index'}
<div class="SearchBox">
<form method="get" action="/search">
<input type="text" id="Form_Search" name="Search" placeholder="{t c="Search"}" class="InputBox js-search">
<input type="submit" id="Form_Go" value="Go" class="Button">
</form>
</div>
{/if}
{asset name="Content"}
@adrianspeyer
adrianspeyer / CSS Fix
Last active August 29, 2015 14:07
CSS Fix for Bootstrap Theme in Vanilla Forums
div.NavBar div.Row div.MeWrap {
margin-top:-10px;
}
div.NavBar {
height:100px !important;
}
div#Frame {
margin-top:80px !important;
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<link href="rotate.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="rotate.js"></script>
<script type="text/javascript">
$(window).load(function() {
startRotator("#rotator");
})
</script>