Skip to content

Instantly share code, notes, and snippets.

@mgedmin
mgedmin / whatsmodified.sh
Created January 8, 2012 22:58
Find all svn/bzr/git/hg checkouts under ~/src and see if any have uncommitted changes.
#!/bin/bash
verbose=0
unknown=0
svn=0
bzr=0
git=0
hg=0
for arg in "$@"; do
@mgedmin
mgedmin / update-tcp-ports-html.py
Created January 14, 2012 00:49
Script to convert netstat -tln output into pretty HTML
#!/usr/bin/python
"""
Update TCP port assignments page in /var/www/HOSTNAME/ports/index.html.
"""
import datetime
import optparse
import os
import pwd
import socket
@Ignas
Ignas / postgresql.mk
Created January 25, 2012 13:52
Set up for a local postgresql database using a Makefile
export PGPORT ?= 4488
PG_PATH ?= $(shell if test -d /usr/lib/postgresql/9.1; then echo /usr/lib/postgresql/9.1; else echo /usr/lib/postgresql/8.4; fi)
PG_DIR = ${PWD}/instance/var
PG_DATA = ${PG_DIR}/data
PG_RUN = ${PG_DIR}/run
PG_LOG = ${PG_DIR}/log
PG_SOCKET = ${PG_RUN}/.s.PGSQL.${PGPORT}
PGPARAMS = -D ${PG_DATA} -o "-F -c unix_socket_directory=${PG_RUN} -c custom_variable_classes='busy' -c busy.active_user=0" -l ${PG_LOG}/pg.log
function! JumpToString(string)
for l:buffer_number in range(1,bufnr("$"))
if buflisted(l:buffer_number)
if join(getbufline(l:buffer_number,1,"$")) =~ a:string
exec "b . " . l:buffer_number
endif
endif
endfor
endfunction
@mgedmin
mgedmin / show-all-256-colors.py
Last active September 24, 2025 15:40
Script to show all 256 colors supported by xterms
#!/usr/bin/python
"""Print a swatch using all 256 colors of 256-color-capable terminals."""
__author__ = "Marius Gedminas <marius@gedmin.as>"
__url__ = "https://gist.github.com/mgedmin/2762225"
__version__ = '2.0'
def hrun(start, width, padding=0):
@mgedmin
mgedmin / disk-inventory.py
Created June 22, 2012 11:17
disk-inventory
#!/usr/bin/python
"""
Produce a disk inventory for fridge:
- how many hard disks and how large
- how are they partitioned
- how are the RAID devices defined
- where are they mounted
- how much space is used and how much is free
@rodw
rodw / backup-github.sh
Last active December 23, 2025 12:15
A simple script to backup an organization's GitHub repositories, wikis and issues.
#!/bin/bash
# A simple script to backup an organization's GitHub repositories.
#-------------------------------------------------------------------------------
# NOTES:
#-------------------------------------------------------------------------------
# * User @jimklimov (and probably some others called out in the long comment
# thread below) have modified this script to make it more robust and keep
# up with various changes in the GitHub API and response format at:
# https://github.com/jimklimov/github-scripts
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

import signal, time, traceback, threading
def start(interval=0.1):
global _interval, _samples
_samples = []
signal.signal(signal.SIGALRM,_sample)
signal.setitimer(signal.ITIMER_REAL,interval,interval)
def stop():
global _samples
@mgedmin
mgedmin / check_manifest.py
Last active October 14, 2015 00:08
Beginning of a tool to check Python MANIFEST.in for completeness. MOVED TO https://github.com/mgedmin/check-manifest
#!/usr/bin/python
"""Check the MANIFEST.in file in a Python source package for completeness.
Here's the plan:
This script works by building a source distribution archive (by running
setup.py sdist), then checking the file list in the archive against the
file list in version control (Subversion, Git, Mercurial, Bazaar are
supported).
Since the first check can fail to catch missing MANIFEST.in entries when