Skip to content

Instantly share code, notes, and snippets.

View MatthewRalston's full-sized avatar
🤒
Out sick

Matt Ralston MatthewRalston

🤒
Out sick
View GitHub Profile
@MatthewRalston
MatthewRalston / Makefile
Created April 18, 2018 17:44
Python project Makefiles
.PHONY: test docs
install:
pip install -r reuqirements.txt;
docs: docs/Makefile
cd docs; $(MAKE) docs
test: test/Makefile
cd test; $(MAKE) test
@MatthewRalston
MatthewRalston / difflib.patch.py
Last active November 4, 2018 02:14
difflib.SequenceMatcher.get_matching_blocks() doesn't return all results
# get_matching_blocks returns non-overlapping matches: https://bugs.python.org/issue35079
# the incomplete result is considered a feature
def get_matching_blocks(s1, s2, overlap=True):
if type(s1) is not str:
throw TypeError("get_matching_blocks() expects a string as its first positional argument")
if type(s2) is not str:
throw TypeError("get_matching_blocks() expects a string as its second positional argument")
if type(overlap) is not bool:
throw TypeError("get_matching_blocks() expects a bool as the named argument 'overlap'")
@MatthewRalston
MatthewRalston / webdocs.el
Created December 2, 2018 03:40
Add popover to HTML
;; Add this to your favorite html/jekyll configuration elisp file
;; Replace $IMG with the relative path to your websites image folder (e.g. img/)
(defun add-popover (link imagepath caption linktext)
"Generate an html popover.
-- Downloads an image file to your website/blog (etc.) image folder.
-- Generate a Bootstrap HTML popover link at the cursor position with caption.
"
(interactive "MImage link:\nFImagepath:\nMCaption:\nMLink text:\n")
(url-copy-file link imagepath)
@MatthewRalston
MatthewRalston / setup.py
Last active June 22, 2019 05:41
Example setup.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import io
import os
import sys
from shutil import rmtree
from setuptools import find_packages, setup, Command
@MatthewRalston
MatthewRalston / reader.py
Created June 22, 2019 14:44
Fasta + Bam file validation with S3 support
import os
import sys
import gzip
import io
import tempfile
from Bio import SeqIO, bgzf
import pysam
import boto3
# Logger
@MatthewRalston
MatthewRalston / trump-bot-twiml.xml
Last active November 9, 2020 15:45
TrumpBot TwiML
<Response>
<Say voice="alice">Hi, I'd like to say on behalf of democracy that your behavior is unpatriotic, undemocratic, and your allegations have all been debunked. Check the debunking megathread on Twitter by Isaac Saul. Your actions are shameful and undermine democracy. Furthermore, you're wasting Republican money by keeping this line open. So I will continue to waste your time. Someone has to listen to this stuff anyways. Trump failed. Trump is supported by racists and xenophobes. Trump has hurt American health. Trump has hurt the economy through trade wars. Trump is friends with dictators. Trump was installed through election interference. Trump is a sexual predator. And you are supporting him. Trump failed. Trump is supported by racists and xenophobes. Trump has hurt American health. Trump has hurt the economy through trade
@MatthewRalston
MatthewRalston / root_logger.py
Created November 19, 2020 16:05
Root_logger boto update
def get_root_logger(level):
levels=[logging.WARNING, logging.INFO, logging.DEBUG]
if level < 0 or level > 2:
raise TypeError("{0}.get_root_logger expects a verbosity between 0-2".format(__file__))
logging.basicConfig(level=levels[level], format="%(levelname)s: $(asctime)s %(funcName)s L%(lineno)s| %(message)s", datefmt="%Y/%m/%d %I:%M:%S")
root_logger = logging.getLogger(__name__)
for name in logging.Logger.manager.loggerDict.keys():
if ('boto' in name) or ('urllib3' in name) or ('s3' in name):
logging.getLogger(name).setLevel(logging.ERROR)
return root_logger
@MatthewRalston
MatthewRalston / peerj.tex
Created January 14, 2021 21:57
DCNorris' Peerj Latex template
\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$babel-lang$,$endif$$if(papersize)$$papersize$paper,$endif$$for(classoption)$$classoption$$sep$,$endfor$]{$documentclass$}
$if(fontfamily)$
\usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$}
$else$
\usepackage{lmodern}
$endif$
% Originally coded by Matt Ralston, Jan 14 2021
% Alex Ball's tutorial LaTeX code for making a bibLaTeX oxyear style (biblatex-oxref)
% Bibliography.
@MatthewRalston
MatthewRalston / cacheremove.hook
Created January 23, 2021 03:50 — forked from luukvbaal/cacheremove.hook
yay paccache hooks
[Trigger]
Operation = Remove
Type = Package
Target = *
[Action]
Description = Clearing cache...
When = PostTransaction
Exec = /home/<user>/.local/bin/tools/removehook
@MatthewRalston
MatthewRalston / sysinfo.txt
Created March 28, 2021 18:56
Arch linux Steam sysinfo
Computer Information:
Manufacturer: Unknown
Model: Unknown
Form Factor: Desktop
No Touch Input Detected
Processor Information:
CPU Vendor: AuthenticAMD
CPU Brand: AMD Ryzen Threadripper 3960X 24-Core Processor
CPU Family: 0x17