Skip to content

Instantly share code, notes, and snippets.

View davidlatwe's full-sized avatar
:shipit:
Awesome

David Lai davidlatwe

:shipit:
Awesome
View GitHub Profile
@davidlatwe
davidlatwe / daemon.md
Created November 15, 2018 08:45 — forked from andreif/daemon.md
A simple unix/linux daemon in Python

A simple unix/linux daemon in Python

Source: http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/

Access: http://web.archive.org/web/20131025230048/http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/

by Sander Marechal

I've written a simple Python class for creating daemons on unix/linux systems. It was pieced together for various other examples, mostly corrections to various Python Cookbook articles and a couple of examples posted to the Python mailing lists. It has support for a pidfile to keep track of the process. I hope it's useful to someone.

@davidlatwe
davidlatwe / renderSetup_util.py
Last active June 1, 2023 10:12
Query renderSetup overrided attribute value without switching layer
import re
import itertools
from maya import cmds
from maya.app.renderSetup.model import selector as rs_selector
from maya.app.renderSetup.model import renderSettings as rs_render_settings
if float(cmds.about(version=True)) >= 2020.0:
_attr_highest_col = "containerHighest"
@davidlatwe
davidlatwe / forceElement_failed_demo.py
Last active August 21, 2020 06:38
Maya command `sets -forceElement` failed cases
"""
Maya command `sets -forceElement` failed cases
"""
from maya import cmds
CUBE = None
@davidlatwe
davidlatwe / maya_get_visible_in_frame_range.py
Created August 8, 2019 07:24 — forked from BigRoy/maya_get_visible_in_frame_range.py
An optimized Maya function that returns the dag node names that are at least visible once on whole frames between requested start and end frame, this accounts for animated visibilities of the nodes and their parents.
import maya.api.OpenMaya as om2
import maya.cmds as mc
import contextlib
from colorbleed.maya.lib import iter_parents
@contextlib.contextmanager
def maintained_time():
ct = cmds.currentTime(query=True)
from avalon.vendor.Qt import QtWidgets, QtCore, QtGui
from avalon.vendor import qtawesome
from avalon import tools, style
import logging
import threading
import time
main_logger = logging.getLogger()
# -*- coding: utf-8
import os
import pyblish.api
import pyblish_qml
import pyblish_qml.settings
class CreateInstances(pyblish.api.ContextPlugin):
"""Create instance"""
@davidlatwe
davidlatwe / plugins.py
Created September 1, 2019 10:17
Maya scene modification aware via Pyblish
"""Implement scene modification awareness
By tracking Maya's undo queue, if there are any undo command that is not
a simple select after collecting completed, consider this scene has been
modified and require to reset Pyblish.
"""
import collections
@davidlatwe
davidlatwe / get_user_knobs.py
Last active November 29, 2019 07:40
[Nuke] Listing all user defined knobs in given node
import nuke
import re
def list_user_knobs(node):
"""Get user defined knobs
Args:
node (nuke.Node): Nuke node object
@davidlatwe
davidlatwe / demo.py
Created February 4, 2020 19:28
Demonstrate how QQmlContext's property may be garbage collected before QML component gets destroyed and leads to "TypeError: Cannot read property 'foobar' of null" in PySide2
import sys
from PySide2 import QtCore, QtGui, QtQuick
class Data(QtCore.QObject):
color = QtCore.Property(str, fget=lambda _: "purple", constant=True)
if __name__ == '__main__':
@davidlatwe
davidlatwe / pyblish_qml_post_collect_demo.py
Created February 6, 2020 08:48
An example for demoing Pyblish-QML new feature "Post Collect"
import os
import pyblish.api
import pyblish_qml
class CreateToy(pyblish.api.ContextPlugin):
order = pyblish.api.CollectorOrder - 0.2
def process(self, context):
instance = context.create_instance("Bear")