Skip to content

Instantly share code, notes, and snippets.

View JotaRata's full-sized avatar
💥

JotaRata

💥
  • 13:40 (UTC -04:00)
View GitHub Profile
@JotaRata
JotaRata / TextEditor.cs
Last active January 7, 2024 22:52
A really really simple text editor for Unity
/*
This is a really simple text editor to be used within Unity
It's useful to write memos, notes or ideas inside your Unity Editor window
Kinda like Blender's Text Editor
*/
using UnityEngine;
using UnityEditor;
using System;
using System.IO;
@JotaRata
JotaRata / list.py
Last active August 6, 2023 05:19
Python Generic List
'''
C# like generic lists for python!
Description
A cool trick that uses a singleton variable called "List" which is an instance of a "hidden" class _GenericList
this class defines a __getitem__ method that returns a type object that internally stores the type given by the getter
because it is a type object you can instanstiate in python using curly braces, hence behaving exactly like a normal class
The class _GenericList also returns a regular list instance if no type were provided, this is done by defining the __call__ method
Usage:
@JotaRata
JotaRata / stubs.py
Last active August 1, 2023 01:05
Auto stub generator for Cython files
'''
Auto stub generator for cython files.
LIMITATIONS:
Can only parse declared cdef variables with public/readonly keywords
Cannot parse plain defined variables (ex: "my_var = 2")
Cannot parse special members imported from C/C++
Cannot parse ctypedef types
Can only parse functions prefixed with 'def' and 'cpdef
@JotaRata
JotaRata / get_axis.py
Last active July 5, 2023 20:52
Matplotlib subplots shortcut
class get_axis():
"""
Context manager to generate subplots quickly
Parameters:
- rows, cols (int): Rows and columns to draw.
- xlabel, ylabel (str / list): Labels for the horizontal and vertical axis, If xlabel/ylabel are lists then each corresponding subplot will have its own labels.
- title (str / list): Title of the plot, If title is a list then each subplot will have its own title.
- figzise (tuple): Size of the figure in inches (same as figure.figsize).
- figargs (dict): Additionl arguments passed to plt.subplots