Skip to content

Instantly share code, notes, and snippets.

function nukebranch () {
BRANCH=`git rev-parse --abbrev-ref HEAD`
if [ $BRANCH == 'master' ]; then
echo "Refusing to delete master"
else
(git push origin --delete $BRANCH || true) && git checkout master && git branch -d $BRANCH
fi
}
@imjasonh
imjasonh / markdown.css
Last active September 27, 2024 11:01
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@brainsik
brainsik / gist:4280136
Created December 13, 2012 21:31
A simple way for Python cron tasks to exit if another process is currently running. Does not use a pidfile.
import os
import subprocess
import shlex
def bail_if_another_is_running():
cmd = shlex.split("pgrep -u {} -f {}".format(os.getuid(), __file__))
pids = subprocess.check_output(cmd).strip().split('\n')
if len(pids) > 1:
pids.remove("{}".format(os.getpid()))
@brandonb927
brandonb927 / osx-for-hackers.sh
Last active October 8, 2024 10:59
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
<!doctype html>
<!-- http://taylor.fausak.me/2015/01/27/ios-8-web-apps/ -->
<html>
<head>
<title>iOS 8 web app</title>
<!-- CONFIGURATION -->
@mwhooker
mwhooker / bzr_tip.py
Created August 2, 2011 02:43
print timestamp of last revision for each file in bzr branch
"""Takes a list of files under bazaar version control and lists path and
timestamp of last commit.
Usage: bzr_tip.py $(find . -name "*.py") | sort -n
line output format is <timestamp> <file>@<last revision>
"""
import sys
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//
!function() {
var doc = document,
htm = doc.documentElement,
lct = null, // last click target
nearest = function(elm, tag) {
while (elm && elm.nodeName != tag) {
elm = elm.parentNode;
}
return elm;
};