Skip to content

Instantly share code, notes, and snippets.

View justinfx's full-sized avatar

Justin Israel justinfx

View GitHub Profile
@justinfx
justinfx / plow_rebuild.sh
Created June 27, 2013 10:43
A helper shell script to completely rebuild Plow server / client, along with dropping the Postgres plow schema, and building it again. Run with the path to the root of the plow source location as the first argument. Adjust the psql host/port to suit
#!/bin/bash
if [ -z $1 ] || [ ! -d ${1}/server ]; then
echo "plow_rebuild.sh <path to plow source>"
exit 1
fi
realpath1() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}
@justinfx
justinfx / child_window_test.py
Last active December 19, 2015 14:39
Showing a test, inside and outside of Maya, of child windows still remaining alive after being closed. Test can toggle the WA_DeleteOnClose attribute on each child widget:
#!/usr/bin/env python
"""
Showing a test, inside and outside of Maya,
of child windows still remaining alive after being closed.
Test can toggle the WA_DeleteOnClose attribute on each child widget:
# Command line (dont delete)
$ ./child_window_test.py
@justinfx
justinfx / weakmethod_callbacks_qt.py
Last active December 20, 2015 19:29
Example of having thread-safe callbacks from threads back to the main event loop, in PySide/PyQt4. Also adds support for weak method references to the callback, so as not to call something when the original object might have been deleted. Merges forked examples from both: http://code.activestate.com/recipes/81253/#c5 and http://code.activestate.…
"""
ActiveState:
http://code.activestate.com/recipes/578634-pyqt-pyside-thread-safe-callbacks-main-loop-integr/
ref and proxy classes are based on:
http://code.activestate.com/recipes/81253/#c5
Modified proxy to support a quiet concept for callbacks that can
simply pass if they were not valid, instead of raising an exception.
@justinfx
justinfx / colorpot.py
Last active December 16, 2017 12:59
ColorPot widget, with tree widget example for keeping background color in sync
from PyQt4 import QtGui, QtCore
# from PySide import QtGui, QtCore
class ColorPot(QtGui.QFrame):
# colorChanged = QtCore.Signal(QtGui.QColor)
colorChanged = QtCore.pyqtSignal(QtGui.QColor)
def __init__(self, color=None, parent=None):
super(ColorPot, self).__init__(parent)
@justinfx
justinfx / errors.out
Last active December 29, 2015 18:49
Broken cgo / C++ test for Go, trying to wrap OpenColorIO
$ go build -x -v .
# swigtest/ocio
ocio/ocio.cpp:24:16: error: no viable conversion from 'OCIO::ConstConfigRcPtr' (aka 'shared_ptr<const OpenColorIO::v1::Config>') to 'Config *' (aka 'void *')
/usr/include/c++/4.2.1/tr1/boost_shared_ptr.h:678:7: note: candidate function
@justinfx
justinfx / mayaQtEmbedRenderView.py
Last active August 29, 2015 13:56
Maya / PyQt: A variation of https://gist.github.com/justinfx/1381489 where we embed the Render View, instead
from PyQt4 import QtCore, QtGui
import maya.cmds as cmds
import maya.OpenMayaUI as mui
import sip
global app
@justinfx
justinfx / py_cudart_memory.py
Last active January 18, 2016 16:05
Get memory usage of CUDA GPU, using ctypes and libcudart
import ctypes
# Path to location of libcudart
_CUDA = "/Developer/NVIDIA/CUDA-5.5/lib/libcudart.5.5.dylib"
cuda = ctypes.cdll.LoadLibrary(_CUDA)
cuda.cudaMemGetInfo.restype = int
cuda.cudaMemGetInfo.argtypes = [ctypes.c_void_p, ctypes.c_void_p]
cuda.cudaGetErrorString.restype = ctypes.c_char_p
@justinfx
justinfx / qtWidgetLeaks.py
Last active August 29, 2015 14:00
A helper class for monitor widget growth and trying to track if instances are leaking
import pprint
import datetime
from collections import defaultdict
from PySide import QtCore, QtGui
class WidgetLeakWatcher(QtCore.QObject):
"""
Monitor the growth or existance of widgets in
the application, at intervals.
@justinfx
justinfx / convert_imagick.go
Last active August 29, 2015 14:00
comparing OpenImageIGO to iMagick
package main
import (
"github.com/justinfx/imagick/imagick"
"runtime"
)
const (
WIDTH = 320
HEIGHT = 240
@justinfx
justinfx / trans_qt_browser.py
Last active January 16, 2019 07:45
Qt/PySide example of a partially transparent browser window, based on screenshot: http://goo.gl/UiULPU
#!/usr/bin/env python
from PySide import QtCore, QtGui, QtWebKit
class TransWindow(QtGui.QDialog):
"""
Example of a partially transparent browser window
Base on screenshot: http://goo.gl/UiULPU
"""