This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Convert markdown to pdf with same filename and open the pdf | |
for file in "$@"; do | |
filename="${file%.*}" | |
extension="${file##*.}" | |
echo "$file" "->" "$filename".pdf | |
pandoc -f markdown -t pdf -o "$filename".pdf "$file" | |
open "$filename".pdf | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os # Import the os module for working with environment variables | |
import openai # Import the OpenAI module for working with the OpenAI API | |
import json # Import the json module for working with JSON data | |
import sys # Import the sys module for working with command-line arguments | |
openai.api_key = os.getenv("OPENAI_API_KEY") # Set the OpenAI API key from an environment variable | |
filename = sys.argv[1] # Get the filename from the command-line arguments | |
with open(filename, "r") as file: # Open the file in read-only mode |
OlderNewer