Skip to content

Instantly share code, notes, and snippets.

""" I needed some unique icons for numerous pyside scripts. This helped.
"""
from PySide import QtCore, QtGui
import sys
import operator
def getIcon(inputStr='', saturation=.8, value=.9, size=128):
""" Creates a QIcon of a single letter on a solid color based on an input
string. The same string will always produce the same background color.
@krets
krets / Nuke: Print Menu
Created April 20, 2014 23:14
Print a given nuke menu
import nuke
def printMenu(menu,indent=0):
if isinstance(menu,basestring):
parts = menu.split("/")
menu = nuke.menu(parts[0])
for i in range(1,len(parts)):
menu = menu.findItem(parts[i])
for x in menu.items():
print "%s%s" % (indent*" ",x.name())
if type(x) == nuke.Menu:
@krets
krets / Clipboard Flip Slashes
Last active August 29, 2015 14:00
ach, whitespace.
"""
Flip slashes in ClipBoard
Now using Tk, so it should be cross-platform.
http://stackoverflow.com/questions/579687
"""
from Tkinter import Tk
w = Tk() # create window object
w.withdraw() # hide window from view.
import sys
import getpass
sentry_url = 'http://<hash>:<hash>@sentry-server.local/1'
try:
import raven
RAVEN_CLIENT = raven.Client(sentry_url)
RAVEN_CLIENT.tags_context({'user':getpass.getuser()})
except:
RAVEN_CLIENT = None
@krets
krets / update_wiretap_anon_usergroup.py
Last active August 29, 2015 14:09
Update Wiretap Anonymous User & Group
import os
import sys
import grp
import pwd
import re
import tempfile
import shutil
import getpass
import logging
@krets
krets / rvFlipBook.py
Last active September 15, 2019 01:01
RV Flipbook for Nuke (with binary discovery)
# http://docs.thefoundry.co.uk/nuke/63/pythondevguide/flipbook.html
# Copyright (c) 2010 The Foundry Visionmongers Ltd. All Rights Reserved.
import glob
import os.path
import platform
import re
import subprocess
import sys
import thread
if [ -r ~/.ssh/known_hosts ]; then
complete -W "$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e 's/,.*//g' | uniq | grep -v "\["`;)" ssh
fi
@krets
krets / slack_leave_bd_channels.py
Last active July 15, 2022 17:39
Quick script to leave a bunch of slack channels with the "bd-" prefix.
#!/usr/bin/env python
import argparse
import requests
import logging
LOG = logging.getLogger("slack_leaver")
class JSONRest(object):
def __init__(self, base_url):
@krets
krets / QtSiteConfig.py
Created January 30, 2018 15:28
Qt.py - QWebEngineView
""" Add the QWebEngineView
Requires Qt.py >=1.1.0
"""
import logging
LOG = logging.getLogger('tx.QtSiteConfig')
def update_members(members):
LOG.debug("update_members")
members['QtWebEngineWidgets'] = ["QWebEngineView","QWebEnginePage"]
""" Test for drawing base64 image strings for job progress
Example Job:
{
'comment': '',
'maxslots': 0,
'numblocked': 0,
'spoolcwd': '/home/freddie/unitard,
'numerror': 0,
'aftertime': None,