Skip to content

Instantly share code, notes, and snippets.

View Owez's full-sized avatar

Owen Griffiths Owez

View GitHub Profile
@Owez
Owez / omerkle.rs
Last active January 5, 2022 17:58
Array-based merkle tree generation
pub fn new(data: impl IntoIterator<Item = T>) -> Self {
// raw data to enumerated leaf
let mut master: Vec<Vec<Leaf<T>>> = data
.into_iter()
.map(|point| vec![Leaf::new_data(point)])
.collect();
// add dummy leaf if odd
if master.len() % 2 != 0 {
master.push(vec![Leaf::new_dummy()])
@Owez
Owez / minimc.py
Last active August 2, 2021 15:36
Automatic minecraft server runner used and maintained for myself; see constants for configuration. Dynamically uses spigot/paper jars placed in same dir
"""Automatic minecraft server runner used and maintained for myself; see constants for configuration. Dynamically uses spigot/paper jars placed in same dir"""
from __future__ import print_function
import os
import sys
import time
import signal
"""The possible beginnings of filenames for server jars"""
STARTJAR = ["spigot-", "paper-"]
@Owez
Owez / jwt-kid-exploit.py
Created July 7, 2021 23:40
JWT KID exploit, ensure Flask (`flask`) and PyJWT (`pyjwt`) are installed before running
"""JWT KID exploit, ensure Flask (`flask`) and PyJWT (`pyjwt`) are installed before running"""
import jwt
from flask import Flask
DEFAULT_PORT = 8000
DIV = "-" * 32
print(f"JWT KID exploit\n{DIV}")
@Owez
Owez / trado.py
Created February 23, 2021 21:13
A simple and quite terrible trading bot made in an hour or so to learn some mpl
import os
import discord
import matplotlib.pyplot as plt
import mplfinance
import numpy as np
import pandas as pd
import yfinance as yf
from discord.ext.commands import Bot
PATH_HISTORIC = "historic.png"
@Owez
Owez / hashing_argon2_apikey.rs
Last active October 17, 2020 12:43
Argon2 + api key hashing
/// Encodes plaintext with [ARGON_PEPPER] before the salt is added
fn encode_pepper<P: Into<String>>(plaintext: P) -> String {
format!("{}{}", plaintext.into(), ARGON_PEPPER)
}
/// Simplifies frontend of [gen_argon_hash] + [encode_hash_base64] into
/// a single function that only returns completed, [String]ified hash, typically
/// used for comparisons with already made hashes
pub fn hash_plaintext<P: Into<String>, S: Into<Option<i64>>>(
password: P,
Computer Information:
Manufacturer: Unknown
Model: Unknown
Form Factor: Desktop
No Touch Input Detected
Processor Information:
CPU Vendor: AuthenticAMD
CPU Brand: AMD FX(tm)-8320 Eight-Core Processor
CPU Family: 0x15
@Owez
Owez / benchmark.bencode
Created September 11, 2020 19:52
A 128,001 character bencode parser benchmark to be used for https://github.com/owez/torro benchmarking
li64ei64ei64ei64ei64ei64ei64ei64el2:hi5:there2:hi5:there2:hi5:therei64ei64ei64ei64ei64ei64ei64ei64eli64ei64ei64ei64ei64ei64ei64ei64el2:hi5:there2:hi5:there2:hi5:therei64ei64ei64ei64ei64ei64ei64ei64eeli64ei64ei64ei64ei64ei64ei64ei64el2:hi5:there2:hi5:there2:hi5:therei64ei64ei64ei64ei64ei64ei64ei64eeli64ei64ei64ei64ei64ei64ei64ei64el2:hi5:there2:hi5:there2:hi5:therei64ei64ei64ei64ei64ei64ei64ei64eeli64ei64ei64ei64ei64ei64ei64ei64el2:hi5:there2:hi5:there2:hi5:therei64ei64ei64ei64ei64ei64ei64ei64eeli64ei64ei64ei64ei64ei64ei64ei64el2:hi5:there2:hi5:there2:hi5:therei64ei64ei64ei64ei64ei64ei64ei64eeli64ei64ei64ei64ei64ei64ei64ei64el2:hi5:there2:hi5:there2:hi5:therei64ei64ei64ei64ei64ei64ei64ei64eeli64ei64ei64ei64ei64ei64ei64ei64el2:hi5:there2:hi5:there2:hi5:therei64ei64ei64ei64ei64ei64ei64ei64eeli64ei64ei64ei64ei64ei64ei64ei64el2:hi5:there2:hi5:there2:hi5:therei64ei64ei64ei64ei64ei64ei64ei64eeli64ei64ei64ei64ei64ei64ei64ei64el2:hi5:there2:hi5:there2:hi5:therei64ei64ei64ei64ei64ei64ei64ei64eeli64ei64ei64ei64ei64ei64e
@Owez
Owez / spec.txt
Created June 19, 2020 03:10
Please Package Manager current spec
DOMAIN: pleasepm.com
API PREFIX: /api/v1
GET /package/[name]
ABOUT: Query for a package using it's unique name.
EXAMPLE REQUEST: `GET https://pleasepm.com/package/mypackage`
EXAMPLE RESPONSE:
{
"status": "success",
"body": {
@Owez
Owez / FormMain.cs
Created April 3, 2018 16:50
C# Maximize button | full code (will maximized if it is normal and go back to normal if pressed again)
// Maximise button (when clicked)
private void buttonMaximise_Click(object sender, EventArgs e)
{
if (this.WindowState == System.Windows.Forms.FormWindowState.Normal) // if the forms state is normal (not maximised or minimised) then..
{
this.WindowState = FormWindowState.Maximized; // Tells windows this application should be maximised
}
else if (this.WindowState == System.Windows.Forms.FormWindowState.Maximized) // if the forms state is maximised then..
{
this.WindowState = FormWindowState.Normal; // Tells windows this application should be in the normal state (not maximised or minimised)