Skip to content

Instantly share code, notes, and snippets.

View mgedmin's full-sized avatar

Marius Gedminas mgedmin

View GitHub Profile
@mgedmin
mgedmin / buildout-tags.sh
Last active December 14, 2015 21:38
Create ctags for the current virtualend or buildout
#!/bin/bash
# Build a vim tags file for all the Python packages in the buildout path
# Assumes . is the directory with a buildout.cfg
# Note: there is no one true buildout path -- every part has its own. So
# we look for a python interpreter in bin/python (or bin/py) and use its path.
# If that fails, we try to find a bin/test script and scrape the path from it.
# Should also work with virtualenv (just run it somewhere with a bin/python)
# Published at https://gist.github.com/mgedmin/5152189
progname=${0##*/}
#!/usr/bin/python3
import json
import os
import subprocess
import urllib.request
import sys
from operator import itemgetter

zope-test-janitor

This is a script that analyzes Zope test summary emails and produces an HTML report.

Mutt users: pipe (|) the email to zope-test-janitor, enjoy output in your browser.

image

@mgedmin
mgedmin / timeline.py
Last active October 10, 2019 12:34
Visualize a Zope trace.log with d3.js
#!/usr/bin/python3
"""
Show recent requests on a timeline
Parses a ZServer trace.log file. The format is documented at
https://pypi.python.org/pypi/zc.zservertracelog
"""
import json
import re
@mgedmin
mgedmin / watchpos.py
Created December 17, 2012 18:16
Hack to monitor file position of an app that doesn't have any built-in progress indication
#!/usr/bin/python
"""
Usage: watchpos {filename|pid fd}
Watches the file pointer of an opened file on Linux. Use it to provide a
progress bar to a command that doesn't have one, assuming the program reads
this file from start to end without jumping around.
Copyright (c) 2011 Marius Gedminas <marius@gedmin.as>
@mgedmin
mgedmin / github_mirror.py
Last active January 13, 2022 07:46
Mirror all my github repositories and gists
#!/usr/bin/env python3
# See http://stackoverflow.com/questions/3581031/backup-mirror-github-repositories/13917251#13917251
# You can find the latest version of this script at
# https://gist.github.com/4319265
import os
import sys
import json
import urllib.request
import subprocess
@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
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
@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:

@rodw
rodw / backup-github.sh
Last active March 30, 2024 15:04
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:
#-------------------------------------------------------------------------------
# * Under the heading "CONFIG" below you'll find a number of configuration
# parameters that must be personalized for your GitHub account and org.
# Replace the `<CHANGE-ME>` strings with the value described in the comments
# (or overwrite those values at run-time by providing environment variables).