Skip to content

Instantly share code, notes, and snippets.

View doctorallen's full-sized avatar

David Allen doctorallen

View GitHub Profile
@doctorallen
doctorallen / gitarchive.sh
Created August 24, 2017 14:15
Clones a Git repository with all tags and branches, and archives it as a .tar.gz file.
#!/usr/bin/env bash
# Takes one parameter: a remote git repository URL.
#
# This is the stuff this script does:
#
# 1. Clones the repository
# 2. Fetches all remote branches
# 3. Compresses the folder
# 4. Deletes the cloned folder.
@doctorallen
doctorallen / updatenooverride.class.php
Created March 25, 2016 15:54
Override Processor for MODX and ImportX
<?php
require_once (dirname(__FILE__).'/update.class.php');
/**
*
* @param $data A JSON array of data to update from.
*
* @package modx
* @subpackage processors.resource
*/
class modResourceUpdateNoOverrideProcessor extends modResourceUpdateProcessor {
@doctorallen
doctorallen / deploy.sh
Last active January 12, 2016 15:27
Simple git deployment helper script
#!/usr/bin/env bash
if [ -r ./.deploy ]; then
echo "Reading config" >&2
. ./.deploy
fi
production=false
while getopts h:b:d:p opt; do
case $opt in
@doctorallen
doctorallen / filter.php
Created October 2, 2015 16:59
Project Switching Alfred Workflow
require_once('workflows.php');
$wf = new Workflows();
$query = "{query}";
$wf->search($query);
echo $wf->toxml();
@doctorallen
doctorallen / timereport.sh
Last active August 29, 2015 14:13
Run A Time Report
#!/usr/bin/env bash
# You will want to also add the git today command: https://github.com/doctorallen/dotfiles/blob/master/.gitconfig#L49
root=$1
if [ -n "$root"]
then
echo "Error: please define the root directory location for your report."
read root
fi
lastchar=${#root}-1
@doctorallen
doctorallen / backup.sh
Created August 5, 2014 14:56
Rolling Backups
#!/bin/sh
MYSQLROOT=test
MYSQLPASS=test
S3BUCKET=TAG_Backups
FILENAME=test
DATABASE='--all-databases'
# the following line prefixes the backups with the defined directory. it must be blank or end with a /
S3PATH=mysql_backup/
# when running via cron, the PATHs MIGHT be different. If you have a custom/manual MYSQL install, you should set this manually like MYSQLDUMPPATH=/usr/local/mysql/bin/
@doctorallen
doctorallen / lstime.sh
Created April 17, 2014 14:14
List all directories by the timestamp of all files recursively
#!/bin/bash
for dir in */; do
timestamp=$(find ./$dir -type f -printf "%T@ %t\\n" | sort -nr -k 1,2 | head -n 1)
printf "%s %s\n" "$timestamp" "$dir"
done | sort -nr -k 1,2 | awk '{$1=""; print}'
@doctorallen
doctorallen / table-dump.sh
Created March 26, 2014 20:04
Handy script for deleting all tables in a remote database you do not have root access to. Modified from original at: http://www.cyberciti.biz/faq/how-do-i-empty-mysql-database/
#!/bin/bash
MUSER="$1"
MPASS="$2"
MSERVER="$3"
MPORT="$4"
MDB="$5"
# Detect paths
MYSQL=$(which mysql)
AWK=$(which awk)
@doctorallen
doctorallen / starbound.sh
Last active July 30, 2016 21:53
Startup script for starbound server
#! /bin/sh
### BEGIN INIT INFO
# Provides: starbound
# Required-Start: networking
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: Starbound Server Daemon
# Description: Starts/Stops/Restarts the Starbound Server Daemon
### END INIT INFO
@doctorallen
doctorallen / custom.ini
Created December 2, 2013 21:59
Updating Trac with custom fields
[ticket-custom]
progress = select
progress.label = Progress
progress.options = not started yet|started|ready for QA|tested but has bugs|testing passed|ready for staging|posted to staging|ready for production|posted to production|needs client approval|needs client feedback|needs PM clarification|can't replicate
estimate = text
estimate.format = plain
estimate.label = Hour Estimate
percent = select
percent.label = Percent Complete
percent.options = 0%|25%|50%|75%|100%