Skip to content

Instantly share code, notes, and snippets.

View dccampbell's full-sized avatar

David C. Campbell dccampbell

View GitHub Profile
@dccampbell
dccampbell / GitPHP-AgeSort.js
Last active August 29, 2015 14:26
Tampermonkey-friendly JS for modifying a GitPHP repo list page. Fixes age sorting to work across all repos by removing categories first.
// ==UserScript==
// @name GitPHP - Age Sort w/o Categories
// @version 1.0.0
// @author dccampbell
// @run-at document-end
// @match http*://*/?sort=age
// @require http://code.jquery.com/jquery-latest.js
// @description GitPHP Repo List - Remove categories and sort all repos by last update.
// ==/UserScript==
@dccampbell
dccampbell / laravel-latestdocs.js
Created September 14, 2015 23:03
Tampermonkey: Redirect all Laravel doc pages to their master version.
// ==UserScript==
// @name Laravel Latest Docs
// @description Always redirect to the master version laravel docs.
// @author David C. Campbell
// @match http://laravel.com/docs/*
// ==/UserScript==
var url = window.location.href;
var matches = url.match(/[0-9].[0-9]/);
@dccampbell
dccampbell / setupEnv.sh
Last active December 27, 2022 14:18
Linux Environment - Initial Setup Script
#!/usr/bin/env bash
echo "=== System Install Starting! ==="
# Variables
DL_DIR="$HOME/Downloads/EnvSetup" && mkdir -p "$DL_DIR"
BIN_DIR="$HOME/bin" && mkdir -p "$BIN_DIR"
source /etc/os-release #loads $UBUNTU_CODENAME
export DEBIAN_FRONTEND=noninteractive
@dccampbell
dccampbell / setupApache.sh
Last active January 14, 2020 03:10
Install Apache, change user to current, enable macro and rewrite modules, set default server name, add a vhost macro, create a localdev site, add commands for easy add/removal of vhost
#!/usr/bin/env bash
## Apache Setup
# Variables
BIN_DIR="/usr/local/bin"
# Install Apache
#sudo apt install -y apache2
# Change Apache User/Group
@dccampbell
dccampbell / installMagerun.sh
Last active February 3, 2016 00:34
Install Magerun, restrict to one user, and create alias.
#!/bin/bash
# Install Magerun, restrict to one user, and create alias.
# Usage: installMagerun.sh [user] [path]
# [user] defaults to current user
# [path] defaults to current ./n98-magerun.phar
# Vars
mrUser="${1:-$(whoami)}"
@dccampbell
dccampbell / git-status-recursive
Last active January 5, 2016 10:25
Scan the current sub-directories for git repositories, recursively, and return the git status for the working tree and all branches. Default max depth is 3. Ignores vendor and modman folders.
#!/usr/bin/env bash
basePath="$PWD"
baseDirs=$(find $basePath -mindepth 1 -maxdepth 1 -type d)
gitPaths=$(find $basePath -mindepth 1 -maxdepth ${1:-3} -name .git -type d -exec dirname {} \; | grep -v '/vendor/\|/.modman/')
unchangedDirs=()
for repo in $gitPaths; do
cd $repo
[[ "$2" = "-f" ]] && git fetch -q &>/dev/null
[core]
autocrlf = input
eol = lf
[push]
default = current
[pull]
ff = only
[merge]
ff = false
[diff]
#!/bin/bash
mkdir -pv ./.n98-magerun/modules/ && cd ./.n98-magerun/modules/
git clone --depth=1 https://github.com/kalenjordan/magerun-addons && mv magerun-addons kj-magerun-addons
git clone --depth=1 https://github.com/peterjaap/magerun-addons && mv magerun-addons pj-magerun-addons
git clone --depth=1 https://github.com/creatuity/magerun-creatuity
git clone --depth=1 https://github.com/aoepeople/mpmd
<?php
function getInput() {
return !empty($_POST['mediawiki']) ? $_POST['mediawiki'] : '';
}
function convertSyntax() {
$mediawiki = getInput();
if(empty($mediawiki)) return '';
@dccampbell
dccampbell / savePageToFile.js
Created March 19, 2016 03:12
Functions for getting the page HTML, search/replacing domain strings, and saving text to a file. Tested in Chrome 49 via Tampermonkey.
window.addEventListener('load', function() {
var data = getPageHtml().replaceUrls('foo.com', 'bar.com');
var file = document.location.pathname.basename();
//saveToFile(data, file);
}, false);
/**