Skip to content

Instantly share code, notes, and snippets.

View tito's full-sized avatar

Mathieu Virbel tito

View GitHub Profile
@tito
tito / refactor.py
Created March 8, 2023 16:51
Using OpenAI/ChatGPT as refactoring tool
"""
Refactoring tool using ChatGPT from Vue 2 to Vue 3
$ export OPENAPI_APIKEY=sk.........
$ python refactor.py MyView.vue
"""
import os
import re
import sys
@tito
tito / buildozer.spec
Last active April 28, 2024 03:37
Python for android / buildozer / androidx (MAY NOT WORK)
# to add in the spcec:
android.api = 28
android.minapi = 26
android.ndk = 17c
p4a.hook = p4a_hook.py
# i have my own set of java tools, don't use it if you don't want it
android.add_src = java/src/
@tito
tito / gist
Created November 17, 2012 14:51
Download and extract a GIST zipfile.
#!/bin/bash
GISTS_DIR=~/.gists
FILENAME=$1.tar.gz
if [ "X$1" == "X" ]; then
echo "Usage: gist <gistid>"
exit 1
fi
@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 / bluetooth.py
Created November 12, 2013 15:28
Bluetooth example on Android using Python / Pyjnius
'''
Bluetooth/Pyjnius example
=========================
This was used to send some bytes to an arduino via bluetooth.
The app must have BLUETOOTH and BLUETOOTH_ADMIN permissions (well, i didn't
tested without BLUETOOTH_ADMIN, maybe it works.)
Connect your device to your phone, via the bluetooth menu. After the
pairing is done, you'll be able to use it in the app.
@tito
tito / pointer.py
Created July 2, 2013 15:37
Exploration of ctypes to get C memory address from a ctypes object, and reuse the memory address to get back a ctypes object
import ctypes
class Point(ctypes.Structure):
_fields_ = (
("x", ctypes.c_int),
("y", ctypes.c_int))
p1 = Point(23, 4)
print 'Original point is', (p1.x, p1.y)
@tito
tito / pchip_interpolate.py
Created April 30, 2016 13:17
Pchip interpolation implementation in pure Numpy (no scipy dependency, suitable for Android.)
# coding=utf-8
"""
Pchip implementation in pure numpy
.. author:: Michael Taylor <mtaylor@atlanticsciences.com>
.. author:: Mathieu Virbel <mat@meltingrocks.com>
Copyright (c) 2016 Michael Taylor and Mathieu Virbel
Permission is hereby granted, free of charge, to any person obtaining a copy
@tito
tito / transparent_video_test.py
Last active June 28, 2023 20:36
Kivy/ffpyplayer transparent/alpha background video
"""
Kivy/ffpyplayer example to read transparent video
=================================================
Right now, VP9/ffmpeg encoder supports alpha channel, under the yuva420p
pixel format. But for decoding, the default libvp9 used by ffmpeg doesn't
support it, so we need to ask for libvpx-vp9 instead.
I was using a set of png image as a source, and got a VP9+alpha video with::
@tito
tito / cpuradialgradient.py
Created December 10, 2012 12:36 — forked from tshirtman/radial_gradient.py
radial gradient texture for kivy
from kivy.graphics.texture import Texture
from kivy.graphics import Rectangle, Color
from kivy.uix.widget import Widget
from kivy.graphics.opengl import glFinish
from kivy.app import App
from time import time
class RadialGradient(App):
def build(self):
@tito
tito / visiblecontainer.py
Created March 24, 2023 23:08
Kivy Widget for showing/hidding content.
from kivy.uix.relativelayout import RelativeLayout
from kivy.properties import BooleanProperty, NumericProperty
from kivy.animation import Animation
class VisibleContainer(RelativeLayout):
visible = BooleanProperty(True)
animated = BooleanProperty(False)
duration = NumericProperty(0.2)
capture = BooleanProperty(False)