Skip to content

Instantly share code, notes, and snippets.

View collinpeters's full-sized avatar

Collin Peters collinpeters

View GitHub Profile
@collinpeters
collinpeters / prepare-commit-msg
Last active April 19, 2018 18:59
Git commit hook to slap hand if a license header was forgottten
#!/bin/sh
#
# Git commit hook to run a license check on new files in the index. Failed CI builds no more!!
#
# Usage: drop it into <repo>/.git/hooks
# One liner (run from .git/hooks folder): curl -s -O -J https://gist.githubusercontent.com/collinpeters/9d6418687b7a390d1a20bebc859814be/raw/prepare-commit-msg
# Since the check is slow, we only want to run it when new files have been added to the index
NEW_FILES=$(git diff --name-only --diff-filter=A --cached)
#!/bin/bash
set -e
JAVA_HOME=${1-text}
[ $# -eq 0 ] && { echo "Usage: sudo $0 \$(/usr/libexec/java_home -v '1.8*')" ; exit 1; }
KEYSTORE=$JAVA_HOME/jre/lib/security/cacerts
wget https://letsencrypt.org/certs/letsencryptauthorityx1.der
wget https://letsencrypt.org/certs/letsencryptauthorityx2.der
@collinpeters
collinpeters / pg_server_status
Created February 14, 2015 12:53
Command line version of pgAdmin server status window
#!/bin/sh
QUERY="\
SELECT count(*), waiting, age(now(), MAX(query_start)) as max_query_age, age(now(), MAX(backend_start)) as max_backend_start_age, age(now(), MAX(xact_start)) as max_xact_start_age, current_query \
FROM pg_stat_activity \
WHERE datname <> 'postgres' \
AND current_query NOT LIKE '%current_query%' \
GROUP BY datname, current_query, waiting"
DEST_HOST=$1
@collinpeters
collinpeters / cvimrc
Last active June 5, 2017 22:02
cvimrc
let barposition = "bottom"
let hintcharacters = "sadfjklewcmpgh"
let scrollstep = 150
let smoothscroll = "true"
" space as leader
let mapleader = "\<Space>"
" Mappings
map <Leader>r reloadTabUncached
@collinpeters
collinpeters / log4j.sh
Created May 31, 2012 20:46
Script to setup log4j for Tomcat internal logging. Uses custom log4j.properties gist as well
#!/bin/sh
# Setup log4j for Tomcat logging as per http://tomcat.apache.org/tomcat-7.0-doc/logging.html#Using_Log4j
# @author Collin Peters
# Download log4j.properties
echo "Getting log4j.properties..."
wget -q --output-document /opt/tomcat/lib/log4j.properties https://gist.github.com/collinpeters/2845875/raw/caef85e03e7b586bace0dbc14da17a4f78d1757a/log4j.properties
# Download log4j.tgz and extract jar directly to Tomcat
@collinpeters
collinpeters / log4j.properties
Created May 31, 2012 20:05
log4j.properties to replace Tomcat internal logging, using RollingFileAppender
log4j.rootLogger=INFO, CATALINA
# Define all the appenders
log4j.appender.CATALINA=org.apache.log4j.RollingFileAppender
log4j.appender.CATALINA.File=${catalina.home}/logs/catalina.out
log4j.appender.CATALINA.MaxFileSize=100MB
log4j.appender.CATALINA.MaxBackupIndex=5
log4j.appender.CATALINA.layout=org.apache.log4j.PatternLayout
log4j.appender.CATALINA.layout.ConversionPattern=%d{dd.MM.yyyy HH:mm:ss} %p-%c{1}: [%m]%n
@collinpeters
collinpeters / tomcat.sh
Created April 19, 2012 20:09
Tomcat 7 Debian LSB Script
#!/bin/sh
#
# /etc/init.d/tomcat -- startup script for the Tomcat 7 servlet engine
#
# Modified init-Script from Ubuntu Tomcat init-script
#
# 2010 - Sebastian Mogilowski - http://www.mogilowski.net/2010/12/11/install-tomcat-7-on-debian-lenny-with-virtual-hosts-and-apache2-integration/
# 2012 - Collin Peters - Added debug option
#
### BEGIN INIT INFO