View udfs.sql
create or replace function dataset.array_int_least(x array<int64>) as | |
((select min(y) from unnest(x) as y)); | |
create or replace function dataset.array_int_greatest(x array<int64>) as | |
((select max(y) from unnest(x) as y)); | |
create or replace function dataset.array_timestamp_least(x array<timestamp>) as | |
((select min(y) from unnest(x) as y)); | |
create or replace function dataset.array_timestamp_greatest(x array<timestamp>) as |
View delete-likes.js
// run in console at twitter.com/username/likes (replace username with your username) | |
(function(document,window) { | |
function clearlikes(){ | |
window.scrollTo(0,document.body.scrollHeight); | |
Array.from(document.querySelectorAll('[data-testid="unlike"]')).forEach(function(el){ | |
el.click(); | |
}) | |
setTimeout(clearlikes, 5000); | |
} | |
clearlikes(); |
View gtm-utilities.js
function(){ | |
"use strict"; | |
/** | |
* Constants | |
*/ | |
var VERSION = '2.1'; |
View code.js
function buildQueryParams(params){ | |
return Object.keys(params).map(function(key) { | |
return encodeURIComponent(key) + '=' + encodeURIComponent(params[key]); | |
}).join('&'); | |
} |
View regex-reference.txt
www.domain.com | ^www\.resmed\.com$ | |
www.domain.com | ^www\d?\.resmed\.com$ | |
www3.domain.com | | |
www.domain.com | ^(www\d?\.)?resmed\.com$ | |
www3.domain.com | | |
domain.com | |
View patterns
Extract domain from string (with or without protocol) | |
[?:http(s)?:\/\/]?([a-z0-9\-]+\.?[a-z0-9\-]+\.[a-z]{2,3}) |
View json-ld-gtm.html
<script> | |
(function(){ | |
var data = { | |
"@context": "http://schema.org", | |
"@type": "BlogPosting", | |
"mainEntityOfPage": { | |
"@type": "WebPage", | |
"@id": {{Page URL}} | |
}, | |
"headline": {{SCHEMA - Article Headline}}, |
View detect-mobile.js
/** | |
* Simple regex/user agent mobile checker | |
* about 99% accurate when compared to 175k sessions in GA | |
*/ | |
function isMobile() | |
{ | |
return window.navigator.match(/Mobi|Touch|Opera\ Mini|Android/) | |
} |
View find-overflow.js
var docWidth = document.documentElement.offsetWidth; | |
[].forEach.call( | |
document.querySelectorAll('*'), | |
function(el) { | |
if (el.offsetWidth > docWidth) { | |
console.log(el); | |
} | |
} | |
); |
View Useful Utility Functions
function getUrlParam(url, param) { | |
var match = url.match('(?:\\?|&)' + param + '=([^&#]*)'); | |
return (match && match.length == 2) ? decodeURIComponent(match[1]) : ''; | |
} |
NewerOlder