Skip to content

Instantly share code, notes, and snippets.

View ZedThree's full-sized avatar

Peter Hill ZedThree

View GitHub Profile
@ZedThree
ZedThree / README.md
Last active December 13, 2021 15:08
Helper for making simple markdown changelogs from closed GitHub PRs and issues
usage: make_github_changelog.py [-h] --token TOKEN [--since-tag SINCE_TAG] [--base BASE]

Helper for writing changelogs

optional arguments:
  -h, --help            show this help message and exit
  --token TOKEN, -t TOKEN
                        GitHub API token
 --since-tag SINCE_TAG
@ZedThree
ZedThree / mpark_variant_printer.py
Created November 29, 2021 11:14
GDB pretty-printer for mpark.variant based on the libstdc++ pretty-printers
# Pretty-printers for mpark.variant based on those for libstdc++.
# Copyright (C) 2008-2021 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@ZedThree
ZedThree / rtags-xref.el
Last active July 30, 2018 12:07 — forked from jwalt/rtags-xref.el
Emacs25 rtags xref bindings
;;; rtags-xref.el -- rtags backend for xref.el
;;; Commentary:
;;;
;;; This adds support for the Emacs25 xref API (`xref-find-definitions' and
;;; friends) to rtags. Just `require' it and the default Emacs keybindings
;;; (M-., M-,, M-? etc.) use rtags.
;;;
;;; Enable like this:
;;;
def moduleinit():
"""Make sure various environment variables are set correctly
"""
if 'MODULE_VERSION' not in os.environ:
os.environ['MODULE_VERSION_STACK'] = '3.2.10'
os.environ['MODULE_VERSION'] = '3.2.10'
else:
os.environ['MODULE_VERSION_STACK'] = os.environ['MODULE_VERSION']
os.environ['MODULESHOME'] = '/usr/share/Modules/3.2.10'
@ZedThree
ZedThree / XMF_3D_timeseries.py
Created May 27, 2015 08:58
An example of writing 3D time series data to an XMF file which references data in an accompanying HDF5 file (output.h5)
from xml.etree.ElementTree import Element, SubElement
from xml.etree import ElementTree
from xml.dom import minidom
def prettify(elem):
"""Return a pretty-printed XML string for the Element.
"""
rough_string = ElementTree.tostring(elem, 'utf-8')
reparsed = minidom.parseString(rough_string)
return reparsed.toprettyxml(indent=" ")
@ZedThree
ZedThree / fortran-dot-graph.py
Last active February 2, 2023 21:15
Build a dot graph of the Fortran modules in a list of files.
import re
def build_graph(files,exclude=['hdf5','h5lt','mpi']):
"""Build a dot graph of the Fortran modules in a list of files,
excluding modules named in the list exclude"""
# Start the graph
graph = "digraph G {\n"
deps = {}
p = re.compile("^(?:module|program) ([a-zA-Z0-9_]*)",
@ZedThree
ZedThree / insert-f90-namelist
Created August 2, 2013 13:34
Insert namelist function for f90-namelist mode
(defun insert-f90-namelist (name)
"Insert a new f90 namelist"
(interactive "sNamelist name: ")
(insert (format "/&%s" name))
(funcall f90-auto-keyword-case -1)
(insert "\n\n/")
(previous-line))
@ZedThree
ZedThree / gist:5978272
Created July 11, 2013 19:05
Zoopla houses thing as an ipython notebook
{
"metadata": {
"name": "zoopla_houses_notebook"
},
"name": "zoopla_houses_notebook",
"nbformat": 2,
"worksheets": [
{
"cells": [
{
@ZedThree
ZedThree / zoopla_house_area
Last active December 19, 2015 15:09
Calculates the area of a house from a listing on Zoopla
import re
import urllib2
import numpy as np
from BeautifulSoup import BeautifulSoup
house_webpage = 'http://www.zoopla.co.uk/for-sale/details/28121543'
# Grab the whole webpage for the house listing
soup = BeautifulSoup(urllib2.urlopen(house_webpage).read())