Skip to content

Instantly share code, notes, and snippets.

View Kif11's full-sized avatar
🐁
Expanding digital frontier

Kirill Kovalevskiy Kif11

🐁
Expanding digital frontier
View GitHub Profile
@Kif11
Kif11 / maya-undo-decorator.py
Last active March 2, 2024 09:40 — forked from schworer/undo_dec.py
quick and dirty Maya Python undo decorator
from functools import wraps
from maya import cmds
def undo(func):
""" Puts the wrapped `func` into a single Maya Undo action, then
undoes it when the function enters the finally: block """
@wraps(func)
def _undofunc(*args, **kwargs):
try:
# start an undo chunk
@Kif11
Kif11 / maya-dockable_window.py
Last active October 16, 2023 04:55
PyQt scaffold for creating dockable Maya window
from PySide import QtCore
from PySide import QtGui
from maya.app.general.mayaMixin import MayaQWidgetDockableMixin
class MainWindow(MayaQWidgetDockableMixin, QtGui.QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent=parent)\
@Kif11
Kif11 / current-script-directory.py
Last active August 31, 2016 06:57
Get current script directory
script_dir = os.path.dirname(os.path.realpath(__file__))
@Kif11
Kif11 / import-logging.py
Last active August 31, 2016 06:57
Simple logger import and config
import logging
logging.basicConfig(format='%(levelname)s: %(message)s')
log = logging.getLogger(__file__)
log.setLevel(logging.INFO)
@Kif11
Kif11 / header.py
Last active August 31, 2016 06:56
Python file header comment
#!/usr/bin/env python
# author: Kirill Kovalevskiy
# e-mail: kovalewskiy@gmail.com
@Kif11
Kif11 / run-util.sh
Last active August 31, 2016 06:57
Bash script to facilitade Python module dependency instalation and environment configuration
#!/usr/bin/env bash
# Get this scrip directory
CURDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Set basic environmental variables
export PYTHONPATH="$PYTHONPATH:$CURDIR/lib/python2.7/site-packages"
# Dependencies
DEPENDENCIES=(\
def get_maya_location():
"""
Return maya install location on Windows
Source: https://github.com/JukeboxPipeline/jukebox-core/blob/master/src/jukeboxcore/ostool.py
:returns: path to maya
:rtype: str
:raises: errors.SoftwareNotFoundError
"""
# The supported maya versions
@Kif11
Kif11 / platform
Created February 1, 2017 00:20
Get current OS
platform = {'linux2': 'linux', 'darwin': 'mac', 'win32': 'windows'}[sys.platform]
@Kif11
Kif11 / obj_in_frust.py
Created June 7, 2017 17:11
Maya script to find if object located within camera frustum
import maya.cmds as cmds
import maya.OpenMaya as OpenMaya
import math
# Find if object located within camera frustum
# Usage:
# from obj_in_frust import in_frustum
# in_frustum('camera1', 'pCube1')
class Plane(object):
@Kif11
Kif11 / append_to_sudoers.sh
Last active June 14, 2017 22:28
Safe way to append a line to your sudoers file
# This is a safe way to append a line to your sudoers file
# The validation will be performed with "visudo -c"
# before replacing the sudoers file
if [[ -z $1 ]]; then echo "No line provided to append"; return 1; fi
# Include directive to be appended to sudoers file
include_line=$1
su_bac_file="/var/tmp/sudoers.bac"