Skip to content

Instantly share code, notes, and snippets.

@pretorh
pretorh / changelog.sh
Last active August 15, 2021 07:05
Read changelog items from Android xml resource file
#!/usr/bin/env sh
# skip first few lines in file (xml setup)
# replace explicit new lines in strings with nothing (all newlines are on own line)
# remove leading spaces
# read up to first blank line
tail -n +6 app/src/main/res/values/changelog.xml | \
sed s'|\\n||g' | \
sed s'|^\ *||' | \
sed -e '/^$/,$d'
@pretorh
pretorh / README.md
Last active September 7, 2022 08:17
List missing sequentially numbered files

for example for photos from a camera (IMG_xxxx.JPG): ./missing-files-in-sequence.sh '*IMG_' 3409 '.jpg'

@pretorh
pretorh / stock.py
Created December 18, 2022 06:11
print stocks' last price in month as a csv string
"print stock prices as a csv string. see https://github.com/ranaroussi/yfinance for disclaimers"
import datetime
import sys
import yfinance as yf
def get_last_stock_price(stock, before):
"get the last price of the stock before the given date"
start = before - datetime.timedelta(days=7)
tick = yf.Ticker(stock)
@pretorh
pretorh / Bash TAP producer.md
Last active January 1, 2023 08:06
Bash test helper to general TAP output

shell script that can be sourced to have produce TAP output for test files

setup

  • create tests/setup.sh
  • create test files, ex tests/example.test.sh
  • run tests, and on success call ok <test name> or fail <test name> (or skip <test-name>)

do need to ensure that none of the tests output TAP related output (ex redirecting stdout)