Skip to content

Instantly share code, notes, and snippets.

View petehalverson's full-sized avatar

Pete Halverson petehalverson

View GitHub Profile
@petehalverson
petehalverson / subnav.js
Created May 22, 2013 21:03
JS for touch subnav. Requires: Modernizr (expects the touch class) and hover classes in CSS.
$(function() {
if ($('html').hasClass('touch'))
{
$('html').click(function(e) {
$('nav > ul > li').removeClass('hover');
});
$('nav > ul > li').click(function(e) {
if (!$(this).hasClass('hover') && $(this).has('ul.subnav').length > 0)
@petehalverson
petehalverson / docker.aliases
Created November 2, 2016 18:34
Docker aliases. Add to ~/.profile and restart your terminal
# Sync docker clock
alias dockerclock='docker run --rm --privileged alpine hwclock -s'
# Kill all running containers.
alias dockerkillall='docker kill $(docker ps -q)'
# stop all running containers
alias dockerstop='docker stop $(docker ps -a -q)'
@petehalverson
petehalverson / dockenv.sh
Last active November 12, 2016 14:30
Docker environment manager. Shortcut for setting docker environment with bash completion
# add to .bashrc, .bash_profile, ~/.profile
dockenv() {
command -v "docker-machine" >/dev/null 2>&1 && {
if [ $1 = 'unset' -o $1 = '-u' ]; then
eval $(docker-machine env -u)
else
eval $(docker-machine env "$1")
if ! [ $1 = 'unset' -o $1 = '-u' ]; then
docker-machine ip $1 | tr -d '\n' | pbcopy
fi
@petehalverson
petehalverson / git_docker_env.sh
Last active November 17, 2016 22:09
Git / Docker environment bash prompt
# add to .bashrc, .bash_profile, ~/.profile
git_docker_env() {
branch=
gitlabel="git."
dockerlabel="docker."
sep="| "
if [ -d .git ]; then
status=$(git status 2> /dev/null)
branch="$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')"
if [[ $( echo $status | grep "branch is ahead") ]]; then
# add to .bashrc, .bash_profile, ~/.profile
www() {
cd ~/www/"$@"
}
_www() {
local cur="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=( $(compgen -W "$(ls ~/www)" -- $cur) )
}
@petehalverson
petehalverson / docker-compose.yml
Last active October 25, 2017 23:25
A sample docker-compose base for PHP projects
version: '2.1'
services:
php:
image: php:apache
ports:
- 80:80
volumes:
- ./.:/var/www/html
@petehalverson
petehalverson / git_branch.sh
Last active April 26, 2018 03:34
git_branch profile script
git_branch() {
local green=$(tput setaf 10)
local yellow=$(tput setaf 11)
local reset=$(tput sgr0)
local branch=
local gitlabel="git."
local sep="| "
if [ -d .git ]; then
status=$(git status 2> /dev/null)

Keybase proof

I hereby claim:

  • I am petehalverson on github.
  • I am petehalverson (https://keybase.io/petehalverson) on keybase.
  • I have a public key whose fingerprint is 35FD 4579 8514 D2F5 DE4F FF11 CC14 405A 60A1 7282

To claim this, I am signing this object:

@petehalverson
petehalverson / oc-tag-plugin-repo.sh
Last active May 17, 2019 23:45
October CMS plugin repo tag script
#!/bin/bash
# Tag your October CMS plugin's repo with versions.
# Run from plugin working directory
if [ ! -d .git ]; then
echo "Not a git repo" && exit 1;
elif [ ! -f updates/version.yaml ]; then
echo "Plugin version.yaml not found" && exit 1;
fi
@petehalverson
petehalverson / namecheap-ddns.sh
Created July 24, 2019 18:20 — forked from dalhundal/namecheap-ddns.sh
Shell script to update namecheap.com dynamic dns for a domain with your external IP address
#!/bin/sh
# Shell script to update namecheap.com dynamic dns
# for a domain to your external IP address
HOSTNAME=yoursubdomain
DOMAIN=yourdomainname.com
PASSWORD=y0urp455w0rd
IP=`curl -s echoip.com`