Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Riina AlexRiina

View GitHub Profile
@AlexRiina
AlexRiina / deoptional.py
Last active Aug 23, 2020
remove Optional[] annotation wrappers where redundant
View deoptional.py
"""
Optional[] is implied in arguments when the default value is None. Leaving it
out is a matter of personal preference and I prefer to leave it out in favor of
shorter lines with not obvious behavior.
This script removes unnecessary Optional declarations in arguments.
WARNING: this updates files in-place.
"""
@AlexRiina
AlexRiina / anki_similarity.py
Created Jul 10, 2020
Find duplicate notes in Anki
View anki_similarity.py
"""
Text clustering of Anki cards to find duplicated concepts. Prints handful of notes and then a list of similar notes.
```
pip install anki_sqlalchemy bs4 sklearn
cp ${ANKI_DATABASE:?replace me} backup.db
python anki_similarity.py
```
"""
@AlexRiina
AlexRiina / hospitalizations_and_viral_rna.csv
Last active May 27, 2020
sewer SARS-CoV-2 RNA vs hospital admissions
View hospitalizations_and_viral_rna.csv
date viral_rna hospitalizations
19/03/2020 5 8
20/03/2020 5 10
21/03/2020 25 3
22/03/2020 0 8
23/03/2020 50 10
24/03/2020 30 12
25/03/2020 80 8
26/03/2020 80 10
27/03/2020 85 17
@AlexRiina
AlexRiina / codemapper.py
Last active Feb 3, 2020
Utility for grouping files by codeower and generating commands
View codemapper.py
"""
Utility for grouping files by codeower and generating commands
"""
import argparse
import re
import shlex
from collections import defaultdict
from glob import fnmatch
from typing import DefaultDict, FrozenSet, Iterator, Optional, Set, Tuple
@AlexRiina
AlexRiina / noqaer.py
Last active Jan 15, 2022
automatically ignore lines from flake8
View noqaer.py
"""
Add `# noqa: FXXX` comments to all lines with violations from flake8
"""
# MIT License
#
# Copyright (c) 2022 Alex Riina
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@AlexRiina
AlexRiina / overlay-exif.py
Last active Feb 3, 2019
Overlay photo speed, aperture, and ISO
View overlay-exif.py
"""
Add legend with exposure speed, aperture, and ISO to top left of jpeg photo exif data.
Copies original exif data into output file.
Requires Python3.6, and some version of Pillow
"""
import argparse
from PIL import Image, ImageDraw, ImageColor, ImageFont
from PIL.ExifTags import TAGS, GPSTAGS
@AlexRiina
AlexRiina / publish.sh
Last active Dec 1, 2017
Publish Jekyll posts using simple git workflow
View publish.sh
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# Move jekyll draft to post, timestamp it, and start to commit it
# Useage:
# $ ./publish.sh _draft/cool-article.markdown
# moves the draft to _posts/2017-12-01-cool-article.markdown
# inserts the published date into the "front matter"
@AlexRiina
AlexRiina / walmart_mvp.html
Created Nov 3, 2017
Walmart BuyNow MVP with Javascript API
View walmart_mvp.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.slim.js"></script>
</head>
<body>
<div class="walmart-buy-now" data-publisherid="PD0Em23B4ME" data-item-walmartid="45698070|2,631|1" data-color="orange" data-size="standard"></div>
@AlexRiina
AlexRiina / deeplink_buy_now.html
Last active Nov 6, 2017
Walmart Deeplink Api
View deeplink_buy_now.html
@AlexRiina
AlexRiina / glucometer_export.py
Last active Jul 25, 2021
Export FreeStyle Lite data from serial USB cable to CSV
View glucometer_export.py
""" Extract FreeStyle Lite data from serial USB cable to CSV.
Defaults for Linux or MacOS systems """
import argparse
import glob
import os
import re
import serial
from csv import writer