Skip to content

Instantly share code, notes, and snippets.

@drewfradette
drewfradette / gist:2617991
Created May 6, 2012 05:41
CodeCat - syntax highlighting for cat
#!/bin/bash
# Filename catc
# Description print files to stdout with syntax highlighting (using python-pygments)
# Author Drew Fradette <http://www.github.com/drewfradette>
# Version 0.6
# Last Updated 2012-09-26
# Usage catc file.sh
# bash_version 4.2.10(1)-release
#######################################################
@drewfradette
drewfradette / headtail.py
Created February 13, 2013 03:30
Python - recreate head/tail functionality
import os
def head(filename, count=1):
"""
This one is fairly trivial to implement but it is here for completeness.
"""
with open(filename, 'r') as f:
lines = [f.readline() for line in xrange(1, count+1)]
return filter(len, lines)
@drewfradette
drewfradette / gist:2645538
Created May 9, 2012 15:29
cURL Benchmark
#!/bin/bash
# Filename benchmark
# Description execute a program periodically,showing fullscreen, colored output
# Author Drew Fradette <http://www.github.com/drewfradette>
# Last Updated 2012-05-08
# Usage benchmark example.com
# bash_version 4.2.10(1)-release
#######################################################
help() {
printf "Usage: ${0} example.com"
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
#!/usr/bin/python
# Equivalent of "tail -f" as a webpage using websocket
# Usage: webtail.py PORT FILENAME
# Tested with tornado 2.1
# Thanks to Thomas Pelletier for it's great introduction to tornado+websocket
# http://thomas.pelletier.im/2010/08/websocket-tornado-redis/
import tornado.httpserver
@drewfradette
drewfradette / gist:2661851
Created May 11, 2012 19:14
notify - Gnome Notification Script
#!/usr/bin/python
# Filename notify
# Description Show a notification in Gnome3
# Author Drew Fradette <http://www.github.com/drewfradette>
# Last Updated 2012-04-18
# Usage notify -t "Eat cheese" -m "It tastes delicious"
#######################################################
import pynotify
import sys
@drewfradette
drewfradette / gist:2618197
Created May 6, 2012 05:44
watchc - Watch with colour
#!/bin/bash
# Filename watchc
# Description execute a program periodically,showing fullscreen, colored output
# Author Drew Fradette <http://www.github.com/drewfradette>
# Version 0.5
# Last Updated 2012-01-31
# Usage watchc -n 5 ls -lah /tmp
# bash_version 4.2.10(1)-release
#######################################################
usage() {
@drewfradette
drewfradette / git-root.sh
Created October 23, 2014 19:19
git-root
#!/bin/bash
set -e
git rev-parse --show-toplevel