Skip to content

Instantly share code, notes, and snippets.

View AlexRiina's full-sized avatar

Alex Riina AlexRiina

View GitHub Profile
// jQuery Plugin (Change Type)
(function ($) {
$.fn.cryptForm = function (key, toCryptSel) {
var form = $(this);
var braintree = Braintree.create(key);
form.submit(function () {
form.find(toCryptSel).each(function () {
this.type = 'password';
$(this).val(braintree.encrypt($(this).val()));
@AlexRiina
AlexRiina / walmart_mvp.html
Created November 3, 2017 19:33
Walmart BuyNow MVP with Javascript API
<!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 November 6, 2017 16:34
Walmart Deeplink Api
@AlexRiina
AlexRiina / publish.sh
Last active December 1, 2017 15:06
Publish Jekyll posts using simple git workflow
#!/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 / overlay-exif.py
Last active February 3, 2019 20:31
Overlay photo speed, aperture, and ISO
"""
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 / codemapper.py
Last active February 3, 2020 18:51
Utility for grouping files by codeower and generating commands
"""
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 / hospitalizations_and_viral_rna.csv
Last active May 27, 2020 05:07
sewer SARS-CoV-2 RNA vs hospital admissions
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 / anki_similarity.py
Created July 10, 2020 21:37
Find duplicate notes in Anki
"""
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 / deoptional.py
Last active August 23, 2020 23:02
remove Optional[] annotation wrappers where redundant
"""
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 / glucometer_export.py
Last active July 25, 2021 06:24
Export FreeStyle Lite data from serial USB cable to CSV
""" 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