Skip to content

Instantly share code, notes, and snippets.

View jefftriplett's full-sized avatar
Living the dream

Jeff Triplett jefftriplett

Living the dream
View GitHub Profile
@jefftriplett
jefftriplett / python-django-postgres-ci.yml
Last active March 27, 2024 04:27
This is a good starting point for getting Python, Django, Postgres running as a service, pytest, black, and pip caching rolling with GitHub Actions.
name: CI
on: [push]
jobs:
test:
runs-on: ubuntu-latest
services:
@jefftriplett
jefftriplett / justfile-alfred.py
Last active March 19, 2024 17:31
Example Justfile Alfred Extension
"""
2021-2024 - Jeff Triplett
gist: https://gist.github.com/jefftriplett/e7d4eade12e30001065eed2636010772
pip install typer pydantic
Inspired/jumpstarted by: https://github.com/kjaymiller/Bunch_Alfred
"""
@jefftriplett
jefftriplett / docker-compose-project-name.yml
Last active March 4, 2024 10:34
Watchtower in Docker Compose
version: "3.3"
services:
web:
container_name: my-fancy-container
image: docker.pkg.github.com/jefftriplett/private-repo/private-project:latest
labels:
- "com.centurylinklabs.watchtower.enable=true"
- "com.centurylinklabs.watchtower.lifecycle.post-update='./post-update.sh'"
# https://medium.com/@dave1010/amazingly-alarming-autonomous-ai-agents-62f8a785e4d8
# https://github.com/dave1010/hubcap
# to run we need a few libraries:
# pip install rich typer
import os
import subprocess
import sys
import time
@jefftriplett
jefftriplett / demo-youtube-playlist-to-markdown.py
Last active January 1, 2024 11:18
A YouTube Playlist to Markdown automation
"""
----------------------------------------------------------------------------
Author: Jeff Triplett <https://github.com/jefftriplett>
Copyright (c) 2023 - Jeff Triplett
License: PolyForm Noncommercial License 1.0.0 - https://polyformproject.org/licenses/noncommercial/1.0.0/
----------------------------------------------------------------------------
1. To extract video URLs, titles, and descriptions from a YouTube playlist using Python, you can use the google-api-python-client library. Here's a step-by-step guide on how to do this:
Install the google-api-python-client library:
@jefftriplett
jefftriplett / 1_hello_in_vanilla_python.py
Last active December 8, 2023 19:22
What `hello.py world` looks like in vanilla python, as a django management command, and using the Typer library to show a basic example of using Python Types.
import sys
def main():
# Check if a name argument is provided
if len(sys.argv) > 1:
name = sys.argv[1]
else:
name = "World" # Default name if no argument is provided
print(f"Hello, {name}!")
@jefftriplett
jefftriplett / .pre-commit-config.yaml
Last active November 7, 2023 14:10
👕 How to get ruff to work with checking and formatting?
...
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.4
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
...
@jefftriplett
jefftriplett / tor.py
Last active May 22, 2023 09:10
Python Requests + Tor (Socks5)
"""
setup:
pip install requests
pip install requests[socks]
super helpful:
- http://packetforger.wordpress.com/2013/08/27/pythons-requests-module-with-socks-support-requesocks/
- http://docs.python-requests.org/en/master/user/advanced/#proxies
"""
@jefftriplett
jefftriplett / chatgpt.py
Last active March 1, 2023 20:14
ChatGPT API using their OpenAI Python library to generate a TailwindCSS template
# https://platform.openai.com/docs/guides/chat/chat-vs-completions
#
# python -m pip install openai
#
import openai
completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
@jefftriplett
jefftriplett / capture.py
Created October 27, 2018 15:44
Using Python 3, selenium, and headless chrome ala chromedriver to capture website screenshots
"""
To install:
# python requirements
$ pip install click selenium
# for headless chrome
$ brew install chromedriver
To use:
$ python capture.py https://revsys.com revsys.png