Skip to content

Instantly share code, notes, and snippets.

View charlesreid1's full-sized avatar
💭
🍒 🍍 🍓 🍊 🍌

Chaz Reid charlesreid1

💭
🍒 🍍 🍓 🍊 🍌
View GitHub Profile
@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
from requests_oauthlib import OAuth2Session
from flask import Flask, request, redirect, session, url_for
from flask.json import jsonify
import os
app = Flask(__name__)
# This information is obtained upon registration of a new GitHub OAuth
# application here: https://github.com/settings/applications/new
client_id = "XXX"
@charlesreid1
charlesreid1 / make_issues_table.py
Last active July 16, 2018 20:12
For a given github repository, create a markdown table of issues+links, and add it to the repo's docs/issues_table folder
from github import Github
import os
"""
Make Issues Table
This script takes the name of a DCPPC workshop repository as an input.
It then compiles a list of open issues, and creates a Markdown document
containing a table with one column (issue name) that links to the issue.
@charlesreid1
charlesreid1 / pending_invitations.py
Last active July 16, 2018 16:02
Get a list of pending invitations to a github organization or team by calling the Github API
import requests
import os
import json
# Credentials
api_token = os.environ['GITHUB_TOKEN']
user = os.environ['GITHUB_USER']