Skip to content

Instantly share code, notes, and snippets.

View Jordan-Cottle's full-sized avatar

Jordan Cottle Jordan-Cottle

View GitHub Profile
@Jordan-Cottle
Jordan-Cottle / description.md
Last active August 16, 2022 19:38
Inspect for self does not do a good job of making something private

Examples from https://stackoverflow.com/questions/69152143/private-attributes-in-pydantic

I added the bottom two tests in test.py, while post_pydantic.py is unmodified from https://stackoverflow.com/a/71742829/10778553

Output from running pytest looks like

$ pytest test.py 
======================================================================================================================== test session starts =========================================================================================================================
platform win32 -- Python 3.9.1, pytest-7.1.2, pluggy-1.0.0
@Jordan-Cottle
Jordan-Cottle / slots.py
Created August 22, 2021 02:23
Quick demonstration of `__slots__` with inheritance. Subclasses are able to make their own independent decision on whether to use slots or not. Subclasses will use a dynamic `__dict__` instead of the static `__slots__` as usual, even if their parent class uses `__slots__`.
class Foo:
__slots__ = ["spam", "eggs"]
def __init__(self) -> None:
self.spam = "spam"
self.eggs = "eggs"
class Bar(Foo):
def __init__(self):
@Jordan-Cottle
Jordan-Cottle / data.md
Last active April 15, 2021 19:29
Markdown table generated with test data
Threads omp parallel + critical time omp parallel + critical speedup omp parallel for + dynamic schedule + critical time omp parallel for + dynamic schedule + critical speedup omp parallel for reduction + dynamic schedule time omp parallel for reduction + dynamic schedule speedup
1 0.8353 1.0 0.8803 1.0 0.8419 1.0
2 0.6286 1.328825962456252 0.6602
@Jordan-Cottle
Jordan-Cottle / HelloMPI.cpp
Last active February 25, 2021 18:27
Generic MPI project Makefile
#include <iostream>
#include <mpi.h>
int main(int argc, char *argv[])
{
MPI_Init(NULL, NULL);
int rank;
int process_count;
import unittest
from flask05 import app
class FlaskTest(unittest.TestCase):
def setUp(self) -> None:
self.client = app.test_client()
def test_index(self):
print("Loading pixelmon recipes!");
// Setup disc -> base recipes
val iron_disc = <pixelmon:iron_disc>;
val iron_base = <pixelmon:iron_base>;
recipes.addShaped(iron_base, [
[iron_disc, null, iron_disc],
[iron_disc, iron_disc, iron_disc],
]);
[INITIALIZATION][CLIENT][ERROR] [crafttweaker]: Error executing {[0:crafttweaker]: pixelmon.zs}: null
java.lang.NullPointerException
at crafttweaker.mc1120.recipes.MCRecipeShaped.toCommandString(MCRecipeShaped.java:335)
at crafttweaker.mc1120.recipes.MCRecipeManager$ActionBaseAddRecipe.calculateName(MCRecipeManager.java:824)
at crafttweaker.mc1120.recipes.MCRecipeManager$ActionBaseAddRecipe.setName(MCRecipeManager.java:818)
at crafttweaker.mc1120.recipes.MCRecipeManager$ActionAddShapedRecipe.<init>(MCRecipeManager.java:880)
at crafttweaker.mc1120.recipes.MCRecipeManager$ActionAddShapedRecipe.<init>(MCRecipeManager.java:875)
at crafttweaker.mc1120.recipes.MCRecipeManager.addShaped(MCRecipeManager.java:151)
at Pixelmon.__script__(pixelmon.zs:79)
at __ZenMain__.run(Pixelmon)
@Jordan-Cottle
Jordan-Cottle / exceptionDecorator.py
Created February 1, 2020 02:36
A decorator that takes in an exception type and handles it
class BaseException(Exception):
""" This is a basic exception """
class NotBasicException(BaseException):
""" This is not a basic exception """
def args_decorator(ExceptionType, msg, status_code):
def decorate(func):
print(f'Decorating {func}')
/**
* Write a description of class Fraction here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Fraction
{
private int numerator;
import java.awt.Color;
import java.util.Scanner;
public class ATest{
private static final int WORLD_WIDTH = 800;
private static final int WORLD_HEIGHT = 650;
private static World w;
private static Turtle t;
private static Scanner in = new Scanner(System.in);
private static boolean bold = false;