Skip to content

Instantly share code, notes, and snippets.

View charlesreid1's full-sized avatar

Chaz Reid charlesreid1

View GitHub Profile
@charlesreid1
charlesreid1 / decorators_examples.py
Last active October 23, 2019 15:43
Examples of Python decorators in action
import random
"""
Python Decorators: Some Examples
This file contains a few examples of ways you can
use decorators. These are minimal examples that
should generalize usefully in many situations.
Also see: https://wiki.python.org/moin/PythonDecoratorLibrary
@charlesreid1
charlesreid1 / gendoc.sh
Created January 1, 2019 23:13 — forked from kegsay/gendoc.sh
Generate static docs for a Go package
#!/bin/bash
set -u
DOC_DIR=godoc
PKG=github.com/matrix-org/go-neb
# Run a godoc server which we will scrape. Clobber the GOPATH to include
# only our dependencies.
GOPATH=$(pwd):$(pwd)/vendor godoc -http=localhost:6060 &
DOC_PID=$!
@charlesreid1
charlesreid1 / doit.sh
Created October 31, 2018 21:47
Make a gif file that zooms in to a static jpg/png image (powered by ImageMagick)
#!/bin/bash
# Panned and zoomed animation
# Mark Setchell
# https://stackoverflow.com/a/33467267
CONVERTME="full.jpg"
steps=60
# Final x offset from top left
finalx=2070
@charlesreid1
charlesreid1 / Readme.md
Last active October 6, 2018 21:38
Contribution Counter - Count contributions (opening issues or pull requests) to the DCPPC.

Top Contributors to the DCPPC

This script uses the Github API to iterate through all repos in the DCPPC organization and count contributions (opening an issue or a pull request) by user.

This requires an API key for an account that can access both public and private repositories in the DCPPC. (We used one of our own, as Florence Python runs Centillion and our Github authorization protection layers, and we don't want to bork those.)

Create an API access token in the Settings page on Github, and pass that into the script with the environment variable GITHUB_TOKEN:

$ GITHUB_TOKEN="AAAAAAAAAAAA" python top_contributors.py
@charlesreid1
charlesreid1 / snippet.csv
Created October 6, 2018 02:00
make table of contents snippet
1M.1.DEMO.md Searching
1M.1.FULLSTACKS.md Common IDs
1M.2.PRODUCT.md API Registry
2M.1.DEMO.md Uploads and Minting
2M.1.FULLSTACKS.md TopMed Workflows
2M.1.PRODUCT.md Draft DCPPC website
2M.2.PRODUCT.md GUIDs Core Metadata
3M.1.DEMO.md Searching metadata
3M.1.PRODUCT.md Draft FAIR metadata specification
3M.2.DEMO.md FAIRness assessment
@charlesreid1
charlesreid1 / Readme.md
Last active October 3, 2018 20:34
Get mail archives for Groups.io subgroups

Get Groups.io Mbox Email Archives

This python script demonstrates how to download the email archives for all subgroups of a groups.io group using their API. This will download each subgroup's email archives into a separate .mbox file in the mboxes/ directory. This write-to-disk step is not strictly necessary, as the mbox file is contained in a zip file in memory.

To run this, you need a Groups.io secret token. Provide this to the script using an environment variable:

@charlesreid1
charlesreid1 / README.md
Last active March 4, 2019 05:20
Walk through each issue in a Github repository and extract the date that each issue was closed.

Walk a Github Repo

This uses the Github API, via the PyGithub Python library, to list all closed issues and print info about when the issue was closed and who closed it.

To run, you need a Github API access token:

GITHUB_TOKEN="XXX" python issue_close_dates.py
@charlesreid1
charlesreid1 / test.py
Created September 16, 2018 03:01
Python OOP: Controlling parent class behavior from child class
"""
Python Object Oriented Programming:
Control Parent Class Behavior from Child Class
Author: Charles Reid
Date: 2018-09-15
This is a short demo of how to conditionally
control the behavior of a parent class from a
child class. This is accomplished by setting
@charlesreid1
charlesreid1 / whoosh_test.py
Created September 15, 2018 02:19
Whoosh test
from whoosh import analysis, fields, index, qparser, query, searching, scoring
from whoosh.filedb.filestore import RamStorage
from whoosh.compat import b, u, text_type
def main():
schema = fields.Schema(name=fields.TEXT(stored=True),
hobbies=fields.TEXT(stored=True))
storage = RamStorage()
ix = storage.create_index(schema)
writer = ix.writer()
@charlesreid1
charlesreid1 / README.md
Last active August 3, 2018 05:23
Walk the file tree of a github repository and extract the text of all markdown files. Then do something trivial with it.

Walk a Github Repo

This uses the github API to walk the file tree of a github repo.

To run:

GITHUB_TOKEN="XXX" python repotree.py