Skip to content

Instantly share code, notes, and snippets.

View ocean1's full-sized avatar
🐶
I may be slow to respond.

_ocean ocean1

🐶
I may be slow to respond.
View GitHub Profile
@maartenbreddels
maartenbreddels / qt_and_tornado.py
Created October 1, 2015 10:57
Combining Qt and tornado, both which want to have their own event loop.
__author__ = 'breddels'
"""
Demonstrates combining Qt and tornado, both which want to have their own event loop.
The solution is to run tornado in a thread, the issue is that callbacks will then also be executed in this thread, and Qt doesn't like that.
To fix this, I show how to use execute the callback in the main thread, using a Qt signal/event in combination with Promises.
The output of the program is:
fetch page, we are in thread <_MainThread(MainThread, started 47200787479520)>
response is 191548 bytes, we are in thread <Thread(Thread-1, started daemon 47201018689280)>
the other thread should fulfil the result to this promise, we are in thread <Thread(Thread-1, started daemon 47201018689280)>
@rbrito
rbrito / brightness.py
Created February 11, 2013 07:44
Script to control monitor brightness
#!/usr/bin/env python
"""
Python script to essentially perform the same as:
gdbus call \
--session \
--dest org.gnome.SettingsDaemon \
--object-path /org/gnome/SettingsDaemon/Power \
--method org.gnome.SettingsDaemon.Power.Screen.SetPercentage 75