Skip to content

Instantly share code, notes, and snippets.

View csaez's full-sized avatar

Cesar Saez csaez

View GitHub Profile
@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 / 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
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 / 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)
@csaez
csaez / Cell.qml
Last active October 5, 2017 17:16
Hello QML
import QtQuick 2.5
Item {
id: container
property alias cellColor: rectangle.color
signal clicked(color cellColor)
width: 40; height: 25
Rectangle {
@csaez
csaez / multi_qcompleter.py
Created July 25, 2017 11:39
Multi QCompleter
import re
import sys
from PySide import QtGui
DELIMITERS = r'[,_\s]'
class MultiCompleter(QtGui.QCompleter):
def pathFromIndex(self, index):
@csaez
csaez / smiley.frag
Last active April 17, 2017 16:49
Stupid smiley face shadertoy shader
float circle(vec2 uv, vec2 p, float r, float blur)
{
return smoothstep( r, r-blur, length(uv - p) );
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = ( fragCoord.xy / iResolution.xy ) - .5f;
@csaez
csaez / flake8
Created January 28, 2017 11:07
Flake 8 command
#!/home/csaez/.nvim/py2/bin/python2
# -*- coding: utf-8 -*-
import re
import sys
from flake8.main.cli import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
@csaez
csaez / houdini
Created January 25, 2017 12:52
Houdini launcher
#!/bin/bash
export HOUDINI_OGL_CORE_PROFILE=1
/opt/hfs15.5.620/bin/happrentice