Skip to content

Instantly share code, notes, and snippets.

View tito's full-sized avatar

Mathieu Virbel tito

View GitHub Profile
@tito
tito / main.py
Created December 7, 2018 11:01 — forked from Cheaterman/main.py
main.py
import os
os.environ['KIVY_WINDOW'] = '' # noqa
from kivy.base import EventLoop, runTouchApp
from kivy.core.window import WindowBase
from kivy.graphics import Callback, opengl as gl
from kivy.lang import Builder
from kivy.properties import ObjectProperty
from direct.showbase.ShowBase import ShowBase
@tito
tito / Setup.local-ssl
Last active November 4, 2018 09:40
P4A: Python 3 fixes with openssl support
SSL=
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL) -lssl$(OPENSSL_VERSION) -lcrypto$(OPENSSL_VERSION)
from kivy.base import runTouchApp
from kivy.lang import Builder
from kivy.factory import Factory as F
class DemoBox(F.ButtonBehavior, F.BoxLayout):
base_direction = F.StringProperty(None, allownone=True)
font_context = F.StringProperty(None, allownone=True)
font_size = F.NumericProperty(10)
runTouchApp(Builder.load_string('''
@tito
tito / parallax.ino
Created August 12, 2018 14:40
Parallax 360 Servo with feedback - Arduino sketch with angle control
#include <Servo.h>
Servo myservo;
int servoPin = 9;
int feedbackPin = 8;
void setup() {
pinMode(feedbackPin, INPUT);
pinMode(servoPin, OUTPUT);
@tito
tito / distance.py
Created March 26, 2018 16:01
Distance approximation from velocity, friction and fps
def get_distance_from_velocity_loop(self, vel, fri, dt=1 / 60.):
# original algo from tito
dist = 0
it = 0
while abs(vel) > .5:
it += 1
vel -= vel * fri
dist += vel * dt
return dist
@tito
tito / README.md
Created March 21, 2018 10:33
Find GL leaks from a apitrace dump

Find leaks from a apitrace dump trace

  1. Trace your program: apitrace trace python main.py
  2. Dump the trace: apitrace dump python.2.7.trace > log
  3. Check for leaks: python findleak.py log
# -*- coding: utf-8 -*-
from kivy.app import App
from kivy.factory import Factory
class TestApp(App):
def build(self):
return Factory.Button(text="Hello")
def reset():
@tito
tito / cyclerv.py
Last active February 6, 2018 13:20
Cyclable RecycleView
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import NumericProperty
kv = """
<Row@BoxLayout>:
canvas.before:
Color:
@tito
tito / kivy_audio_android.py
Created December 10, 2017 17:25
Kivy Android audio player implementation
"""
Kivy audio implementation for Android using native API
======================================================
"""
from jnius import autoclass
from kivy.core.audio import Sound, SoundLoader
MediaPlayer = autoclass("android.media.MediaPlayer")
@tito
tito / testperf.py
Created September 1, 2017 17:12
Test widget instanciation
# -*- coding: utf-8 -*-
from kivy.factory import Factory
from time import time
MAX_TIME = 2
def time_bounded_perf(f):
def _time_bounded_perf(*args, **kwargs):