Skip to content

Instantly share code, notes, and snippets.

Avatar

glowinthedark glowinthedark

  • URLError: <urlopen error [Errno 8] nodename nor servname provided, or not known>
  • HTTPError: HTTP Error 403: Forbidden
View GitHub Profile
@glowinthedark
glowinthedark / get_gists.py
Last active Jan 14, 2022 — forked from leoloobeek/get_gists.py
Download all gists for a specific user
View get_gists.py
#!/usr/bin/env python3
#
# download all gists for a user, pass github user as first arg
# if the gists have already been downloaded before then update them
import json
import os
import re
import requests
View ttml2-to-srt.py
#!/usr/bin/env python3
# TTML2 to SRT subtitle converter
# USAGE:
# ttml2srt.py matrix.ttml2
import sys
import xml.etree.ElementTree as ET
from pathlib import Path
@glowinthedark
glowinthedark / html2text.py
Created Oct 25, 2021
HTML to plain text converter using python and lxml
View html2text.py
#!/usr/bin/env python3
# Convert HTML markup from a file or stdin to plain text.
#
# Usage:
# html2text.py
#!/usr/bin/env python3
import sys
@glowinthedark
glowinthedark / pyqt5_pdf_viewer.py
Last active Sep 20, 2021
Python simple PDF viewer using PyQt5 and mozilla's pdf.js
View pyqt5_pdf_viewer.py
#!/usr/bin/env python3
import sys
from pathlib import Path
from PyQt5.QtCore import *
from PyQt5.QtWebEngineWidgets import *
from PyQt5.QtWidgets import *
# REQUIREMENTS
@glowinthedark
glowinthedark / ffmpeg-hard-embed-srt-subtitles-resize540p.sh
Created Aug 21, 2021
FFMPEG: hard embed srt subtitles AND resize video
View ffmpeg-hard-embed-srt-subtitles-resize540p.sh
#!/usr/bin/env bash
## ffmpeg MUST be compiled with `--enable-libass`
if [ "$#" -lt 2 ]; then
printf "Usage:\n $(basename $0) MyVideo.mp4 MySubtitles.srt\n"
else
## embed SRT or ASS subtitles and downsample to 540p
ffmpeg -i "$1" -vf "subtitles=${2}, scale=540:-1" "${1%.mp4}-with-subs-540p.mp4"
fi
@glowinthedark
glowinthedark / subs_xml_to_srt.py
Created Aug 13, 2021
Python script to convert XML subtitles to SRT
View subs_xml_to_srt.py
#!/usr/bin/env python3
# XML to SRT subtitle converter
# USAGE:
# subs_xml_to_srt.py matrix.xml
import sys
from datetime import timedelta
import srt
@glowinthedark
glowinthedark / remove_duplicated_line_blocks.py
Created Aug 2, 2021
Remove multiline duplicated blocks from text files
View remove_duplicated_line_blocks.py
#!/usr/bin/env python3
# Remove multiline duplicated blocks from text files
import argparse
import os
import sys
from pathlib import Path
@glowinthedark
glowinthedark / migrate_vscode_to_vscodium.sh
Created Jul 19, 2021
Migrate all configs and extensions from VSCODE to VSCODIUM (MacOS)
View migrate_vscode_to_vscodium.sh
VSCODE_SETTINGS_DIR="$HOME/Library/Application Support/Code"
VSCODE_EXTENSIONS_DIR="$HOME/.vscode"
VSCODIUM_SETTINGS_DIR="$HOME/Library/Application Support/VSCodium"
VSCODIUM_EXTENSIONS_DIR="$HOME/.vscode-oss"
mkdir -p "$VSCODE_SETTINGS_DIR"
mkdir -p "$VSCODIUM_EXTENSIONS_DIR"
rsync --progress -av --exclude 'Backups' --exclude 'Cache' --exclude 'CachedData' --exclude 'CachedExtensionVSIXs' "${VSCODE_SETTINGS_DIR}/*" "${VSCODIUM_SETTINGS_DIR}/"
rsync --progress -av "${VSCODE_EXTENSIONS_DIR}/extensions" "${VSCODIUM_EXTENSIONS_DIR}/"
@glowinthedark
glowinthedark / disable_gapps_noroot.sh
Created Jul 18, 2021
Extract package names from a gapps installation ZIP.
View disable_gapps_noroot.sh
pm disable-user --user 0 com.android.chrome
pm disable-user --user 0 com.android.vending
pm disable-user --user 0 com.google.android.apps.books
pm disable-user --user 0 com.google.android.apps.docs
pm disable-user --user 0 com.google.android.apps.magazines
pm disable-user --user 0 com.google.android.apps.maps
pm disable-user --user 0 com.google.android.apps.messaging
pm disable-user --user 0 com.google.android.apps.nexuslauncher
pm disable-user --user 0 com.google.android.apps.photos
pm disable-user --user 0 com.google.android.apps.turbo
@glowinthedark
glowinthedark / RsyncBackup.js
Last active Sep 27, 2021
MacOS RsyncBackup — simplest possible rsync GUI for MacOS
View RsyncBackup.js
#!/usr/bin/osascript -l JavaScript
// ^^^^ COMMENT/REMOVE THIS SHEBANG IF RUNNING FROM SCRIPT EDITOR!!!!! ^^^^^^^^^^^
// The SHEBANG is only needed if the file is executable and is run from a terminal with `./RsyncBackup.js`
// 1. In MacOS Spotlight type 'Script Editor' and paste the code below
// 2. Click the top-left dropdown which says 'AppleScript' and select 'JavaScript'
// 3. Under menu File pick Export
// 4. In the Export dialog select File Format = Application
// 5. Save the app in /Applications