Skip to content

Instantly share code, notes, and snippets.

@toaster-code
toaster-code / maze-builder.py
Created February 14, 2024 18:17
A maze-builder script made in python
""" A maze builder algorithm.
Based on accepted answer at this post from stackoverflow:
https://stackoverflow.com/questions/29739751/implementing-a-randomly-generated-maze-using-prims-algorithm/29758926#29758926
The main logic is in the dig method in the class Maze. Once provided with a list of `fronts` to explore, the algorithm will
dig a maze in 2 steps movement (avoiding creating open rooms).
Assumptions:
- A frontier is a cell chosen to explore for its neighbours, digging from it until there are no move moves available.
@toaster-code
toaster-code / create_project.py
Last active September 17, 2023 14:05
setup a project using python
import os
import sys
def create_project_structure(project_name):
# Create project directory
os.makedirs(project_name, exist_ok=True)
os.chdir(project_name)
# Create a virtual environment (.venv)
os.system(f"python -m venv .venv")
@toaster-code
toaster-code / counter.py
Last active April 15, 2022 09:29
Create a decorator to a counter of class calls and object creation
class Report():
"""Decorator for counter."""
COUNTER = dict()
@classmethod
def counter(cls,func):
def wrapper_counter(*args,**kwargs):
# COUNTER['split_array']+=1
# print(dir(func))
print(func.__qualname__)
name = func.__qualname__
@toaster-code
toaster-code / 0_reuse_code.js
Created June 19, 2017 10:13
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console