Instantly share code, notes, and snippets.

View ISO-timezone-with-offset.js
function() {
// Get local time as ISO string with offset at the end
var now = new Date();
var tzo = -now.getTimezoneOffset();
var dif = tzo >= 0 ? '+' : '-';
var pad = function(num) {
var norm = Math.abs(Math.floor(num));
return (norm < 10 ? '0' : '') + norm;
};
return now.getFullYear()
View random-ID.js
function() {
return new Date().getTime() + '.' + Math.random().toString(36).substring(10);
}
// node.js
function() {
return new Date().now() + '.' + Math.random().toString(36).substring(5);
}
View gtag.js
<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments)};
gtag('js', new Date());
gtag('config', 'GA_TRACKING_ID');
</script>