Skip to content

Instantly share code, notes, and snippets.

@prot0man
prot0man / is_invalid_unicode.c
Last active April 8, 2023 18:44
Detects whether a string has any invalid utf-8 characters
// Stolen from chatgpt
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
bool has_invalid_utf8(const char *s)
{
const uint8_t *p = (const uint8_t *)s;
while (*p != '\0') {
if (*p < 0x80) {
@prot0man
prot0man / timedelta.c
Created February 22, 2023 01:28
Function that substracts days, hours, minutes, and seconds from the current system time in epoch seconds
#include <stdio.h>
#include <inttypes.h>
#include <time.h>
time_t days_to_seconds(uint32_t days)
{
return days * 24 * 60 * 60;
}
time_t hours_to_seconds(uint32_t hours)
@prot0man
prot0man / get_version.py
Last active March 3, 2022 03:10
Get Play Store Application Version
import requests
import urllib
import re
import argparse
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("getversion")
PLAY_URL_FMT_STR = "https://play.google.com/store/apps/details?id=%s&hl=%s&gl=%s"
@prot0man
prot0man / get_vendor.py
Last active July 25, 2023 04:11
Valheim vendor finder
"""
Locates the x and z coordinates of the Valheim vendor and prints them
to console.
"""
import struct
import sys
import argparse
#VENDOR_ID = b"Meteorite" # ashlands
#VENDOR_ID = b"Eikthyrnir" # first boss
@prot0man
prot0man / jenkins_downloader.py
Last active January 28, 2020 22:56
A Jenkins plugin and dependency downloader for offline Jenkins instances
"""
Attempts to download the specified jenkins plugin and all of its dependencies.
"""
import subprocess
import os
import re
import requests
import argparse
import logging
import zipfile