Skip to content

Instantly share code, notes, and snippets.

View mortehu's full-sized avatar

Morten Hustveit mortehu

  • Jump Trading
  • New York, New York
View GitHub Profile
@mortehu
mortehu / gist:6225231
Created August 13, 2013 20:15
Automatically install missing programs after failing to start
#!/bin/bash
function @()
{
if [ $? = 127 ]
then
PROGRAM=$(history 2 | head -n 1 | tr -s \ \ | cut -f3 -d\ | tr -d '[:space:]')
PATTERN="/s?bin/$PROGRAM\$"
SHORT_PATTERN="$PROGRAM"
elif [ $1 != "" ]
@mortehu
mortehu / gist:5579441
Created May 14, 2013 20:51
Retrieve missing episodes of Above & Beyond: Group Therapy Radio
#!/usr/bin/env python
from atomicfile import AtomicFile
import feedparser
import os
import re
import urllib2
import urlparse
feed = feedparser.parse("http://www.tatw.co.uk/podcast.xml")
@mortehu
mortehu / gist:5469769
Last active December 16, 2015 17:19
Fix spelling mistakes in bash command lines
# BEGIN: Put this in ~/.bashrc
function err_handle {
if [ "$?" != 0 ]
then
if echo "$previous_command" | grep -q '\<hlep\>'
then
NEW_COMMAND="$(echo "$previous_command" | sed 's/\<hlep\>/help/g')"
echo -ne "Command failed. Retry with '$NEW_COMMAND' (y/n)? "
read p