Skip to content

Instantly share code, notes, and snippets.

View csaez's full-sized avatar

Cesar Saez csaez

View GitHub Profile
@csaez
csaez / spaceship.py
Last active February 12, 2020 08:15
Interactive Programming in Python - Mini-project #7 - "Spaceship"
# Mini-project # 7 - Spaceship
#
# 'Introduction to Interactive Programming in Python' Course
# RICE University - coursera.org
# by Joe Warren, John Greiner, Stephen Wong, Scott Rixner
import simplegui
import math
import random
@csaez
csaez / hideSignInButton.py
Last active February 3, 2020 11:13
Hide Maya 2017 "Sign In" button at the top of the screen.
from PySide2 import QtWidgets
def mainWindow(widget):
mw = widget.parent()
if not mw:
return widget
return mainWindow(mw)
if __name__ == "__main__":
mw = mainWindow(QtWidgets.QApplication.activeWindow())
@csaez
csaez / fonts.conf
Created January 2, 2017 04:11
Fix green border around fonts in GIMP (/etc/gimp/2.0/fonts.conf)
<fontconfig>
<match target="font">
<edit name="rgba" mode="assign">
<const>none</const>
</edit>
</match>
</fontconfig>
@csaez
csaez / resize_row_via_delegate.py
Last active January 4, 2020 16:38
QtreeView: keep aspect ratio when resizing a column
import sys
from PyQt5 import QtWidgets, QtGui, QtCore
def fetch_data():
return [
{
'name': 'horizontal',
'image': {
'colour': (255, 0, 0),
@csaez
csaez / guiThingy.py
Last active August 2, 2019 13:37
Maya: A simple qt gui that can be ran within Maya or as standalone (notice the shebang)
#!/usr/autodesk/maya/bin/mayapy
import sys
for each in ("PySide", "PySide2"):
try:
if each == "PySide2":
_temp = __import__(each, globals(), locals(), ['QtWidgets'], -1)
QtWidgets = _temp.QtWidgets
else:
_temp = __import__(each, globals(), locals(), ('QtGui'), -1)
import unittest
def ikePoleVector(root, mid, end):
result = []
for i in range(len(root)):
v1 = end[i] - root[i]
midV1 = v1 * 0.5
v2 = end[i] - midV1
v3 = mid[i] - v2
vf = mid[i] + v3
@csaez
csaez / ricerocks.py
Created June 15, 2013 10:10
Interactive Programming in Python - Mini-project #8 - "RiceRocks" (Asteroids)
# Mini-project #8 - "RiceRocks" (Asteroids)
#
# 'Introduction to Interactive Programming in Python' Course
# RICE University - coursera.org
# by Joe Warren, John Greiner, Stephen Wong, Scott Rixner
import simplegui
import math
import random
@csaez
csaez / std_modules.py
Created January 7, 2018 03:33
print modules from python std library
import os
import sys
from distutils import sysconfig
def std_modules():
std_lib = sysconfig.get_python_lib(standard_lib=True)
for top, dirs, files in os.walk(std_lib):
for nm in files:
@csaez
csaez / nonblocking_ui.py
Last active January 4, 2018 14:19
multiprocessing gui example
import sys
import multiprocessing
from PyQt5 import QtWidgets
def calc():
# random cpu bound computation
result = 0
for i in range(10 ** 7):
result += i ** 2
@csaez
csaez / pyall
Created November 7, 2017 06:38
Command line to extract __all__ from python files
#!/usr/bin/python
import imp
import sys
def main(filepath):
module = imp.load_source('foo', filepath)
entities = [repr(x) for x in dir(module) if not x.startswith('__')]
if entities:
text = ', '.join(entities)