Skip to content

Instantly share code, notes, and snippets.

View tdulcet's full-sized avatar

Teal Dulcet tdulcet

View GitHub Profile
@tdulcet
tdulcet / autofix.py
Last active January 28, 2024 11:16
Interactively apply Ruff autofixes per rule and optionally commit the changes.
#!/usr/bin/env python3
# Teal Dulcet
# Interactively apply Ruff autofixes per rule and optionally commit the changes
# Also see: https://github.com/astral-sh/ruff/issues/4361
# Run: python3 autofix.py [Ruff args]...
import json
import os
@tdulcet
tdulcet / makemake.sh
Last active October 22, 2023 15:55
Ernst W. Mayer's makemake.sh script for Mlucas v21 posthumously released. Includes support for building Mfactor.
#!/bin/bash
# EWM: This is a makefile-only cutdown of Teal Dulcet's much more extensive Mlucas install/build/tune
# script, available at https://raw.github.com/tdulcet/Distributed-Computing-Scripts/master/mlucas.sh ;
# he does not explicitly use the GPL boilerplate as below, but assures me his version is GPL-covered.
################################################################################
# #
# (C) 2021 by Ernst W. Mayer and Teal Dulcet. #
# #
@tdulcet
tdulcet / gimps_status.py
Last active March 10, 2024 12:28
Read Prime95/MPrime, Mlucas, GpuOwl, CUDALucas, CUDAPm1, mfaktc and mfakto save/checkpoint files and display status of them. Supports both Python 2 and 3.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Read Prime95/MPrime, Mlucas, GpuOwl, CUDALucas, CUDAPm1, mfaktc and mfakto save/checkpoint files and display status of them."""
# Adapted from: https://github.com/sethtroisi/prime95/blob/py_status_report/prime95_status.py
# Copyright (c) 2021-2023 Seth Troisi and Teal Dulcet
#
# This program is free software: you can redistribute it and/or modify
@tdulcet
tdulcet / factor.py
Created July 30, 2023 10:34
Python port of the factor command from GNU Coreutils. Supports both Python 2 and 3.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Teal Dulcet
# Run: python3 factor.py <numbers(s)>...
# Run: python2 factor.py <numbers(s)>...
# python3 -X dev factor.py {2..100}
# diff <(factor {2..100}) <(python3 -X dev factor.py {2..100})
@tdulcet
tdulcet / google.py
Last active May 9, 2023 10:59
Generate word list from Google Ngram data for 1-grams. Saves results to a TSV file.
#!/usr/bin/env python3
# Teal Dulcet
# Run: python3 google.py <input TSV file(s)>... <output TSV file>
# export LC_ALL=C.UTF-8
# sudo apt update
# sudo apt install hunspell-tools
@tdulcet
tdulcet / wiktionary.py
Last active May 9, 2023 10:55
Generate word list from Wiktionary JSON extraction. Saves results to a TSV file.
#!/usr/bin/env python3
# Teal Dulcet
# Run: python3 wiktionary.py <input JSON file> <output TSV file>
# export LC_ALL=C.UTF-8
# sudo apt update
# sudo apt install hunspell-tools
@tdulcet
tdulcet / performance.sh
Last active January 31, 2024 16:08
Compares the performance of GpuOwl commits/versions with multiple exponents. Saves the results in a `bench.csv` file.
#!/bin/bash
# Copyright © 2022 Teal Dulcet
# Compare the performance of GpuOwl commits with multiple exponents
# Run: ./performance.sh
# set -e
# Exponents
EXPONENTS=(106928347)
@tdulcet
tdulcet / LL.py
Last active December 22, 2023 13:03
LL and PRP Primality Tests.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Teal Dulcet
# Lucas-Lehmer (LL) Primality Test
# Run: python3 -OO LL.py <p> [iterations] [shift]
# time for i in 3 5 7 13 17 19 31 61 89 107 127 521 607 1279 2203 2281 3217 4253 4423 9689 9941 11213 19937 21701 23209 44497 86243 110503 132049 216091 756839 859433 1257787 1398269 2976221 3021377 6972593; do python3 -X dev LL.py "$i" '' 0; done
@tdulcet
tdulcet / wrap.cpp
Last active January 4, 2019 09:26
Word wrap based on the current width of the user's terminal. Supports Unicode characters. Contains one C/C++ and two C++ solutions.
// Copyright © 2018 Teal Dulcet
// Compile: g++ -Wall -g -O3 -o wrap wrap.cpp
// Run: ./wrap
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>