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 / 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

Setup nut and netdata on Ubuntu

In this document, I will explain how to setup nut (Network UPS Tools) on Ubuntu 18.04 and 20.04.

It is basically the next chapter of my previous gist, Upgrade nut on Ubuntu 18.04.

I'll only document USB connected UPS and not the other supported connection modes.

Install required dependencies

@glowinthedark
glowinthedark / telegram_bot_api_curl.cpp
Created January 4, 2024 20:43 — forked from ozlb/telegram_bot_api_curl.cpp
Telegram bot API via curl
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <time.h>
#include <ctype.h>
#include <string>
//https://github.com/DaveGamble/cJSON
#include "cJSON.h"