Skip to content

Instantly share code, notes, and snippets.

View gottadiveintopython's full-sized avatar

水戸う納豆齋(Nattōsai Mitō) gottadiveintopython

View GitHub Profile
@gottadiveintopython
gottadiveintopython / main.py
Last active July 24, 2022 00:58
class-based context managers are faster than generator-based ones
# CPython3.8.12 上で測ったところclass-basedの方が17倍近く速かった
from functools import partial
from contextlib import contextmanager
from timeit import timeit
class class_based:
__slots__ = tuple()
@gottadiveintopython
gottadiveintopython / getting_familiar_with_size_hint_min.py
Created July 4, 2022 14:22
getting familiar with size_hint_min #1
'''
CPython 3.8.12
pip install kivy[base]==2.1.0
pip install "asynckivy>=0.5,<0.6"
pip install git+https://github.com/gottadiveintopython/kivyx.uix.magnet#egg=kivyx.uix.magnet
'''
from kivy.config import Config
Config.set('graphics', 'width', 1280)
Config.set('graphics', 'height', 720)
# Config.set('graphics', 'maxfps', 30)
from kivy.clock import Clock
from kivy.app import App
from kivy.animation import Animation
from kivy.uix.widget import Widget
from kivy.uix.floatlayout import FloatLayout
from kivy.lang import Builder
from kivy.core.window import Window
from kivy.graphics import RenderContext
from kivy.uix.modalview import ModalView
from kivy.properties import ListProperty, NumericProperty, ObjectProperty, ColorProperty
@gottadiveintopython
gottadiveintopython / test.glsl
Created October 3, 2021 13:18 — forked from tshirtman/test.glsl
glsl vjaying experiment
$HEADER$
float PI = 3.1415926535;
uniform vec2 resolution;
uniform float time;
vec2 rotate(vec2 pos, float angle, vec2 center){
pos -= center;
pos *= mat2(cos(angle), sin(-angle), sin(angle), cos(angle));
pos += center;
@gottadiveintopython
gottadiveintopython / main.py
Last active September 19, 2021 22:26
sqlite3 database as RecycleView data source
import sqlite3
from kivy.app import App
from kivy.lang import Builder
def init_db():
import itertools
from string import ascii_uppercase
conn = sqlite3.connect(":memory:")
cur = conn.cursor()
@gottadiveintopython
gottadiveintopython / shiled.py
Created August 11, 2021 22:20 — forked from tshirtman/Overworld.png
a tilemap implementation in kivy using a shader
from array import array
from kivy.uix.widget import Widget
from kivy.clock import Clock
from kivy import properties as P
from kivy.graphics import (
RenderContext, BindTexture, Rectangle, Color
)
from kivy.graphics.texture import Texture
from kivy.core.window import Window
@gottadiveintopython
gottadiveintopython / chat_viewer.py
Last active March 18, 2022 03:46
RecycleViewを使ってchat viewerを実装
import itertools
from string import Template
from collections import defaultdict
from kivy.config import Config
Config.set('graphics', 'width', 400)
Config.set('graphics', 'height', 800)
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
from kivy.utils import escape_markup
from kivy.clock import Clock
@gottadiveintopython
gottadiveintopython / noglobal.py
Created December 6, 2020 15:41 — forked from yoshipon/noglobal.py
Useful Noglobal in Python
# License:
# I hereby state this snippet is below "threshold of originality" where applicable (public domain).
#
# Otherwise, since initially posted on Stackoverflow, use as:
# CC-BY-SA 3.0 skyking, Glenn Maynard, Axel Huebl
# http://stackoverflow.com/a/31047259/2719194
# http://stackoverflow.com/a/4858123/2719194
import types
import inspect
@gottadiveintopython
gottadiveintopython / noglobal.py
Created December 6, 2020 15:39 — forked from ax3l/noglobal.py
Useful Noglobal in Python
# License:
# I hereby state this snippet is below "threshold of originality" where applicable (public domain).
#
# Otherwise, since initially posted on Stackoverflow, use as:
# CC-BY-SA 3.0 skyking, Glenn Maynard, Axel Huebl
# http://stackoverflow.com/a/31047259/2719194
# http://stackoverflow.com/a/4858123/2719194
import types
@gottadiveintopython
gottadiveintopython / wobblywidget.py
Created May 14, 2020 17:27 — forked from salt-die/wobblywidget.py
Make any widget wobble with wobbly widget!
"""For this to work, WobblyEffect should be parent to WobblyScatter.
Try setting WobblyScatter `size_hint = (None, None)` or `size = self.parent.size`
if having size issues.
"""
from kivy.clock import Clock
from kivy.uix.effectwidget import AdvancedEffectBase, EffectWidget
from kivy.uix.scatter import Scatter
from kivy.uix.widget import Widget
from itertools import product