Skip to content

Instantly share code, notes, and snippets.

View TheMatt2's full-sized avatar

Matthew Schweiss TheMatt2

View GitHub Profile
@TheMatt2
TheMatt2 / port-forwarding.py
Created June 13, 2019 21:05 — forked from neoatlantis/port-forwarding.py
port forwarding via python socket
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# TCP Port Forwarding via Socks5 Socket
# Original Author : WangYihang <[email protected]> (for port forwarding)
# (As gist: <https://gist.github.com/WangYihang/e7d36b744557e4673d2157499f6c6b5e>)
# Changes : NeoAtlantis <[email protected]>
# (adapted to pySocks, argparse for CLI invokation, encryption, etc.)
import argparse
@TheMatt2
TheMatt2 / iterator_test.cpp
Last active December 25, 2020 02:37
Example to show the speed difference of using an iterator across an array, versus using std::begin() iteration. Source: https://softwareengineering.stackexchange.com/questions/386614/c-iterator-why-is-there-no-iterator-base-class-all-iterators-inherit-from
/* Iterator Example
* Modified to support clang compiler
* Compiler and Run:
* $ clang++ -Wall -Ofast -std=c++11 iterator_test.cpp && ./a.out
* y
* y
* time1: 143ns
* time2: 168ns
* https://softwareengineering.stackexchange.com/questions/386614/c-iterator-why-is-there-no-iterator-base-class-all-iterators-inherit-from
*/
@TheMatt2
TheMatt2 / PrintHangTest.java
Last active July 21, 2021 15:45
Demonstration of scripts that will hang Ghidra. Part of Bug Report Submission
import ghidra.app.script.GhidraScript;
public class PrintHangTest extends GhidraScript {
long STALL_TIME = 60 * 1000; // milliseconds
@Override
public void run() throws Exception {
if (currentProgram == null) {
return;
@TheMatt2
TheMatt2 / clear_symbols.py
Created July 23, 2021 20:10
Scripts used to demonstrate an issue in Ghidra. Part of bug report
"""
Deletes all symbols in Ghidra Symbol Tree
Not necessary for this demonstration, but useful for testing.
"""
symbolTable = currentProgram.getSymbolTable()
for sym in symbolTable.getSymbolIterator():
sym.delete()
currentProgram.invalidate()
@TheMatt2
TheMatt2 / jython_array_bugs.py
Created August 5, 2021 14:58
Demonstration script for Jython bug with array module.
import sys
import array
def test_signed(typecode):
try:
a = array.array(typecode)
# Create byte representation of exactly one item
byte_item = bytes()
for i in range(a.itemsize):
#!/bin/bash
JAVA="java"
JAR="paper-1.18.1-101.jar"
RAM="2000M"
FLAGS="-XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Daikars.new.flags=true -Dusing.aikars.flags=https://mcflags.emc.gs"
echo "Starting server..."
${JAVA} -Xmx${RAM} -Xms${RAM} ${FLAGS} -jar ${JAR} --nogui
# https://en.wikipedia.org/wiki/Reuleaux_triangle
import math
import cairo
def pos_on_circle(cx, cy, radius, angle):
# Convert polar to cartesian, Author: Matthew Schweiss
x = math.cos(angle) * radius + cx
y = math.sin(angle) * radius + cy
return x, y
@TheMatt2
TheMatt2 / generator_pickler.py
Last active March 2, 2023 17:18
Make unused Python generators Pickle-able!
"""
Simply little utility function to make it possible to pickle generators.
While generator instances can not actually be pickled, this saves the generator
function and only creates a generator instance when the first value is accessed.
The goal is to make it possible to pass generators, with arguments, through multiprocessing
which uses pickling internally to move objects between Python processes.
import multiprocessing
# Because it turns out writing files is hard
# Process can crash halfway through, and a collision can overwrite the file
# mid operation.
# https://stackoverflow.com/questions/7645338/how-to-do-atomic-file-replacement
# http://www.weirdnet.nl/apple/rename.html
import os
import hjson
import filelock
def safe_json_read(filename, timeout = None):

Checkbox Tables in Markdown

An attempt to make a list of the supported ways to make a table with checkboxes in Markdown.

Results as of October 2023.


Below is the style element that formats the colors of the colored check mark emojis.