Skip to content

Instantly share code, notes, and snippets.

View pamelafox's full-sized avatar

Pamela Fox pamelafox

View GitHub Profile
@pamelafox
pamelafox / Dockerfile
Created June 16, 2023 23:43
Dockerfile for single Python version
FROM python:3.11.2-slim
# Install Git
RUN apt-get update && apt-get install -q -y --fix-missing \
git && \
rm -rf /var/lib/apt/lists/*
#[Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
COPY .devcontainer/requirements.txt /tmp/pip-tmp/
RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
@pamelafox
pamelafox / links.md
Last active June 9, 2023 21:22
SF Reactor AI Fair
@pamelafox
pamelafox / axe.yaml
Created April 7, 2023 22:16
A workflow that uses pytest + playwright to run Axe on Flask routes, then converts the results to SARIF and uploads to Github CodeQL tab
name: Axe analysis
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
@pamelafox
pamelafox / gh_api.sh
Created April 7, 2023 22:14
Test Github API CodeQL endpoint with sarif upload
response=$(gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/pamelafox/pamelafox-site/code-scanning/sarifs \
-f commit_sha='d9b327639e4e84337b9edd297a8cfb098bbfeefa' \
-f ref='refs/heads/a11y' \
-f sarif=$(gzip -c src/tests/axe_results.sarif | base64 -b 0))
url=$(echo $response | grep -o '"url": *"[^"]*"' | cut -d '"' -f 4)
@pamelafox
pamelafox / opcodes_parser.py
Created February 20, 2023 00:21
Parse opcodes
opcode_links = {}
file = open("Include/patchlevel.h", "r")
for line in file.readlines():
if line.startswith("#define PY_VERSION"):
full_version = line.split()[2].strip('"')
major_version = full_version.rsplit(".", 1)[0]
break
file.close()
@pamelafox
pamelafox / country_capitals.json
Last active March 29, 2023 12:25
country_capitals.json
[{"id":"AD","country":"Andorra","capital":"Andorra la Vella","lat":42.5063174,"lng":1.5218355},
{"id":"AF","country":"Afghanistan","capital":"Kabul","lat":34.5553494,"lng":69.207486},
{"id":"AG","country":"Antigua and Barbuda","capital":"St. John's","lat":17.1274104,"lng":-61.846772},
{"id":"AL","country":"Albania","capital":"Tirana","lat":41.3275459,"lng":19.8186982},
{"id":"AM","country":"Armenia","capital":"Yerevan","lat":40.1872023,"lng":44.515209},
{"id":"AO","country":"Angola","capital":"Luanda","lat":-8.8146556,"lng":13.2301756},
{"id":"AR","country":"Argentina","capital":"Buenos Aires","lat":-34.6036844,"lng":-58.3815591},
{"id":"AT","country":"Austria","capital":"Vienna","lat":48.2081743,"lng":16.3738189},
{"id":"AU","country":"Australia","capital":"Canberra","lat":-35.2801903,"lng":149.1310038},
{"id":"AZ","country":"Azerbaijan","capital":"Baku","lat":40.4092617,"lng":49.8670924},
@pamelafox
pamelafox / calc_bnf_part1.py
Created April 22, 2022 05:43
BNF-based Calculator interpreter, 3 ways
# A Simple Calculator Using Scheme Syntax.
# Implemented using the Lark package in Python.
import sys
from lark import Lark
grammar = """
?start: calc_expr
?calc_expr : NUMBER | calc_op
@pamelafox
pamelafox / animals.sql
Created November 22, 2021 21:11
Animals SQL
CREATE TABLE animals (name TEXT, legs INTEGER, weight INTEGER);
INSERT INTO animals VALUES ("dog", 4, 20);
INSERT INTO animals VALUES ("cat", 4, 10);
INSERT INTO animals VALUES ("ferret", 4, 10);
INSERT INTO animals VALUES ("parrot", 2, 6);
INSERT INTO animals VALUES ("penguin", 2, 10);
INSERT INTO animals VALUES ("t-rex", 2, 12000);