Skip to content

Instantly share code, notes, and snippets.

Bjoern Siegert nicelifeBS

  • Canada
Block or report user

Report or block nicelifeBS

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
nicelifeBS /
Created Mar 28, 2018 — forked from bradmontgomery/
A python decorator that logs execution time.
from functools import wraps
import logging
logger = logging.getLogger(__name__)
def timed(func):
"""This decorator prints the execution time for the decorated function."""
def wrapper(*args, **kwargs):
start = time.time()
nicelifeBS /
Created Mar 12, 2018
Replace double quotes with single quotes in string
import re
def replace(obj):
if == '\'':
return '"'
if == '"':
return '\''
if == '"""':
nicelifeBS /
Created Dec 19, 2017 — forked from mottosso/
Minimal QML SceneGraph



python --amount 100
  • Panning by left-click + drag
  • Scale by rotating the mouse wheel
nicelifeBS /
Created Nov 3, 2017
Katana - Eval cel with python
prod = NodegraphAPI.GetGeometryProducer()
root = prod.getRootProducer()
cel = root.getAttribute('collections.test.cel').getValue()
node = NodegraphAPI.GetNode('CollectionCreate')
collector = Widget.CollectAndSelectInScenegraph(str(cel), '/root/world/geo')
result = collector.collectAndSelect(select=False, node=node)
nicelifeBS /
Created Jun 25, 2017
dropbox: upload large files
f = open(file_path)
file_size = os.path.getsize(file_path)
CHUNK_SIZE = 4 * 1024 * 1024
if file_size <= CHUNK_SIZE:
print dbx.files_upload(f, dest_path)
nicelifeBS /
Created Feb 25, 2017
Katana: Create a teleparameter
def CreateTeleParam(parentParam, targetParam):
teleParam = parentParam.createChildString(
'%sTeleParam' % targetParam.getName(), '')
% targetParam.getFullName())
teleParam.setHintString(repr({'widget': 'teleparam'}))
nicelifeBS /
Created Feb 24, 2017
KATANA: How to layout widget like Katana does it
import UI4.FormMaster.PythonValuePolicy
# Create a node for which to create parameter widgets
node = NodegraphAPI.CreateNode('Alembic_In', NodegraphAPI.GetRootNode())
# Get a couple of parameters from the node
addForceExpandParameter = node.getParameter('addForceExpand')
addBoundsParameter = node.getParameter('addBounds')
fpsParameter = node.getParameter('fps')
nicelifeBS /
Created Sep 5, 2016
QItemDelegate and QAbstractListModel
import sip
sip.setapi('QVariant', 2)
from PyQt4 import QtCore, QtGui
class SpinBoxDelegate(QtGui.QItemDelegate):
def createEditor(self, parent, option, index):
editor = QtGui.QSpinBox(parent)
View gist:24c667b7090625fdf0df9796b63402c5
import sip
sip.setapi('QString', 2)
sip.setapi('QVariant', 2)
from PyQt4 import QtCore, QtGui
class TableModel(QtCore.QAbstractTableModel):
A simple 5x4 table model to demonstrate the delegates
nicelifeBS /
Created Jul 28, 2016
modo channel reading API
# @author David Ballesteros
# @brief Helper classes to deal with the read and write of Item Channels.
# Based on a ChannelRead class sample code provided by Matt Cox
import lx
class ChannelRead:
def __init__(self, item):
You can’t perform that action at this time.