Skip to content

Instantly share code, notes, and snippets.

View chipolux's full-sized avatar

NaKyle chipolux

View GitHub Profile
@chipolux
chipolux / map.py
Created May 31, 2019 18:32
Take the JSON output of `tree` and generate a graphviz graph for it.
#!python
########
# Usage:
# tree -a -J | ./map.py | dot -Tpdf > map.pdf
########
import json
import sys
@chipolux
chipolux / converter.py
Created January 28, 2019 03:52
Simple Currency Conversion
def main():
conversions = [
# In Hyrule Lon Lon Milk si 10 rupees and a gallon of milk is 2.53 dollars.
{"country": "Hyrule", "rate": 3.9525, "name": "rupees"},
# In Animal Crossing a kettle is 960 bells and 19.48 dollars.
{"country": "Animal Crossing", "rate": 49.2813, "name": "bells"},
# In Skyrim a bottle of milk is 6 septims, a pint of milk is 1.29 dollars.
{"country": "Skyrim", "rate": 4.6511, "name": "septims"},
]
usd = float(input('Please enter amount in US Dollars: '))
tool
extends Node
export(bool) var reset = false setget onReset
export(String, FILE, "*png") var tilesheet
export(int) var tilesize
func onReset(isTriggered):
if (isTriggered):
@chipolux
chipolux / move_window.py
Created August 23, 2017 00:08
Moving X11 Window (python-xlib)
import Xlib.display
WINDOW_NAME = 'some window name'
d = Xlib.display.Display()
r = d.screen().root
x = 0
y = 100
width = r.get_geometry().width
@chipolux
chipolux / sinewave.py
Created August 23, 2017 00:05
Graphing Sine Wave (PyQt5)
from math import sin, pi
from PyQt5.QtGui import QPainter, QPainterPath
from PyQt5.QtWidgets import QWidget, QApplication, QSlider, QLabel
class Widget(QWidget):
def __init__(self, parent=None):
super().__init__(parent)
@chipolux
chipolux / embedded_window.py
Created August 22, 2017 23:27
Embedding A Window In A Widget (PyQt5 and python-xlib)
def get_window_id(name):
import Xlib.display
d = Xlib.display.Display()
r = d.screen().root
window_ids = r.get_full_property(
d.intern_atom('_NET_CLIENT_LIST'), Xlib.X.AnyPropertyType
).value
@chipolux
chipolux / debounce.py
Created August 22, 2017 17:09
pyqt debounced text input
# A simple example of using a QTimer to create a debounce on a line edit.
# For things like search fields, etc.
from PyQt5.QtCore import QTimer
from PyQt5.QtWidgets import QWidget, QLineEdit, QApplication, QVBoxLayout
class Widget(QWidget):
def __init__(self, parent=None):
super().__init__(parent)
@chipolux
chipolux / test.py
Last active March 2, 2017 18:00
Simple EGLFS ComboBox Example (Works With Raspberry Pi and LeanDog PyQt 5.7)
import sys
from PyQt5.QtCore import QUrl
from PyQt5.QtGui import QGuiApplication
from PyQt5.QtQuick import QQuickView
app = QGuiApplication(sys.argv)
view = QQuickView()
view.setSource(QUrl('./test.qml'))
from PyQt5.QtWidgets import QDialog, QGridLayout, QLabel, QPushButton
from PyQt5.QtNetwork import QNetworkInterface, QAbstractSocket
class NetworkInfoDialog(QDialog):
def __init__(self, parent=None):
super().__init__(parent)
self.setWindowTitle('Network Interface Info')
layout = QGridLayout(self)
for i, interface in enumerate(self.get_interfaces()):
nakyle at lnakyle-work in ~/Projects/manufacturing-kiosk (time-routing●●)
$ mkvirtualenv test-fdb -p python3
Running virtualenv with interpreter /usr/local/bin/python3
Using base prefix /usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5
New python executable in test-fdb/bin/python3.5
Also creating executable in test-fdb/bin/python
Installing setuptools, pip, wheel...done.
virtualenvwrapper.user_scripts creating /Users/nakyle/.virtualenvs/test-fdb/bin/predeactivate
virtualenvwrapper.user_scripts creating /Users/nakyle/.virtualenvs/test-fdb/bin/postdeactivate
virtualenvwrapper.user_scripts creating /Users/nakyle/.virtualenvs/test-fdb/bin/preactivate