Skip to content

Instantly share code, notes, and snippets.

View jessehanley's full-sized avatar
🏠
Working from home

Jesse Thomas Hanley jessehanley

🏠
Working from home
View GitHub Profile
@jessehanley
jessehanley / segment.js
Last active July 24, 2023 05:48
Bento Function for Segment
// Learn more about destination functions API at
// https://segment.com/docs/connections/destinations/destination-functions
/**
* Handle track event
* @param {SegmentTrackEvent} event
* @param {FunctionSettings} settings
*/
async function onTrack(event, settings) {
// Learn more at https://segment.com/docs/connections/spec/track/
<form name="bento-identify-form" id="bento-identify-form" data-thank-you-message="Thank you!" data-redirect-url="">
<input type="text" name="email">
<input type="submit" class="btn btn-success">
</form>
@jessehanley
jessehanley / tl_persistent.js
Created April 10, 2019 23:27
Persistent Scroll for Turbolinks
const turbolinksPersistScroll = () => {
const persistScrollDataAttribute = 'turbolinks-persist-scroll'
let scrollPosition = null
let enabled = false
document.addEventListener('turbolinks:before-visit', (event) => {
if (enabled)
scrollPosition = window.scrollY
else
@jessehanley
jessehanley / gist:209ceee4c4848438273d5b88cb991407
Last active June 16, 2017 19:37
Slack Invite: Simple Javascript Form
<!-- Get your token here https://api.slack.com/custom-integrations/legacy-tokens -->
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<input id="email" type="text" placeholder="Email for invite">
<button onclick="sendInvite()">Apply</button>
<script>
function sendInvite() {
<script>
function getAllUrlParams(url) {
// get query string from url (optional) or window
var queryString = url ? url.split('?')[1] : window.location.search.slice(1);
// we'll store the parameters here
var obj = {};
// if query string exists
<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '1387232614654235'); // Insert your pixel ID here.
fbq('track', 'PageView');
</script>
<blockquote dir=ltr itemtype="http://schema.org/Product" itemscope>
<p>98.83% of customers who left a <span itemprop="name">replacement key</span> review recommend example.com</p>
<p itemtype="http://schema.org/AggregateRating" itemscope itemprop="aggregateRating">Average rating <span itemprop="ratingValue">4.9</span> out of <span itemprop="bestRating">5</span> for replacement keys, from <span itemprop="ratingCount">1163</span> reviews left by fastkeys.co.uk customers (as at October, 2015)</p>
</blockquote>
<link rel="prerender" href="http://example.com">
@jessehanley
jessehanley / gist:b2db6636229fd52ee418543b9cdca707
Created September 29, 2016 07:59
YouTube Demo - Form Personalisation
<script src="https://cdnjs.cloudflare.com/ajax/libs/blueimp-md5/1.0.1/js/md5.min.js"></script>
<script>
function validateEmail(email) {
var re = /^[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;
return re.test(email);
}
$('#user_email').on('change keyup keydown', function() {
var email = $(this).val(),
valid = validateEmail(email);
<script async custom-element="amp-analytics"
src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js">
</script>