Skip to content

Instantly share code, notes, and snippets.

View xjcoan's full-sized avatar

X Coan xjcoan

View GitHub Profile
@xjcoan
xjcoan / docker pg upgrade.md
Last active January 25, 2024 20:22
Upgrading Existing Postgres in Docker/Compose

Example done from an upgrade from 12.5 to 15.4

App is a Rails app, the default container user has limited access and no direct sql/psql access

  • build the image with current pg version & docker compose up
  • docker exec -it <NAME_OF_CONTAINER> pg_dump <NAME_OF_PRIMARY_DB> > db.out -U postgres
    • had issues doing pg_dumpall; wondering if the default postgres database interferred?
  • backup the data from the volume. I store in a tmp folder in the repo.
  • clear the folder your data is saved in or delete the volume
  • update the postgres version in docker compose, run docker compose build & up
@xjcoan
xjcoan / pytube_download.py
Last active February 10, 2022 14:47
pytube download videos from playlist
from pytube import Playlist
from pytube import YouTube
import re
def download_vids():
playlist = Playlist("PLAYLISTURL")
playlist._video_regex = re.compile(r"\"url\":\"(/watch\?v=[\w-]*)")
for url in playlist:
print(url)
yt = YouTube(url)
@xjcoan
xjcoan / kill docker commands
Last active November 6, 2019 14:40
Kill Docker containers and remove local builds
#kill active containers
docker kill $(docker ps -q)
# remove unused/old images
docker rmi $(docker images -f dangling=true -q)
@xjcoan
xjcoan / dismissBlackboardNotifications.js
Last active February 13, 2019 21:36
Dismiss all updates in Blackboard
// Dismiss all updates in Blackboard (on the update finder page)
// Best used when you let the updates pile up
// Find all dismiss buttons on the page and click them
let dismissButtons = document.querySelectorAll('[id*="dismiss_"]')
for (let i = 0; i < dismissButtons.length; i++) {
dismissButtons[i].click()
}
@xjcoan
xjcoan / Add Java JUnit Testing to Mac
Last active January 25, 2024 20:24
Install JUnit testing on a Mac environment (written for JUnit 4)
Download the latest version of JUnit here : <https://github.com/junit-team/junit4/wiki/Download-and-Install>
(I place mine in ~/java/ for this example)
Add the following lines to terminal conf. file (~/.zshrc)
`export JUNIT_HOME="$HOME/java"`
`export PATH="$PATH:$JUNIT_HOME"`
`export CLASSPATH="$CLASSPATH:$JUNIT_HOME/junit-4.12.jar:$JUNIT_HOME/hamcrest-core-1.3.jar"`
Alias junit in zshrc: `alias junit="java org.junit.runner.JUnitCore"`