Skip to content

Instantly share code, notes, and snippets.

View chhib's full-sized avatar

David Jurelius chhib

View GitHub Profile
@chhib
chhib / Dockerfile
Created January 10, 2019 18:43
Companion files used in the episode "Trying Kubernetes for the First Time" on the DevTips channel: https://youtu.be/ZSuh_nNPGls
FROM node
EXPOSE 8080
COPY app.js .
CMD node app.js
@chhib
chhib / hacky.js
Created November 20, 2018 13:25
Code from the Query String Parameters video on DevTips
const URL = 'https://www.adlibris.com' +
'/se/bok/factfulness-tio-knep-som-hjalper-dig-forsta-varlden-9789127149946' +
'?filter=hardcover' +
'&gclid=760a19f0-5057-417a-8e6a-b44a01b12a46' +
'&some=thing'
const [first, last] = URL.split("?")
const URLwithoutGCLID = first
URLwithoutGCLID
@chhib
chhib / index.html
Last active August 29, 2018 14:05
Utterly Failing at CSS Animations
<html>
<head>
<style>
html, body {
padding: 0;
margin: 0;
}
body {
background: #D8D8D8;
width: 100%;
@chhib
chhib / dt-regex-basics-2.js
Created June 15, 2018 09:33
Companion Code to DevTips Capture Groups & Alternation
// Classic first/last name switcharoo regex replace example
let firstThenLast = "Zara Larsson"
let getFirstAndLast = /(\w+) (\w+)/
firstThenLast.match(getFirstAndLast) //?
let lastCommaFirst = firstThenLast.replace(getFirstAndLast, "$2, $1") //?
// Capturing parentheses
let message = "MPJ hosts DevTips"
let host = message.match(/(dah?vid|mpj) hosts devtips/i)[1] //?
@chhib
chhib / gtm-kp-snippet.html
Created June 30, 2016 15:14
Keyword Provider with Google Tag Manager
<!-- Roy App Keyword Provider snippet -->
<script>
(function (window) {
window['RoyAppKeywordProviderConfig'] = {
accountId: {{Keyword Provider Account ID}},
mode: 'dataLayer',
dataLayer: {
name: 'dataLayer',
event: 'Provided keyword'
}
@chhib
chhib / customTask.js
Last active October 20, 2017 13:58
Keyword Provider Google Analytics plugin method to override campaign keyword
function () {
return function(model) {
if ({{Provided Keyword}}) {
model.set('campaignKeyword', {{Provided Keyword}});
model.set('campaignContent', {{Provided Position}});
model.set('campaignSource', 'google');
model.set('campaignMedium', 'organic');
model.set('campaignName', 'Roy App Keyword Provider');
}
}
@chhib
chhib / ga-modified-with-require.html
Last active May 26, 2016 09:03
Keyword Provider Google Analytics plugin method for custom dimensions
<!-- Google Analytics Snippet -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-1234-5', 'auto');
// Add this before the send pageview call
chartHandlers = {};
Template.metric.rendered = function () {
var self = this;
self.myDeps = Deps.autorun(function () {
// Get data from db
var calculatedData = Aggregates.find().fetch();
// find the container to put the graph in
var element = self.$('.chart').first();