Skip to content

Instantly share code, notes, and snippets.

View justinfx's full-sized avatar

Justin Israel justinfx

View GitHub Profile
import matplotlib.pyplot as plt
from random import randint
from time import time
DATA = [
(i, randint(5,30), randint(5,30), randint(30,35), randint(1,5)) \
for i in xrange(1, 401)
]
def mapValues(group):
#move vertices as rod goes over it
import maya.OpenMaya as om
import maya.cmds as cmds
import math as m
class vertexInfo(object):
def __init__(self):
self.verX = []
self.verY = []
self.verZ = []
@justinfx
justinfx / cache_generics.py
Created July 12, 2012 02:17
forwards generic relations
'''
Cache the generic relation field of all the objects
in the queryset, using larger bulk queries ahead of time.
Improved from original by Daniel Roseman:
http://blog.roseman.org.uk/2010/02/22/django-patterns-part-4-forwards-generic-relations/
'''
def cache_generics(queryset):
@justinfx
justinfx / enc_dec_test.py
Last active October 16, 2022 13:28
Speed test of common serializers on python 2.7.2 (pickle, cPickle, ujson, cjson, simplejson, json, yajl, msgpack)
"""
Dependencies:
pip install tabulate simplejson ujson yajl msgpack
"""
from timeit import timeit
from tabulate import tabulate
setup = '''d = {
'words': """
@justinfx
justinfx / float_qslider.py
Created August 22, 2012 17:27
Remapping int values from a PyQt4 QSlider to a new float range
from PyQt4 import QtCore, QtGui
class Window(QtGui.QDialog):
def __init__(self):
super(Window, self).__init__()
self.resize(200,100)
self._new_slider_min = .1
self._new_slider_max = .9
@justinfx
justinfx / shells.py
Created September 17, 2012 17:06
function for returning the selectable shells of a poly
def getShellFaces(poly, asString=False):
shells = set()
faces = set()
total = cmds.polyEvaluate(poly, s=True)
for f in xrange(cmds.polyEvaluate(poly, f=True)):
if len(shells) >= total:
break
if f in faces:
@justinfx
justinfx / animDialog.py
Created September 29, 2012 04:34
Dialog with an animated show event
from PyQt4 import QtCore, QtGui
class AnimatedDialog(QtGui.QDialog):
def __init__(self, parent=None):
super(AnimatedDialog, self).__init__(parent)
self.text = QtGui.QLineEdit(self)
self.text.move(20,20)
@justinfx
justinfx / move_up_or_down.py
Created October 10, 2012 19:32
PyQt4 example of how to move custom widgets up and down in a layout, using a key press UP/DOWN from within the QLineEdit
from PyQt4 import QtGui, QtCore
class RenderManagement(QtGui.QWidget):
def __init__(self):
super(RenderManagement, self).__init__()
self.v_layout = QtGui.QVBoxLayout(self)
# Create 5 dynamic items
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class ListOrderView(QListView):
itemMoved = pyqtSignal(int, int, QStandardItem)
def __init__(self, parent=None):
super(ListOrderView, self).__init__(parent)
@justinfx
justinfx / setup_maya_pyqt.py
Created October 12, 2012 00:00
py2app setup.py script for creating a PyQt4 semi-standalone application. PyQt4 is bundled, while Maya's installation location is referenced for the Python framework
"""
setup.py
py2app setup script for creating a semi-standalone .app
around a Maya API based PyQt4 application.
Only bundled PyQt4 with the app, and references the Maya install
location for the python environment.
Allows for a portable GUI application that does not require