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 / xrdp-nvidia-setup.sh
Created March 22, 2024 16:13 — forked from Nexarian/xrdp-nvidia-setup.sh
Setup for XRDP using Nvidia Acceleration
#!/usr/bin/env bash
set -e
cd ~
sudo -v
# Make sure system is in a good, updated, clean, state.
sudo apt-get -y update
@davidlatwe
davidlatwe / example.cpp
Created November 23, 2023 19:31 — forked from zekroTJA/example.cpp
Simple C++ asynchronous timer class
/*
COPYRIGHT © 2018 Ringo Hoffmann (zekro Development)
READ BEFORE USING: https://zekro.de/policy
*/
#include "timer.h"
using namespace std;
@davidlatwe
davidlatwe / python_decorator_guide.md
Created December 27, 2021 10:51 — forked from Zearin/python_decorator_guide.md
The best explanation of Python decorators I’ve ever seen. (An archived answer from StackOverflow.)

NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.


Q: How can I make a chain of function decorators in Python?


If you are not into long explanations, see [Paolo Bergantino’s answer][2].

'''
This plugin was ported to python from C++,
All credits by Anno Schachner
original plugin is here https://github.com/wiremas/tension
'''
import sys
import maya.api.OpenMaya as om2
import maya.OpenMaya as om
@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)
@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 / maya2016.sh
Created November 3, 2018 18:05 — forked from stenstorp/maya2016.sh
Installing Maya 2016 SP6 on Ubuntu 16.04 with Student License
#!/bin/bash
#Download Maya from here: http://download.autodesk.com/us/support/files/maya_2016_service_pack_6/Autodesk_Maya_2016_SP6_EN_Linux_64bit.tgz
#Get a student License from: http://www.autodesk.com/education/free-software/maya
#Log in and select maya 2016, your language and an OS. Either should work.
# !!!!!! IMPORTANT !!!!!!
# BEFORE RUNNING, REPLACE "USER" AND "HOME" AT THE BOTTOM OF THIS SCRIPT WITH YOUR USERNAME AND HOME FOLDER
# !!!!!! IMPORTANT !!!!!!
@davidlatwe
davidlatwe / .coveragerc
Created September 9, 2018 07:31 — forked from mattbennett/.coveragerc
coverage subprocess
[run]
branch = True
source = .
@davidlatwe
davidlatwe / cefpython_pyside.py
Created August 14, 2018 10:18 — forked from mmolero/cefpython_pyside.py
CefBrowser using PySide on Windows/Linux/MacOX
from cefpython3 import cefpython
import sys, os
import platform
import ctypes
from PySide.QtGui import *
from PySide.QtCore import *
@davidlatwe
davidlatwe / dict_merge.py
Created March 19, 2018 11:13 — forked from angstwad/dict_merge.py
Recursive dictionary merge in Python
import collections
def dict_merge(dct, merge_dct):
""" Recursive dict merge. Inspired by :meth:``dict.update()``, instead of
updating only top-level keys, dict_merge recurses down into dicts nested
to an arbitrary depth, updating keys. The ``merge_dct`` is merged into
``dct``.
:param dct: dict onto which the merge is executed
:param merge_dct: dct merged into dct