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 / cartesianProduct.py
Created April 19, 2019 20:58
Computes the set of positive even numbers with no reapted digits less than 1000 using cartesian products and unions of sets. Checks answer using less obtuse methods.
def cartesianProduct(a, b, repeatDigit = False):
if repeatDigit:
return {f'{aItem}{bItem}' for aItem in a for bItem in b}
else:
return {f'{aItem}{bItem}' for aItem in a for bItem in b if all([char not in bItem for char in list(aItem)])}
odd = {'1','3','5','7','9'}
even = {'0','2','4','6','8'}
natEven = {'2','4','6','8'}
# Blender v2.79 (sub 0) OBJ File: 'Pentagon.blend'
# www.blender.org
mtllib Pentagon.mtl
o Plane
v -1.200000 -0.000000 -1.200000
v -1.000000 0.000000 0.000000
v 0.000000 -0.000000 -2.200000
v 1.200000 -0.000000 -1.200000
v 1.000000 0.000000 0.000000
v -1.200000 0.100000 -1.200000
@Jordan-Cottle
Jordan-Cottle / newTest.py
Last active January 15, 2020 13:45
Test the functionality of __new__ to have constructor return an existing object if the same object id is used
class Test:
objects = {}
def __new__(cls, id):
# Check if id is already used
if id in Test.objects:
print(f'Id {id} previously used, returning existing object')
# Return reference to existing object
return Test.objects[id]
else:
print(f'Id {id} not used, creating new object')
public static void main(String[] args) {
int width = 1024;
int height = 800;
World earth = new World(width, height);
Turtle t0 = new Turtle(earth);
Random r = new Random();
// Draws a random pixel for every pixel on th
for(int i = 0; i < width*height; i++){
int x = r.nextInt(width);
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;
/**
* Write a description of class Fraction here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Fraction
{
private int numerator;
@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}')
[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)
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],
]);
import unittest
from flask05 import app
class FlaskTest(unittest.TestCase):
def setUp(self) -> None:
self.client = app.test_client()
def test_index(self):