Skip to content

Instantly share code, notes, and snippets.

View dccampbell's full-sized avatar

David C. Campbell dccampbell

View GitHub Profile
@dccampbell
dccampbell / GoogleOauthWalkthrough.sh
Last active July 11, 2021 23:58
Google OAuth 2.0 Walkthrough Script - script to help step through getting an access token for Google API calls (w/o needing a domain/server)
#!/bin/bash
# Variables
client_id=""
client_secret=""
scopes=""
auth_code=""
access_token=""
@dccampbell
dccampbell / UpdateWebflowRedirects.js
Created March 6, 2021 00:50
Webflow 301 Redirects Batch Updater
/**
* Console-friendly function to batch update 301 redirects in Webflow.
* Existing redirects will be replaced when source matches but target doesn't.
* A rule w/ an empty target will remove existing matches but not replace them.
* Small wait time between each add/remove to allow ajax calls time to finish.
* Intended for use here: https://webflow.com/dashboard/sites/YOURSITE/hosting
* @example updateWebflowRedirects( [{ source: "/old", target: "/new" }] );
*/
async function updateWebflowRedirects(rules) {
@dccampbell
dccampbell / .env.example
Created February 28, 2020 16:19
Local Dev Environments for PHP Projects w/ Homestead
APP_URL=http://www.myproject.test
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=myprojectdb
DB_USERNAME=homestead
DB_PASSWORD=secret
MAIL_DRIVER=smtp
@dccampbell
dccampbell / webpack.mix.extractjs.js
Last active February 10, 2020 19:03
ExtractJS for Laravel Mix - Extension for code splitting custom JS modules similar to extract() for vendor ones.
let glob = require('glob');
let mix = require('laravel-mix');
let webpackMerge = require('webpack-merge');
/**
* Laravel Mix extension for code splitting custom JS similar to extract() for vendor modules.
* @author @dccampbell
* @example mix.extractJs('/resources/js/api.js', 'public/js')
* @example mix.extractJs('/resources/js/store/*', 'public/js/store.js')
* @example mix.extractJs(['/js/lib.js', '/js/lib.*.js'], 'public/js/lib.js')
@dccampbell
dccampbell / git_prune_merged_branches.sh
Last active September 16, 2019 18:40
Git: Prune Merged Branches
#!/bin/bash
set -e
git fetch --all --prune
localBranches=$(git branch --merged origin/master | sed 's/^[ *]\+//' | grep -v '^master$' || echo '')
if [[ -z "$localBranches" ]]; then
echo "No local merged branches found."
@dccampbell
dccampbell / osx_setup_homebrew.sh
Last active January 24, 2020 07:08 — forked from iainconnor/setup.sh
Mac OSX Setup
#!/usr/bin/env bash
# Ask for the administrator password upfront
sudo -v
# Install Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" || exit 1
# Configure Homebrew
brew doctor
@dccampbell
dccampbell / setupFirefoxDev.sh
Last active March 6, 2019 16:04
Install Firefox Developer Edition
#!/usr/bin/env bash
set -e -x
# Variables
INSTALL_DIR="/opt/firefox-dev"
TEMP_FILE="$HOME/Downloads/firefox-dev.tar.bz2"
MENU_FILE="$HOME/.local/share/applications/firefox-dev.desktop"
BIN_DIR="$HOME/bin"
# Prepare
# Variables
COMPOSER_HOME="$HOME/.composer"
HOSTS='/etc/hosts'
VHOST='/etc/apache2/sites-available/localdev.conf'
ERRLOG='/var/log/apache2/error.log'
# Fix SSH xterm-256color issue
alias ssh='TERM=xterm-color ssh'
# File Shortcuts
@dccampbell
dccampbell / FacebookAdvertiserRemover.js
Created February 18, 2019 18:15
A script for selectively batch removing advertisers from your Facebook preferences.
// https://www.facebook.com/ads/preferences/
function loadAllAdvertisers() {
if(!document.querySelector('#interacted ._45ys')) {
document.querySelector('#interacted div[role=button]').click();
}
window.interactedInterval = setInterval(function() {
var moreBtn = document.querySelector('#interacted ._45yr');
if(moreBtn) {
document.querySelector('#interacted ._45yr').click();
@dccampbell
dccampbell / wp-config.php
Last active November 6, 2018 19:49
Wordpress config file w/ env support
<?php
/**
* Dynamic Wordpress Configuration File
*
* This config file is designed to be flexible for use in any environment without need for modification.
* It exposes most configurations to being set externally, such as via SetEnv in Apache/htaccess or PHP's putenv().
*
* It will optionally load a /env.php file. If the file returns an array, the key/values will be loaded using putenv().
*