Skip to content

Instantly share code, notes, and snippets.

View mbstacy's full-sized avatar

Mark Stacy mbstacy

  • Harvard University
  • Boston, MA
  • 15:55 (UTC -04:00)
View GitHub Profile
library(ellmer)
library(httr2)
# Bypass AWS credential requirements - routes through Harvard Apigee gateway
Sys.setenv(
HUIT_API_KEY = Sys.getenv("APIGEE_API_KEY"),
AWS_ACCESS_KEY_ID = "placeholder",
AWS_SECRET_ACCESS_KEY = "placeholder",
AWS_REGION = "us-east-1"
)
"""
Strands Agent with Web Search - Harvard Holiday Schedule Example
Uses the Strands Agents SDK to create an AI agent backed by Claude on AWS Bedrock
(via Harvard's Apigee gateway) with a local web_search tool powered by DDGS.
The agent searches the web for Harvard's current holiday schedule and writes
the results to a markdown file.
Install
Docs: https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-meta.html
Model: meta.llama3-1-8b-instruct-v1:0
1. Original Parameters
prompt:{
"modelId": "meta.llama3-1-8b-instruct-v1:0",
"contentType": "application/json",
"accept": "application/json",
"body": {"prompt":"Answer the following question concisely in English (no code)with either '##Yes##' OR '##No##' and avoid extra details.Is Boston in the United states?","temperature":0.7}
@mbstacy
mbstacy / anchorLinks.js
Last active March 5, 2024 16:34
Apigee Portal Anchor Links and Overview Navigation

Data Lake API

The CU Boulder Library uses the Cybercommons framework to access the data lake API. The backend database uses Mongo Database as the data document store. The query and aggregation pipeline leverages the MongoDB Query language. The language is passed through URL parameters using the JSON format.

Basic Parameters

- default format is a web presentation with clickable links 
  ?format=json
  ?format=xml

?format=yaml

import PyPDF2
from sys import argv
def getTextPdf(filename):
'''
Reads entire file and returns text
'''
#open allows you to read the file
with open(filename,'rb') as pdfFileObj:
#The pdfReader variable is a readable object that will be parsed
@mbstacy
mbstacy / EKSvsEC2.md
Last active November 22, 2025 13:37
EKS vs EC2 Kubernetes Costs

Kubernetes Cost Comparison EC2 vs EKS

EKS Kubernetes

AWS EKS service provides the Kubernetes control plane. Price for EKS Service is $0.20 per hour / cluster.

EKS Use Case Monthly Cost

Three clusters with four worker nodes.

import pandas as pd
#error file generated in bash: $cat dm-ir.log | awk '{print $5,$8}' > errors2.txt
err=pd.read_csv('errors2.txt',delim_whitespace=True,header=None )
err.columns=['error_type','context_key']
err=err.drop_duplicates()
#Main inventory
df=pd.read_csv('data/inventory-2019-05-30.csv',converters={i: str for i in range(0, 83)})
df= df.drop_duplicates()
import requests, json, os
from sys import argv
catalog_url = "https://libapps.colorado.edu/api/catalog/data/catalog/cuscholar.json"
headers={"Content-Type":"application/json","Authorization":"Token {0}".format(os.getenv('LIBAPPS_APITOKEN'))}
def get_cuscholar_data():
#query='query={"filter":{},"projection":{"data_files.s3.key":1,"title":1,"_id":0}}'
#url = "{0}?page_size=100&{1}".format(catalog_url,query)