Skip to content

Instantly share code, notes, and snippets.

@amywieliczka
amywieliczka / infrastructure-structure.yaml
Created April 3, 2024 19:52
PAD Infrastructure Proposal
PAD-Infrastructure-Repo:
config # this is the sceptre config directory, each directory
# represents a (sceptre-ism) stack group, and each file
# represents a (sceptre and cloudformation-ism) stack
# within that group
config.yml # this is the root config file, enforcing pad-wide
# defaults like:
# project_name: pad
# region: us-west-2
@amywieliczka
amywieliczka / lambda_function.py
Created July 10, 2023 23:41
Cognito-MWAA Connector
import json
import urllib.request
import urllib.parse
import boto3
# This lambda function is configured in the AWS console to have a "function URL"
# a dedicated https endpoint for this function. In this configuration, the
# event parameter is a dict describing the request made to the function URL
def lambda_handler(event, context):
@amywieliczka
amywieliczka / cloudfront-distros.md
Last active July 5, 2023 20:58
DSC CloudFront Distros

Cloudfront Distributions in DSC AWS Account

Distro ID Description Alternate Domain Names Last Modified Date
E1RSO6N0RTXH8X calisphere.org calisphere.org July 3, 2023 at 8:19:58 PM UTC
EA4P9EMQ9TNK0 calisphere-test.cdlib.org calisphere-test.cdlib.org May 24, 2023 at 5:24:22 PM UTC
E215A3D7QO74OG this may not be needed thumbnails.calisphere.org May 16, 2023 at 11:45:55 PM UTC
E2U9T45UP3ZOJ8 real IIIF June 1, 2022 at 4:29:03 PM UTC
E2BKF7XHHT31S3 legacy OAC video av-cdn.calisphere.org December 8, 2021 at 7:46:23 PM UTC
E1HBH81MROL4M5 legacy redirect www.calisphere.cdlib.org, calisphere.cdlib.org December 8, 2021 at 7:45:03 PM UTC
@amywieliczka
amywieliczka / csv_read.py
Last active April 4, 2022 23:27
Reading a csv file
import csv
def read_csv_file_into_array(filename):
csv_file = open(filename)
lines = csv.reader(csv_file, delimiter=',')
data = []
for row_num, row in enumerate(lines):
if row_num == 0:
continue
@amywieliczka
amywieliczka / lambda_function.py
Last active April 28, 2020 21:17
async fetching with python
import asyncio
import aiohttp
import aioboto3
import boto3
import xmltodict
import json
import time
async def build_fetchRequest(oai, resumptionToken):
try:
@amywieliczka
amywieliczka / CreateGoogleLog.py
Created October 29, 2019 19:18
Strips non-google log entries from access logs in an s3 bucket
import boto3
import uuid
from urllib.parse import unquote_plus
import csv
import socket
import re
import gzip
s3_client = boto3.client('s3')
googlebot_whitelist_ip = []
from pyspark.sql import SparkSession
def grade_collection(id):
untitledItemsDF = spark.sql(f"SELECT COUNT(*) FROM calisphere \
WHERE array_contains(collection_url, 'https://registry.cdlib.org/api/v1/collection/{id}/') \
AND array_contains(title, 'Untitled')")
totalItemsDF = spark.sql(f"SELECT COUNT(*) FROM calisphere \
WHERE array_contains(collection_url, 'https://registry.cdlib.org/api/v1/collection/{id}/')")
untitledItemsDF.show() / totalItemsDF.show()
@amywieliczka
amywieliczka / banner-img.png
Last active November 19, 2015 21:37
Banner for the old Calisphere
banner-img.png