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 / 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,
@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 / apache-404-php.conf
Last active May 25, 2019 21:46
Fail2Ban: Custom configuration files
# Fail2Ban configuration file
# /etc/fail2ban/filter.d/apache-404-php.conf
#
# Author: Karl Wilbur
#
# Description:
# filter for blocking IPs that generate 'File does not exist'
# entries in Apache's error log, from attempts to access non-existent
# PHP files.
#
@karlwilbur
karlwilbur / Vagrantfile
Last active July 20, 2019 21:32
Vagrant - Set Guest ENV vars
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANT_API_VERSION='2'
$set_environment_variables = <<SCRIPT
cat > '/etc/profile.d/envvars.sh' <<EOV
# AWS environment variables.
export SOME_VAR=things
export OTHER_VAR='other stuff'
@karlwilbur
karlwilbur / barrier.config
Last active June 8, 2021 15:54
Karl's K&R Desktop+ Barrier (Synergy) Configuration
# `~/.barrier.conf`
#
# Configuration for [Barrier](https://github.com/debauchee/barrier) server
#
# Physical arrangement, with machine names as used by Barrier (Synergy).
# +---------------+---------------+
# | | |
# | kandr-imac | kandr-nuc |
# | | |
@karlwilbur
karlwilbur / .sh_nvm
Last active October 8, 2019 02:28
Karl's `zsh` Setup
[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && source "$NVM_DIR/bash_completion" # This loads nvm bash_completion
[ -s "$HOME/.avn/bin/avn.sh" ] && source "$HOME/.avn/bin/avn.sh" # load avn
@karlwilbur
karlwilbur / 20081231235959-example_migration.php
Last active December 18, 2019 15:50
Simple PHP DB Migration script with example migrations
<?php
# db/migrations/20081231235959-example_migration.php
/**
* Example migration. This is just here to serve as a kind of template for creating
* new migrations.
*
* The filename convention is: YYYYMMDDHHIISS-some_class_name.php
*
* The name of the class defined within the migration file should match the what
@karlwilbur
karlwilbur / movie-list.perl
Created December 11, 2019 16:28
A stupid simple dynamic web app written in perl
#!/usr/bin/perl
#use warnings;
use strict;
use CGI qw(:standard);
use DBI;
#=============================
# Database connection
my $host = "localhost";
@karlwilbur
karlwilbur / .aliases
Last active July 27, 2020 16:14
Using CLI, open in GitKraken the repository for the current directory [via Bash or Zsh alias].
alias release-the-kraken='eval "gitkraken --new-window -p \"`pwd`\" -l /dev/null >/dev/null 2>&1 &" &'
@karlwilbur
karlwilbur / keybase.md
Created October 4, 2020 15:41
Keybase Identity Proof

Keybase proof

I hereby claim:

  • I am karlwilbur on github.
  • I am karlwilbur (https://keybase.io/karlwilbur) on keybase.
  • I have a public key ASC_tRwwaNwNO05hh_kvs5LVHtVRTBSSFib3kF8JGynO9Qo

To claim this, I am signing this object: