Skip to content

Instantly share code, notes, and snippets.

@jrial
jrial / git-tidy
Created April 9, 2019 07:56
Git tidy: remove tracking branches with no upstream and clean up merged local branches with no tracking branch
#!/usr/bin/env bash
# First, prune the tracking branches without a remote
git fetch --prune
# Now list the ones that have been merged into master
BRANCHES=`git branch -l --merged master|grep -Ev "(^\*| master$| develop$)"`
# Get the SHA of the tip of both master and origin/master for comparison
MASTER_SHA=`git show master --pretty='%H'`
@jrial
jrial / cleanup_branches.sh
Created May 4, 2018 12:37
Bash script for deleting local and remote branches that have been merged into master
#!/bin/bash
BRANCHES_BEFORE_LOCAL=`git branch -l|wc -l`
BRANCHES_BEFORE_REMOTE=`git branch -r|wc -l`
# Check if we need to pop our changes afterwards
if [ "`git stash save`" == "No local changes to save" ] ; then
POP_CHANGES="false"
else
POP_CHANGES="true"
@jrial
jrial / html_to_text.py
Last active April 18, 2018 13:04 — forked from racitup/html_to_text.py
Extract text from html in python using BeautifulSoup4
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
from bs4 import BeautifulSoup, NavigableString, Tag
def html_to_text(html):
"Creates a formatted text email message as a string from a rendered html template (page)"
soup = BeautifulSoup(html, 'html.parser')
# Ignore anything in head
" Use syntax highlighting by default
syntax on
" Use decent colors in screen
set background=dark
" Don't expand tabs...
set noexpandtab
" ...But if we were to, they would expand to 4 spaces
set shiftwidth=4
" Tabs are 4 characters wide
set tabstop=4
@jrial
jrial / gist:165d8d54e80f6f91ab5577072e8dcdc3
Created March 22, 2017 12:30 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@jrial
jrial / gist:1161f74472c10cc1f0dd6eabafe60b8a
Last active February 7, 2018 12:48
Installing VBox Guest Additions on Debian
pushd /tmp &&
sudo apt-get update && \
sudo apt-get dist-upgrade -y && \
sudo apt-get install -y build-essential linux-headers-`uname -r` module-assistant && \
sudo module-assistant prepare && \
mkdir VMT &&
pushd VMT &&
cp -r /media/`whoami`/VMware\ Tools/* . &&
tar zxf VMwareTools-*.tar.gz &&
pushd vmware-tools-distrib &&