This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
import os | |
import time | |
import numpy as np | |
from pynput import keyboard | |
from pynput.keyboard import Key | |
TERMX, TERMY = os.get_terminal_size() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
A simple Mandlebrot explorer in Kivy! Drag mouse to translate, multitouch-zoom to zoom, and scroll to increase/decrease number of iterations. | |
""" | |
from kivy.app import App | |
from kivy.core.window import Window | |
from kivy.uix.effectwidget import AdvancedEffectBase | |
from kivy.lang import Builder | |
from kivy.vector import Vector | |
SHADER = """ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import chain, product, repeat, starmap | |
from more_itertools import interleave | |
from functools import lru_cache | |
import numpy as np | |
import sounddevice as sd | |
SAMPLE_RATE = 44100 | |
sd.default.samplerate = SAMPLE_RATE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Scroll with the mouse to enable auto-poking.""" | |
from random import random | |
from kivy.app import App | |
from kivy.clock import Clock | |
from kivy.core.window import Window | |
from kivy.lang import Builder | |
from kivy.uix.effectwidget import AdvancedEffectBase | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
An analog clock for your terminal! | |
The grid and base arrays in Clock are dtype=int, but this might make more sense if we just | |
use character arrays instead -- we may update this soon. | |
""" | |
import os | |
import time | |
import numpy as np |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Move bulge by dragging the mouse. Scale with multitouch. | |
""" | |
from kivy.app import App | |
from kivy.core.window import Window | |
from kivy.uix.effectwidget import AdvancedEffectBase | |
from kivy.lang import Builder | |
EFFECT = AdvancedEffectBase() | |
EFFECT.glsl = """ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""TODO: ctrl + left/right (move past word), ctrl + backspace/del (del word), shift + del (del line) | |
...: Smart movement through leading indentation. | |
...: Except for first line, up/down to work normally on multi-line console input. | |
""" | |
from code import InteractiveConsole | |
from collections import deque | |
from dataclasses import dataclass | |
from io import StringIO | |
from itertools import chain, takewhile | |
from more_itertools import ilen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from more_itertools import always_iterable | |
from sys import modules | |
from weakref import WeakKeyDictionary | |
from types import FunctionType | |
class WeakDefaultDict(WeakKeyDictionary): | |
def __init__(self, default_factory=lambda: None, **kwargs): | |
self._default_factory = default_factory | |
super().__init__(**kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ast | |
import re | |
NAME_RE = re.compile('[.]([A-Za-z]+)[ ]') | |
DEFAULT = 3 | |
LINE_CHRS = '├─', '│ ', '╰─', ' ' | |
def flatten(iterable): | |
for item in iterable: | |
if isinstance(item, list): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""For this to work, WobblyEffect should be parent to WobblyScatter. | |
""" | |
from kivy.clock import Clock | |
from kivy.uix.effectwidget import AdvancedEffectBase, EffectWidget | |
from kivy.uix.scatter import Scatter | |
from itertools import product | |
FRICTION = .95 | |
K = 8 |
OlderNewer