Skip to content

Instantly share code, notes, and snippets.

View mauritsvanrees's full-sized avatar

Maurits van Rees mauritsvanrees

View GitHub Profile
@mauritsvanrees
mauritsvanrees / gh-stale-issue-closer.sh
Last active August 20, 2022 17:50
Iterate over open issues using the 'gh' command, and offer to close them.
#!/bin/sh
# Get a list of open issues using the 'gh' command from GitHub.
# By default this gives at most 30 answers.
# We print only the number.
# Then we iterate over these issues and check each one, offering to close it.
# There are a few sample queries.
# Make sure one of the ISSUES commands is uncommented.
# 1. Get open issues last updated before 2019.
@mauritsvanrees
mauritsvanrees / newssnippet.py
Last active October 16, 2019 20:45
News snippet
# -*- coding: utf-8 -*-
# Original: https://gist.github.com/mauritsvanrees/b30c9a8ff7075bfc38e873f03c9ebefe
#
# Sometimes towncrier is just too hard to understand, or it does too much,
# or the combination with zest.releaser is too restricting,
# especially when you want to make some manual edits after running towncrier.
# So try something out.
# Ideas for commands:
# - newssnippet create: create a news snippet with a correct name, compatible with towncrier.
# - newssnippet print/list: print all news snippets.
# -*- coding: utf-8 -*-
# https://gist.github.com/mauritsvanrees/c47e974e418c707a626200cb6561405b
# https://community.plone.org/t/creating-constraints-and-requirements-from-buildout-config/10296
# from configparser import ConfigParser
from zc.buildout import buildout
import re
# We read this buildout config file:
@mauritsvanrees
mauritsvanrees / check-redirects.py
Created April 3, 2019 14:15
Check the automatic and manual redirects in all Plone Sites.
# Check the automatic and manual redirects in all Plone Sites.
# Run this with:
# bin/instance run check-redirects.py
# or with extra options: --verbose --fix --site=Plone
from plone.app.redirector.interfaces import IRedirectionStorage
from zope.component import getUtility
from zope.component.hooks import setSite
import argparse
import sys
@mauritsvanrees
mauritsvanrees / towncrier-init.sh
Last active October 1, 2018 10:52
Make initial changes in a git project to use towncrier instead of manually editing CHANGES.rst
#!/bin/sh
# Latest public version:
# https://gist.github.com/mauritsvanrees/92c40bc16ceaf3c375d81c995b4552c4
# Goal:
# Make initial changes in a git project to use towncrier
# instead of manually editing CHANGES.rst.
# Create a standard pyproject.toml file.
TOML="pyproject.toml"
if ! test -e $TOML; then
@mauritsvanrees
mauritsvanrees / add51.py
Created August 12, 2016 20:55
Add Plone 5.1 classifier when Plone 5.0 classifier is there.
"""Add Plone 5.1 classifier when Plone 5.0 classifier is there.
Usage:
cd <coredev 5.1 branch>
cd src
python2.7 add51.py plone.app.favoritepackage
python2.7 add51.py *
"""
@mauritsvanrees
mauritsvanrees / plonecheck.sh
Last active November 2, 2018 11:01
Run a few checks in a Plone package checkout before creating a release. Hardcoded to my system.
#!/bin/sh
# Latest version:
# https://gist.github.com/mauritsvanrees/eb69adbb51747834808f6847c140b706
# Run this in a checkout of a Plone package to get some information,
# like which version is used in which Plone version.
# Hardly related note: sort coredev checkouts by date that they were added:
# git blame checkouts.cfg | cut -b29- | sort -g
# The current directory as package name.
package=$(basename $(pwd))
@mauritsvanrees
mauritsvanrees / grabversions.py
Last active November 13, 2015 20:18
Grab version files from dist.plone.org for each Plone version.
"""Grab version files from dist.plone.org for each Plone version.
Original location:
https://gist.github.com/mauritsvanrees/99cb4a25b622479e7dc3
Goal: grep through these files to see which version of a package is
used in which Plone version.
Usage:
$ virtualenv-2.7 .
@mauritsvanrees
mauritsvanrees / blobchunkcleanup.py
Last active August 29, 2015 14:18
Proof of concept for downloading and deleting blob chunks from RelStorage. Use at your own risk.
#!/usr/bin/env python
##############################################################################
#
# Copyright (c) 2015 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@mauritsvanrees
mauritsvanrees / blobdownload.py
Created March 31, 2015 09:15
Proof of concept for downloading blobs from relstorage. Use at your own risk.
#!/usr/bin/env python
##############################################################################
#
# Copyright (c) 2015 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED