Skip to content

Instantly share code, notes, and snippets.

View sethtroisi's full-sized avatar
🌈

Seth Troisi sethtroisi

🌈
  • Google
  • Seattle
View GitHub Profile
/**
* For local visualizer
* Make sure to apply/unapply changes in FastLed for stub platform
*
* Finally compile the visualizer with
* g++ demo_simple.cpp -I../../../Projects/FastLED/src -lsfml-graphics -lsfml-window -lsfml-system -pthread
* And run with
* ./a.out
*/
import math
import random
# merchant is good for selling metal -> crystal
# and selling deut -> metal or crystal
# fleeters don't like when you sell deut -> metal / crystal
# (as this wastes finite amount of deuterium in the game)
# Global exchange rate of [mcd] to [mcd]
@sethtroisi
sethtroisi / tf_proof_verify.py
Last active May 9, 2020 12:20
Verify proof_k from results.txt v1.3
# 2020-05-08 version 1.3
import re
import os
import sys
def merge(int96):
return int96[0] + (int96[1] << 32) + (int96[2] << 64)
def res96(residual):
@sethtroisi
sethtroisi / tf_proof_verify.py
Created May 8, 2020 20:58
Tool to verify TF proof results.
# 2020-05-08 version 1.1
def merge(int96):
return int96[0] + (int96[1] << 32) + (int96[2] << 64)
def res96(residual):
mask = (1 << 32) - 1
parts = [(residual >> (32 * i)) & mask for i in range(3)]
# bits = [part if part >= 0 else ((1 << 32) - part) for part in parts]
@sethtroisi
sethtroisi / PGSurround.pl
Last active February 21, 2020 21:15
PGSurround.pl by Dana Jacobsen (danaj@), Found on MersenneForum 2019
#!/usr/bin/env perl
use warnings;
use strict;
use Math::GMPz;
use Math::BigInt only => "GMP";
use Math::BigFloat only => "GMP";
use Math::Prime::Util qw/:all/;
use Math::Prime::Util::GMP; # Ensure we're using this
use Term::ReadKey; # Used to read terminal key presses without requiring 'Enter' to be pressed
use Time::HiRes qw(gettimeofday time tv_interval);
@sethtroisi
sethtroisi / PGSurround.pl
Last active February 16, 2020 21:40
PGSurround.pl by Dana Jacobsen (danaj@), Provided by Robert W. Smith in a personal communication 2019
#!/usr/bin/env perl
use warnings;
use strict;
use threads;
use threads::shared;
use Timer::Runtime;
use Math::GMPz;
use Math::BigFloat lib=>"GMP";
use Math::Prime::Util qw/:all/;
$|=1;
"""
$ python
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from bs4 import BeautifulSoup
>>> html = """<html><body><b><center>Chapter 5</center></b></body></html>"""
>>> soup = BeautifulSoup(html, "lxml")
>>> html
'<html><body><b><center>Chapter 5</center></b></body></html>'
@sethtroisi
sethtroisi / choix_test.py
Created April 10, 2019 22:21
Choix test
import random
import choix
import numpy as np
M = 20
PAIRS = 150
PENALTY = 0.1
models = list(range(M))
@sethtroisi
sethtroisi / 2048v6.py
Created April 10, 2019 04:27
2048.py windows code
import collections
import math
import itertools
import time
from PIL import ImageGrab
import win32api
import win32con
INF = 1000000
@sethtroisi
sethtroisi / sprt.py
Last active January 2, 2019 23:59
sprt test
import math
def LL(x):
return 1/(1+10**(-x/400))
def LLF(wins,losses, p0, p1):
# from sethtrois@ https://github.com/gcp/leela-zero/issues/378#issuecomment-351639093
winLog = math.log(p1 / p0)
lossLog = math.log((1-p1) / (1-p0))