Skip to content

Instantly share code, notes, and snippets.

@ccerv1
ccerv1 / dependency_tree.md
Last active September 26, 2025 08:00
Workflow for mapping dependencies (LLM generated based on overview of current approach)

Decision Tree: Parsing Dependencies for a GitHub Repository

Objective

Produce a complete, source-attributable dependency set for a GitHub repo with clear provenance, direct vs transitive labeling (where feasible), and predictable fallbacks.

High-Level Flow

  1. Detect ecosystem(s) from repo files
@ccerv1
ccerv1 / get_contributors.py
Created July 16, 2025 18:20
Get monthly contributors from a collection using pyoso
from pyoso import Client
client = Client(YOUR_OSO_API_KEY)
target_collection = "your-collection-name"
start_date, end_date = "2025-01-01", "2025-07-31"
query = f"""
WITH target_artifacts AS (
SELECT DISTINCT artifact_id
@ccerv1
ccerv1 / sbom.py
Last active June 1, 2025 16:51
Lookup the SBOM for a given repo
# python sbom.py --analyze-test-repos
import requests
from typing import List, Dict, Tuple
import os
from datetime import datetime
GITHUB_TOKEN = os.getenv('GITHUB_TOKEN')
TEST_REPOS = [
@ccerv1
ccerv1 / oso_reward_lookup.py
Created April 3, 2025 20:40
Lookup S7 Retro Funding rewards for a project
from dotenv import load_dotenv
import os
import pandas as pd
from pyoso import Client
load_dotenv()
OSO_API_KEY = os.environ['OSO_API_KEY']
client = Client(api_key=OSO_API_KEY)
@ccerv1
ccerv1 / op_atlas_oso_queries.py
Created March 5, 2025 22:52
OP Atlas x OSO Test Queries
import requests
import json
from typing import Dict, Any, List
from requests.exceptions import HTTPError
import re
class OsoClient:
def __init__(self, endpoint: str = "https://www.opensource.observer/api/v1/graphql"):
self.endpoint = endpoint
self.headers = {
@ccerv1
ccerv1 / active_devs_by_repo.py
Created February 21, 2025 15:32
Identify all developers who have contributed to a set of repos
import csv
import re
import json
from datetime import datetime, timedelta
from githubkit import GitHub
from githubkit.exception import RequestFailed
GITHUB_TOKEN = "" # add your token here
github = GitHub(GITHUB_TOKEN)
@ccerv1
ccerv1 / text-on-image.py
Created January 14, 2025 21:08
text-on-image.py
from PIL import Image, ImageDraw, ImageFont
import os
def add_text_to_images(directory, output_directory, text):
# Create the output directory if it doesn't exist
os.makedirs(output_directory, exist_ok=True)
# Loop through all PNG files in the directory
for filename in os.listdir(directory):
print(filename)
@ccerv1
ccerv1 / fil_retropgf_fetcher.py
Last active May 5, 2024 22:26
FIL RetroPGF project application fetcher
import json
import requests
url = 'https://www.fil-retropgf.io/api/trpc/projects.search?input=%7B%22json%22%3A%20%7B%22limit%22%3A%201000%7D%7D'
response = requests.get(url)
data = response.json()
projects = data['result']['data']['json']
for p in projects:
"""
This script converts a properly formatted CSV file to a JSON list.
The CSV must have the `Project ID` in the first column and `OP Amount` in the second column.
The `Project ID` can be found at the end of the voting URL, eg:
https://vote.optimism.io/retropgf/3/application/0xd730a803f5714c7f1b5e518edd57121d1b64c8c91cf611ae5f226cf9bb4b963f
https://round3.optimism.io/projects/0xd730a803f5714c7f1b5e518edd57121d1b64c8c91cf611ae5f226cf9bb4b963f
`Project ID` = 0xd730a803f5714c7f1b5e518edd57121d1b64c8c91cf611ae5f226cf9bb4b963f
@ccerv1
ccerv1 / RPGF3_projects_on_EAS.py
Created November 4, 2023 09:06
Approved RPGF3 projects on EAS
import json
import os
import requests
PROJECT_APP_SCHEMA = "0x76e98cce95f3ba992c2ee25cef25f756495147608a3da3aa2e5ca43109fe77cc"
PROJECT_REVIEW_SCHEMA = "0xebbf697d5d3ca4b53579917ffc3597fb8d1a85b8c6ca10ec10039709903b9277"
REVIEWER_ADDRESS = "0x621477dBA416E12df7FF0d48E14c4D20DC85D7D9"
DATA_EXPORT_JSON = "rpgf3_applicant_data.json"