Skip to content

Instantly share code, notes, and snippets.

View karlwilbur's full-sized avatar
🏠
Working from home

Karl Wilbur karlwilbur

🏠
Working from home
View GitHub Profile
@karlwilbur
karlwilbur / vpndown.sh
Last active May 24, 2019 15:32
Start/stop OpenVPN while tracking PID
#!/bin/bash
PID_FILE=~/run/openvpn.pid
if [ -e $PID_FILE ] && [ -s $PID_FILE ]; then
pid=`cat $PID_FILE`;
if [ ! "$(ps -eF | grep $pid | grep openvpn)" ]; then
echo "It seems that OpenVPN is not running and was not shutdown cleanly, remove the file '$PID_FILE' before attepting to start."
exit 1;
@karlwilbur
karlwilbur / googleapi-example.js
Created November 21, 2018 19:26
Example Google Analytics API Request Using JavaScript/Node.js
import config from './config.js'
import { google } from 'googleapis'
const scopes = ['https://www.googleapis.com/auth/analytics.readonly']
const jwtClient = new google.auth.JWT(config.clientEmail, null, config.privateKey, scopes)
async function doTheThings() {
await jwtClient.authorize()
let response = await google.analytics('v3').data.realtime.get({
'auth': jwtClient,