Skip to content

Instantly share code, notes, and snippets.

View honno's full-sized avatar
🛰️

Matthew Barber honno

🛰️
View GitHub Profile
#!/usr/bin/env python2
from collections import deque
from itertools import permutations
def gen_permutations(numbers, slice_by):
subsequence_len = len(numbers) - slice_by
for permutation in permutations(numbers, subsequence_len):
yield permutation
#!/usr/bin/env python2
from collections import defaultdict, deque
from itertools import product
from operator import add
def vectorsum(*vectors):
if len(vectors) > 1:
return map(add, vectors[0], vectorsum(*vectors[1:]))
else:
#!/usr/bin/env python2
from collections import defaultdict
ID_LEN = 5
def gen_primes():
"""Using the Sieve of Erastothenes solution"""
composites = defaultdict(list)
checker = 2
@honno
honno / distribution.csv
Last active March 18, 2020 17:33
Some stats for each ID of dataset
We can't make this file beautiful and searchable because it's too large.
total_freq,pos_freq,neg_freq,KF9.1_miss,KF9.1_present,KF9.1_value,BLOSUM2.1_miss,BLOSUM2.1_present,BLOSUM2.1_value
QVSGSENTDNKPHSE,1,0,1,1,0,?,1,0,?
LQRFDQRSRQFQNLQ,3,0,3,3,0,?,3,0,?
IHFGNDWEDRYYREN,2,2,0,2,0,?,2,0,?
FADLMGYIPLVGAPL,1,1,0,1,0,?,1,0,?
EQEWGTPGSHVREET,1,0,1,0,1,-0.5,1,0,?
NLVGLLGVTGTDLQG,2,2,0,2,0,?,1,1,-0.41
PTDSPSATIDVPSNC,3,0,3,1,2,0.156667,2,1,-0.6
AVGQGWVDHFADGYD,2,1,1,1,1,-0.182667,1,1,0.208
LKLDIQPYDINQRLQ,1,0,1,1,0,?,1,0,?
#!/usr/bin/env python3
import argparse
import sys
import re
id_pattern= re.compile("[A-Z]+")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
@honno
honno / asda-order-to-csv.py
Last active February 20, 2020 08:34
Get a csv out of asda order summaries
#!/usr/bin/python3
import argparse
import sys
import csv
from bs4 import BeautifulSoup
import requests
if __name__ == "__main__":
@honno
honno / expert-system.lisp
Last active September 28, 2020 15:04
An inference engine for an expert system.
;; Forward & Backward Chaining
;;
;; Use (run *rules *goals) in CLISP to try it out.
;;
;; Written by Matthew Barber <quitesimplymatt@gmail.com> under MIT
;;
;; The MIT License (MIT)
;;
;; Copyright (c) 2019 Matthew Barber
;;
@honno
honno / find-crc32.py
Created July 26, 2019 07:15
Multiprocessing bruteforcing script to find a valid CRC32 checksum in a file which quotes said CRC32 value, i.e. a self-referential CRC32.
#!/usr/bin/python3
import logging
import argparse
import sys
import binascii
import multiprocessing as mp
from time import sleep
SLEEP_TIME = 0.1
@honno
honno / description.md
Last active October 24, 2023 14:31
Scraper for Health Lotto gambling game Quick Win

Health Lottery Quick Win Draws Scraper

The Health Lottery in the UK runs an online lottery that runs every 3 minutes called Quick Win, where they employ the services of an online casino games supplier called Gamevy.

And so, scraper.py collates the numbers resulting from each draw to generate a .csv file.

Gamevy has seemingly exposed every past draw of the lottery in one API endpoint that only requires a (publicly available) session token from another endpoint. As of May 2019, that's over 300 000 draws!

I made this as part of a learning exercising to test the "randomness" of this lottery game by way of statistical analysis.