Skip to content

Instantly share code, notes, and snippets.

Bjoern Siegert nicelifeBS

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

untitled

Usage

python main.py --amount 100
  • Panning by left-click + drag
  • Scale by rotating the mouse wheel
@nicelifeBS
nicelifeBS / k_eval_cel.py
Created Nov 3, 2017
Katana - Eval cel with python
View k_eval_cel.py
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
nicelifeBS / db_upload.py
Created Jun 25, 2017
dropbox: upload large files
View db_upload.py
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)
else:
@nicelifeBS
nicelifeBS / teleparam.py
Created Feb 25, 2017
Katana: Create a teleparameter
View teleparam.py
def CreateTeleParam(parentParam, targetParam):
teleParam = parentParam.createChildString(
'%sTeleParam' % targetParam.getName(), '')
teleParam.setExpression('getParam("%s").param.getFullName()'
% targetParam.getFullName())
teleParam.setHintString(repr({'widget': 'teleparam'}))
@nicelifeBS
nicelifeBS / katana_layout_widgets.py
Created Feb 24, 2017
KATANA: How to layout widget like Katana does it
View katana_layout_widgets.py
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
nicelifeBS / QItemDelegate.py
Created Sep 5, 2016
QItemDelegate and QAbstractListModel
View QItemDelegate.py
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)
editor.setMinimumHeight(100)
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
nicelifeBS / channelRead.py
Created Jul 28, 2016
modo channel reading API
View channelRead.py
# @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.