Skip to content

Instantly share code, notes, and snippets.

View tolu's full-sized avatar

Tobias Lundin tolu

  • Elate
  • Oslo, Norway
View GitHub Profile
@tolu
tolu / wsl-puppeteer.js
Last active January 28, 2022 14:20
Puppeteer on WSL
// resource: http://ktkr3d.github.io/2020/01/27/Puppeteer-on-WSL/
// install puppeteer
// > npm i -g puppeteer
// use chrome from windows: add this to ~/.profile
// PATH=/mnt/c/Program\ Files\ \(x86\)/Google/Chrome/Application:$PATH
const puppeteer = require('puppeteer');
@tolu
tolu / express-puppeteer-server.ts
Created February 18, 2021 22:03
SPA meta-tag renderer (for fb bots etc)
import express from 'express';
import puppeteer from 'puppeteer';
import ua from 'useragent';
const isBot = (agent: ua.Details) => {
return !agent.webkit && !agent.opera && !agent.ie &&
!agent.chrome && !agent.safari && !agent.mobile_safari &&
!agent.firefox && !agent.mozilla && !agent.android;
}
@tolu
tolu / Dockerfile
Created November 14, 2022 21:21
Docker nginx static web server
FROM node:lts-alpine as BUILD
WORKDIR /app
# Copy files needed for install
COPY .npmrc ./
COPY *.json ./
# Install deps
RUN npm ci --ignore-scripts
@tolu
tolu / remove-old-branches.sh
Created October 17, 2024 19:12
Remove git branches older than x
#!/bin/bash
# Function to get the cutoff date
get_cutoff_date() {
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
date -v-12m +%s
else
# Linux and others
date -d "12 months ago" +%s