Skip to content

Instantly share code, notes, and snippets.

View jlumbroso's full-sized avatar

Jérémie Lumbroso jlumbroso

View GitHub Profile
@jlumbroso
jlumbroso / publish_to_gh_pages.sh
Created February 14, 2024 03:06
Script to push a folder (such as the output of a static website generator) directly to a branch (such as "gh-pages") of a repository.
#!/bin/bash
###################################################################################
# Automatic gh-pages site updater
#
# Author: Jérémie Lumbroso <lumbroso@seas.upenn.edu>
# Date: February 13, 2024
#
# This script automates updating a GitHub Pages site hosted on the gh-pages branch
# of a repository. It takes a local folder containing the static site content and
@jlumbroso
jlumbroso / combine_for_model.py
Created February 12, 2024 22:15
A Python script to concatenate source code to send to a foundational model as a prompt.
#!/usr/bin/env python3
"""
combine_for_model.py
Author: Jérémie Lumbroso <lumbroso@seas.upenn.edu>
Date: July 25, 2023
Version: 1.0
Description:
@jlumbroso
jlumbroso / decrypt_all_pdfs.py
Created November 3, 2023 21:59
A Python script to recursively decrypt PDF files using `qpdf --decrypt`, handling files without passwords and overwriting the originals if decryption is successful.
#!/usr/bin/env python3
"""
decrypt_all_pdfs.py
Author: Jérémie Lumbroso <lumbroso@seas.upenn.edu>
Date: November 3, 2023
Description:
This script recursively finds all PDF files within a specified directory path,
checks if they are encrypted (without a password), and attempts to decrypt them
@jlumbroso
jlumbroso / unicode_logic_to_latex.py
Created October 23, 2023 19:56
Snippet to convert between Unicode and LaTeX representations of logical propositions.
import re
_LATEX_POST_ENTITY = "{}"
# Mapping of Unicode characters to LaTeX expressions
MAPPING = {
"∀": "\\forall",
"∃": "\\exists",
"→": "\\rightarrow",
"↔": "\\leftrightarrow",
@jlumbroso
jlumbroso / codePost-compute-grade-from-file-contents.py
Created May 12, 2023 23:33
codePost snippet to automatically compute a grade based on extracting data from one of the files of the submissions (such as an auto-grader output), finalize all submissions of an assignment, and automatically add a comment that sets the grade of the submission
import re
import codepost
# ================================================================
# VARIABLE PARAMETERS
# get the API key here: https://codepost.io/settings
API_KEY = "... see above where to get this ..."
COURSE_NAME = "COS126"
COURSE_TERM = "S2023"
ASSIGNMENT = "Atomic"
@jlumbroso
jlumbroso / codePost-output-submission-dates.py
Last active February 20, 2023 23:14
codePost snippet to programmatically dump all the submission times (in UTC) for all submissions of an assignment in a CSV file
import codepost
# fancy progress bar if available
try:
from tqdm import tqdm
except ModuleNotFoundError:
# dummy replacement that does nothing
tqdm = lambda x: x
# variable parameters
@jlumbroso
jlumbroso / codePost-fix-partners.py
Last active December 1, 2022 03:18
codePost snippet to programmatically reassign students/partnerships on already-uploaded submissions
import codepost
# variable parameters
# get the API key here: https://codepost.io/settings
API_KEY = "... see above where to get this ..."
# mapping a codePost ID to students
# (note that this could be loaded from a CSV file)
partnerships = {
65490: ["student1@princeton.edu", "student2@princeton.edu"],
@jlumbroso
jlumbroso / codePost-assign-graders.py
Created November 28, 2022 01:51
codePost snippet to assign graders to specific submissions, given a CSV file
import codepost
# variable parameters
# get the API key here: https://codepost.io/settings
API_KEY = "... see above where to get this ..."
COURSE_NAME = "COS126"
COURSE_TERM = "F2022"
ASSIGNMENT = "Final Project Proposal PDF"
DEFAULT_TEACHER = "pparedes@princeton.edu"
@jlumbroso
jlumbroso / codePost-recompute-grades.py
Created September 17, 2022 16:50
codePost snippet to recompute the grades of all submissions of an assignment
import codepost
# fancy progress bar if available
try:
from tqdm import tqdm
except ModuleNotFoundError:
# dummy replacement that does nothing
tqdm = lambda x: x
# variable parameters
@jlumbroso
jlumbroso / gh_clone.sh
Created May 23, 2022 14:02
Introduces a command `gh` to clone your repos in a few keystrokes
# Fast command-line cloning of GitHub repos
#
# usage: add to your .bashrc or .zsh like this:
# source gh_clone.sh
# replace 'jlumbroso' with your own GitHub username
export GITHUB_USERNAME="jlumbroso"
# one-line repo clone
# gh <repo> [<-- will default to username=${GITHUB_USERNAME}]