Skip to content

Instantly share code, notes, and snippets.

View koehn's full-sized avatar
🧐
Coaching

Brad Koehn koehn

🧐
Coaching
View GitHub Profile
@koehn
koehn / configure-dovecot.sh
Created May 14, 2014 13:37
Configure dovecot 2.x build
./configure --with-pam --with-solr --with-sql --with-mysql --with-zlib --with-bzlib
@koehn
koehn / welcome.md
Created May 30, 2014 14:05
My standard welcome message.

Welcome to the pod! Be sure to check out the tutorials and wiki to learn how diaspora works.

Enjoy!

@koehn
koehn / java2groovy.vim
Last active August 29, 2015 14:03
These VIM macros help to covert Java to Groovy. Sadly neither IntelliJ nor Eclipse has regex that can handle this, but VIM is always available.
# no semicolons at eol
:%s/;[ \t]*$//
# no 'public'
:%s/public //
# convert Java 'bar.getFoo()' to Groovy 'bar.foo' in VIM
:%s/\.\(get\|is\)\(\u\)\(\w\+\)()/.\l\2\3/g
# convert Java 'foo.setBar(baz)' to Groovy 'foo.bar = baz'
@koehn
koehn / getip6
Last active December 29, 2015 06:19
Send the current IPv6 address to stdout.
#!/bin/bash
CHECK_IP=`curl -6 -m 5 http://www.whatismyipv6.com/ 2> /dev/null | awk '/^[0-9a-f:]+<tr><td>/ { sub(/<.*/, "") }; { print $0 }' | egrep '^[0-9a-f:]+$'`
if [ $? -ne 0 ]
then
echo Unable to get current IP address with curl >&2
exit 100
fi
echo $CHECK_IP | sed -e 's!.*is \(.*\)</h1>.*!\1!'
@koehn
koehn / block-bad-domains.conf
Last active December 29, 2015 10:38
mod_rewrite configuration to send either a 410 (Gone) or a robots file with disallow * for any request to a domain other than one I own. I needed this because some Chinese company had been leasing the IP address that I got and still had dozens/hundreds of domain names pointed at my IP; I didn't want my app server getting these and/or redircting …
RewriteEngine On
RewriteCond %{HTTP_HOST} !^.*koehn\.com$
RewriteRule ^robots\.txt$ /robots-off.txt [L]
RewriteCond %{HTTP_HOST} !^.*koehn\.com$
RewriteRule !^robots-off\.txt$ - [L,G]
@koehn
koehn / gitconfig
Created December 7, 2013 18:55
GitConfig with a lot of handy aliases I've come to love.
[alias]
co = checkout
ci = commit
st = status
br = branch
hist = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)&lt;%an&gt;%Creset' --abbrev-commit --date=relative
type = cat-file -t
dump = cat-file -p
undo = reset --hard
new = !sh -c 'git log $1@{1}..$1@{0} "$@"'
@koehn
koehn / mysql-db-backup.sh
Created December 31, 2013 03:18
A script to backup MySQL databases. If you're using InnoDB and MariaDB 5.3 or higher, --single-transaction will give you a dump that is consistent without locking the tables. I use this as part of my rsnapshot backups. The use of --single-transaction and the echo "" > /dev/null (to avoid returning non-zero) were the only changes I made.
#!/bin/bash
# A UNIX / Linux shell script to backup mysql server database using rsnapshot utility.
# -------------------------------------------------------------------------
# Copyright (c) 2007 Vivek Gite <vivek@nixcraft.com>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
# Tested under RHEL / Debian / CentOS / FreeBSD oses
@koehn
koehn / quit.sh
Created January 4, 2014 16:48
A simple command-line utility to use AppleScript (neé OSAScript) to quit an application. Usage: `quit [Application Name]`
#!/bin/bash
osascript -e "tell application \"$1\" to quit"
@koehn
koehn / GenericsQuiz.java
Last active January 3, 2016 09:39
Test your Java generics knowledge with this pop quiz: which are the valid statements?
import java.util.List;
public class GenericsQuiz {
List<Number> listOfNumber;
List<? extends Number> listOfExtendsNumber;
List<? super Number> listOfSuperNumber;
List<Integer> listOfInteger;
List<? extends Integer> listOfExtendsInteger;
List<? super Integer> listOfSuperInteger;
@koehn
koehn / txt
Created March 7, 2016 20:02
Fix Mac Docker
Run the Docker Quickstart Terminal app
Run docker-machine restart default
Run eval $(docker-machine env default)