Skip to content

Instantly share code, notes, and snippets.

@woutrbe
woutrbe / gist:4a762b3356fc668967f177bcb7fe4f54
Last active October 12, 2017 02:04
Quickly resize and crop images in Node.js
/**
* Make sure you have imagemagich installed on your system
*/
const im = require('imagemagick');
const g = require('glob');
/**
* Find all files with a specific pattern
*
* @param {String} pattern
@woutrbe
woutrbe / gist:e9df9d5eff0222a67765aa8d49dad62f
Created October 19, 2017 08:40
Track outbound links in Google Analytics
(function() {
var links = document.getElementsByTagName('a');
for(var i = 0; i < links.length; i++) {
if(links[i].href.indexOf(location.host) === -1) {
links[i].onclick = function() {
gtag('event', 'click', {
'event_category': 'outbound',
'event_label': this.href
});
}
@woutrbe
woutrbe / gist:3dad6d4c39c78d2956e9ae0a7a309112
Last active December 15, 2023 12:27
Deploy to Google Cloud Bucket from Gitlab CI/CD
build app:
image: node:6
stage: build
artifacts:
paths:
- public
script:
- npm install
- npm run build
# Your next stage won't have access to these files again, so copy it to a public directory
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Typescript",
"skipFiles": ["<node_internals>/**"],
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"sourceMaps": true,