Skip to content

Instantly share code, notes, and snippets.

View dbrant's full-sized avatar
🍣
Kickin' it

Dmitry Brant dbrant

🍣
Kickin' it
View GitHub Profile
@dbrant
dbrant / dongle.asm
Last active February 6, 2026 02:23
Disassembly of hardware dongle code
0800:0000 1E PUSH DS // save ds, since we'll be setting it to 0
0800:0001 33C9 XOR CX,CX // cx = 0
0800:0003 8ED9 MOV DS,ECX // ds = 0
// Detect parallel port address (from bios data area)
0800:0005 BB0804 MOV BX,0408
0800:0008 B104 MOV CL,04 // try up to 4 addresses
0800:000A 8B17 MOV DX,WORD PTR [BX]
0800:000C 0BD2 OR DX,DX
0800:000E 7506 JNE 0016 // if (DX != 0) break;
@dbrant
dbrant / onthisday.py
Created January 22, 2025 16:26
Retrieve the number of on-this-day events from a given language Wikipedia.
# Retrieve the number of on-this-day events from a given language Wikipedia,
# iterated over all days of all months of the year.
# usage: onthisday.py [en|de|ru|...]
#
# Dmitry Brant, 2025
import sys
import requests
daysPerMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
@dbrant
dbrant / convert_writenow.py
Created January 5, 2025 15:41
Using LibreOffice, convert all Macintosh WriteNow files inside a directory (recursively) into Docx format.
import os
import subprocess
def is_writenow_file(filepath):
with open(filepath, 'rb') as file:
header = file.read(8)
return header == bytes([0x57, 0x72, 0x69, 0x74, 0x65, 0x4E, 0x6F, 0x77])
def convert_files(source_directory, target_directory):
# Traverse the directory
@dbrant
dbrant / convert_wpd.py
Created January 5, 2025 15:37
Using LibreOffice, convert all WordPerfect files inside a directory (recursively) into Docx format.
import os
import subprocess
def is_wordperfect_file(filepath):
with open(filepath, 'rb') as file:
header = file.read(4)
return header == bytes([0xFF, 0x57, 0x50, 0x43])
def convert_files(source_directory, target_directory):
# Traverse the directory
@dbrant
dbrant / validate_jsonschema.py
Last active January 4, 2024 17:52
Validate JSON from a URL against a Json Schema from another URL.
# Make sure to install 'jsonschema' as well as any validator packages,
# such as 'rfc3339-validator', that are used by the schema.
import json
import sys
import urllib.request
import urllib.error
import jsonschema
def main():
# Dmitry Brant, 2023
import requests
def cleanupForCsv(s):
return s.replace("\"", "”").replace("'", "’").replace("\r", " ").replace("\n", "")
apiBaseUrl = "https://www.wikidata.org/w/api.php?format=json&formatversion=2&"
continueStr = ""
userEditCounts = {}
# Dmitry Brant, 2023
import requests
import urllib
def parseDescription(content):
description = ""
sStart = content.lower().find("{{short description|")
if sStart != -1:
sEnd = content.find("}}", sStart)
@dbrant
dbrant / DeleteEmptySpam.gs
Last active May 2, 2022 00:25
Google Apps Script for deleting empty spam messages from Gmail
function deleteMessageIfEmpty() {
var threads = GmailApp.search('is:unread in:inbox')
for (const thread of threads) {
const messages = thread.getMessages()
if (messages.length != 1) { continue; }
const msg = messages[0];
const words = msg.getPlainBody().trim().split(" ");
@dbrant
dbrant / MacRetrospectTapeBackup.txt
Created April 20, 2022 13:50
Tape backup format for Mac Retrospect v??
(Dmitry Brant, Apr 2022)
Recently I came across a backup tape (an AIT-3 100GB tape) that was written with a format
I didn't recognize. The only thing I knew is that it came from a Mac workstation, which means
it was likely written using Retrospect, which was a popular backup tool at the time.
This is the result of my reverse-engineering effort to get the contents out of this archive.
------------------
This backup format is composed of a sequence of blocks which use FourCC-style formatting.
(All data is big-endian. Dates are formatted as seconds since Jan 1 1904.)
@dbrant
dbrant / playstorereport.py
Last active April 28, 2022 12:55
Download statistics from Google Play Store console using Google Cloud API.
import csv
from google.cloud import storage
# To install Google Cloud dependency:
# pip install --upgrade google-cloud-storage
# Private key to use for authenticating our service account:
key_file = 'playStoreAccessKey.json'
# Bucket name for our data (copy from Play Store Console):