Skip to content

Instantly share code, notes, and snippets.

@attilaolah
attilaolah / imgcmp.py
Created February 29, 2012 11:30
Fast image comparison with Python
import math
import Image
import Levenshtein
class BWImageCompare(object):
"""Compares two images (b/w)."""
_pixel = 255
@maty974
maty974 / hideAllViewerQtInfosWidgets.py
Created April 3, 2012 15:11
Hide all Nuke Viwer Qt Infos Widgets
def hideAllViewerQtInfosWidgets():
try:
import PySide.QtGui as QtGui
parentApp = QtGui.QApplication.allWidgets()
parentName = "Viewer"
name = "/"
parentViewer = None
for parent in parentApp:
@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
@knutwalker
knutwalker / imdb_to_trakt.py
Created October 14, 2012 03:29
Migrate movies from a public watchlist from IMDb into your private watchlist on trakt.
#!/usr/bin/env python
import csv
import collections
import re
import json
import requests
@dbridges
dbridges / CustomSortFilterProxyModel.py
Last active December 1, 2022 22:11
A subclass of QSortFilterProxyModel that implements custom filtering, especially useful for multicolumn filtering.
from PySide import QtGui
class CustomSortFilterProxyModel(QtGui.QSortFilterProxyModel):
"""
Implements a QSortFilterProxyModel that allows for custom
filtering. Add new filter functions using addFilterFunction().
New functions should accept two arguments, the column to be
filtered and the currently set filter string, and should
return True to accept the row, False otherwise.
from PySide import QtGui, QtCore
def findDagWidget():
stack = QtGui.QApplication.topLevelWidgets()
while stack:
widget = stack.pop()
if widget.windowTitle() == 'Node Graph':
# You should probably be a little safer with this return, but the actual DAG widget
# seems to be here consistently... if not, it should be the only child of 'widget'
@hzqtc
hzqtc / imgcmp.py
Last active December 16, 2015 10:28
Compare two image mathematically using Perceptual Hash Algorithm. http://hzqtc.github.io/2013/04/image-duplication-detection.html
#!/usr/bin/python
import sys
from PIL import Image
def avhash(im):
if not isinstance(im, Image.Image):
im = Image.open(im)
im = im.resize((8, 8), Image.ANTIALIAS).convert('L')
avg = reduce(lambda x, y: x + y, im.getdata()) / 64.
@dbr
dbr / nuke_viewer_shortcut_intercept.py
Created June 4, 2013 04:12
Test of finding Nuke's viewer widget, and intercepting the hardwired "c" shortcut and rewiring it to view the RGB channel
"""Test of finding Nuke's viewer widget, and intercepting the hardwired "c" shortcut and rewiring it to view the RGB channel
"""
from PySide import QtGui, QtCore
def findviewer():
stack = QtGui.QApplication.topLevelWidgets()
viewers = []
while stack:
@rsgalloway
rsgalloway / gist:5835065
Last active June 3, 2016 08:07
Alembic Build Notes

Alembic Build Notes

Alembic 1.5.1 Boost 1.49 OpenEXR 2.0.1 HDF5 1.8.9

@cleverdevil
cleverdevil / markdown-to-email
Created January 4, 2014 01:06
markdown-to-email A simple script to send beautifully formatted emails that you write in Markdown. The email will have an HTML payload and a plain-text alternative, so you'll make everyone happy, including yourself.
#!/usr/bin/env python
'''
Send an multipart email with HTML and plain text alternatives. The message
should be constructed as a plain-text file of the following format:
From: Your Name <your@email.com>
To: Recipient One <recipient@to.com>
Subject: Your subject line
---