Skip to content

Instantly share code, notes, and snippets.

@mousetree
mousetree / build.py
Created October 15, 2020 19:58
Prefect CI Build Example
import uuid
from os import environ, path
import docker
from prefect.environments import KubernetesJobEnvironment
from prefect.environments.storage import Docker
from sable_batch.flows import (
flow1,
flow2,
@mousetree
mousetree / config.yml
Created July 12, 2018 09:57
Multi environment CircleCI build
version: 2
jobs:
test:
docker:
- image: circleci/node:10
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
@mousetree
mousetree / index.js
Created July 11, 2018 09:15
Node.js server showing environment variables
const express = require('express')
const app = express()
/*
For the purpose of making the testing easier, we've just put this
in a seperate file.
*/
const myLib = require('./lib')
const commitRef = process.env.APP_COMMIT_REF || 'N/A'
@mousetree
mousetree / k8s.yml
Created July 10, 2018 17:21
Kubernetes deployment and service config (no templating)
kind: Service
apiVersion: v1
metadata:
name: my-app
spec:
selector:
app: my-app
ports:
- protocol: TCP
port: 80
@mousetree
mousetree / k8s.yml
Created July 10, 2018 17:00
Kubernetes deployment and service template
kind: Service
apiVersion: v1
metadata:
name: ${PROJECT_NAME}
spec:
selector:
app: ${PROJECT_NAME}
ports:
- protocol: TCP
port: 80
@mousetree
mousetree / Dockerfile
Last active July 11, 2018 09:39
Dockerfile with build number as env var
FROM node:10
ARG COMMIT_REF
ARG BUILD_DATE
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
@mousetree
mousetree / config.yml
Created July 10, 2018 16:18
CircleCI v2.0 config for deployment to Google Kubernetes Engine (GKE)
version: 2
jobs:
build_and_test:
docker:
- image: circleci/node:10
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
@mousetree
mousetree / config.yml
Created July 10, 2018 13:22
CircleCI Config
version: 2
jobs:
test:
docker:
- image: circleci/node:10
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
@mousetree
mousetree / Dockerfile
Created July 10, 2018 13:22
Node.js Dockerfile (Basic)
FROM node:10
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
@mousetree
mousetree / analytics.js
Created March 7, 2018 10:14
Tracking page views in an SPA with Adobe Analytics
/**
* Tracks a page view with Adobe Analytics
* @param {string} pageName The name of the page
*/
export function trackPageView(pageName) {
window.digitalData = {
event: {
eventInfo: [],
},
button: [],