Skip to content

Instantly share code, notes, and snippets.

View glowinthedark's full-sized 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 / aliexpress_order_history_export_csv.js
Last active September 23, 2024 12:28
AliExpress Order History export to CSV
function formatCSVValue(value) {
value = String(value);
// If the value contains a comma, newline, or quote, it needs to be quoted
if (/[,\"\n]/.test(value)) {
// Escape quotes by doubling them
value = value.replace(/"/g, '""');
// Wrap the value in quotes
value = `"${value}"`;
}
@glowinthedark
glowinthedark / yt-dlp-local-m3u8-playlist-download-bullk.sh
Last active September 24, 2024 16:19
yt-dlp download from local m3u8 playlist files
#!/usr/bin/env bash
find . -iname "*.m3u*" -exec yt-dlp --enable-file-urls file://$PWD/{} \;
# same as above with subshell
find * -iname '*.m3u*' -print -exec sh -c 'yt-dlp --enable-file-urls "file://$PWD/${1}"' _ {} \;
@glowinthedark
glowinthedark / macos_check_pytorch_metal_support.py
Created June 20, 2024 18:37
check if pytorch can use macos apple silicon chip metal support
#!/usr/bin/env python3
import torch
def is_metal_enabled():
"""Checks if Metal acceleration is enabled for PyTorch."""
# Check if MPS backend is available on the system
if not torch.backends.mps.is_available():
print("MPS backend is not available on this system.")
return False
package com.legbehindneck;
import java.io.IOException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.core.JsonPointer;
public class Main {
public static void main(String[] args) {
@glowinthedark
glowinthedark / image-gallery-generator-with-thumbnails-v2.md
Last active March 15, 2024 12:30
Script to generate a static HTML image gallery file with thumbnail generation using imagemagick and keyboard navigation; support for images, audio, video
@glowinthedark
glowinthedark / image-gallery-generator-with-thumbnails.py
Last active February 14, 2024 20:32
Script to generate a static HTML image gallery file with thubnails generation using imagemagick https://gist.github.com/glowinthedark/75ae05cb0052cc6c99697278bb2d9f7d
We couldn’t find that file to show.
@glowinthedark
glowinthedark / image-gallery.py
Last active February 11, 2024 17:34
Script to generate a static HTML image gallery file
@glowinthedark
glowinthedark / json_remove_null_keys.js
Created February 10, 2024 09:44
remove empty or null keys from JSON file; print to stdout or to file with `-o output.json`; to beautify output JSON add the `-f` flag
#!/usr/bin/env node
const fs = require('fs');
// Function to remove null keys from an object
function removeEmpty(obj) {
Object.keys(obj).forEach(function(key) {
if (obj[key] && typeof obj[key] === 'object') {
removeEmpty(obj[key]);
} else if (obj[key] === '' || obj[key] === null) {
@glowinthedark
glowinthedark / immich-orphan-cleaner.py
Created February 6, 2024 20:14 — forked from sircharlo/immich-orphan-cleaner.py
I modified @T-One 's excellent Gist somewhat for my purposes: I had alot of orphaned files in my Immich instance! I was getting impatient and wanted to see progress and ETA. Here it is in case anyone is impatient like me lol; all credit goes to @T-One though. Original Gist: https://gist.github.com/T-One/c857005e58286149914ad38f24a891e1
#!/usr/bin/env python3
# Note: you might need to run "pip install halo tabulate tqdm" if these dependencies are missing on your machine
import argparse
import json
import requests
from datetime import datetime
from halo import Halo