Skip to content

Instantly share code, notes, and snippets.

View hezral's full-sized avatar
🐍
python time

hezral hezral

🐍
python time
View GitHub Profile
@hezral
hezral / pixbuf2pillow.py
Created October 28, 2021 04:03 — forked from mozbugbox/pixbuf2pillow.py
Python Pillow image to/from GdkPixbuf with gobject introspection
#!/usr/bin/python3
# vim:fileencoding=utf-8:sw=4:et
# Convert between pygobject Pixbuf and PIL/Pillow image format
# Also a function to do fast gamma correction with Pillow image
from __future__ import print_function, unicode_literals, absolute_import
import sys
from gi.repository import GLib, GdkPixbuf
@hezral
hezral / waveform.py
Created October 28, 2021 04:03 — forked from moeseth/waveform.py
Create Soundcloud style waveform from Audio in Python
from pydub import AudioSegment
from matplotlib import pyplot as plot
from PIL import Image, ImageDraw
import numpy as np
import os
src = "./test.mp3"
audio = AudioSegment.from_file(src)
data = np.fromstring(audio._data, np.int16)
@hezral
hezral / waveform.py
Created October 28, 2021 04:03 — forked from mixxorz/waveform.py
Generate waveform images from audio files
# Requires pydub (with ffmpeg) and Pillow
#
# Usage: python waveform.py <audio_file>
import sys
from pydub import AudioSegment
from PIL import Image, ImageDraw
@hezral
hezral / x11_watch_active_window.py
Created October 17, 2021 05:26 — forked from dperelman/x11_watch_active_window.py
python-xlib example which reacts to changing the active window
#!/usr/bin/env python3
# Based on code by Stephan Sokolow
# MIT-licensed
# Source: https://gist.github.com/ssokolow/e7c9aae63fb7973e4d64cff969a78ae8
"""python-xlib example which reacts to changing the active window/title.
Requires:
- Python
- python-xlib
@hezral
hezral / getscreenshot.py
Created December 7, 2020 15:29 — forked from bellbind/getscreenshot.py
[python][pywebkitgtk]Get web page screenshot
#
# Get web page screenshot
#
# usage:
# xvfb-run -s "-screen 0 1024x768x24" python getschreenshot.py test.html
#
# libs:
# - pygtk: http://www.pygtk.org/
# - pywebkitgtk(python-webkit): http://code.google.com/p/pywebkitgtk/
# - PIL: http://www.pythonware.com/products/pil/
@hezral
hezral / gasyncspawn.py
Last active December 16, 2020 11:18 — forked from fabrixxm/gasyncspawn.py
Run external process asynchronously with Python, GLib. Get stdout and stderr via signals.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#https://developer.gnome.org/pygobject/2.28/
#http://www.pygtk.org/articles/subclassing-gobject/sub-classing-gobject-in-python.htm#d0e570
from gi.repository import GObject
from gi.repository import GLib
class GAsyncSpawn(GObject.GObject):
@hezral
hezral / touchegg.conf
Created October 28, 2020 03:29 — forked from cassidyjames/touchegg.conf
A touchégg config I am trying out for elementary OS and big trackpads
<touchégg>
<settings>
<property name="animation_delay">150</property>
<property name="action_execute_threshold">20</property>
<property name="color">909090</property>
<property name="borderColor">FFFFFF</property>
</settings>
<application name="All">