Skip to content

Instantly share code, notes, and snippets.

View michaeltrainor's full-sized avatar
:octocat:
Riding in a giant-spinning-molten-crust-ball spaceship.

haktwld michaeltrainor

:octocat:
Riding in a giant-spinning-molten-crust-ball spaceship.
View GitHub Profile
@michaeltrainor
michaeltrainor / delete_all.py
Last active September 24, 2015 15:21
This is a convenience function that deletes all items in a given path and the path itself. The use of 'robocopy' ensures that paths that exceed the 255 character limitation are removed.
# standard libraries
import os
import sys
import subprocess
__author__ = "Michael Trainor (http://www.mtrainor.com)"
__gist__ = "git@gist.github.com:f2a849dd0051d35bc2ba.git"
# usage
""" python.exe delete_all.py {your_path} """
@michaeltrainor
michaeltrainor / spot_locator.py
Created January 22, 2016 07:34
Spot Locator WIP
import pymel.core as pm
selection = pm.ls(sl=True)
for index, node in enumerate(selection):
position = None
if isinstance(node, pm.Component):
if isinstance(node, pm.MeshVertex):
@michaeltrainor
michaeltrainor / MayaDockingClass.py
Created May 18, 2017 19:30 — forked from liorbenhorin/MayaDockingClass.py
Maya 2017 PySide2 Docking Qt QMainWindow
"""
This is what you need to do in order to get a qt window to dock next to maya channel box,
In all maya versions, including 2017 with PySide2
"""
__author__ = "liorbenhorin@gmail.com"
import sys
import os
import logging
import xml.etree.ElementTree as xml
# standard libraries
import os
import sys
import json
import traceback
class JSONDict(dict):
def __init__(self, file_path, sort_keys=False, *args, **kwargs):
super(JSONDict, self).__init__(*args, **kwargs)
@michaeltrainor
michaeltrainor / registry_queries.py
Created August 30, 2017 08:54
Hey there! Here's a quick example of how to query the Windows registry via the standard winreg library.
# standard libraries
import platform
import _winreg
def query(key, sub_key, path):
result = None
if platform.architecture()[0] == "32bit":
architecture_ = _winreg.KEY_READ | _winreg.KEY_WOW64_32KEY
# third party libraries
import pymel.core as pm
from PySide import QtGui
menus = [i for i in sorted(pm.lsUI(menus=True)) if isinstance(i.getParent(), pm.ui.Window) and isinstance(i, pm.ui.Menu)]
for i in sorted(menus):
if i.shortName() == "Test":
i.delete()
# third party libraries
import pymel.core as pm
menus = [i for i in sorted(pm.lsUI(menus=True)) if isinstance(i.getParent(), pm.ui.Window) and isinstance(i, pm.ui.Menu)]
for i in sorted(menus):
if i.shortName() == "Test":
i.delete()
break
@michaeltrainor
michaeltrainor / read_file_binary.hpp
Created February 14, 2018 12:00
Read a Binary File to std::vector<BYTE>
#include <fstream>
#include <iterator>
inline std::vector<uint8_t> read_file_binary(const std::string& file_path)
{
std::ifstream file_buffer(file_path, std::ios::binary);
file_buffer.unsetf(std::ios::skipws);
file_buffer.seekg(0, std::ios::end);
const auto size = file_buffer.tellg();
@michaeltrainor
michaeltrainor / .bash_profile
Created February 6, 2019 13:28 — forked from natelandau/.bash_profile
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
@michaeltrainor
michaeltrainor / profile.ps1
Created July 22, 2020 09:52 — forked from timsneath/profile.ps1
PowerShell template profile: adds some useful aliases and functions
### PowerShell template profile
### Version 1.03 - Tim Sneath <tim@sneath.org>
### From https://gist.github.com/timsneath/19867b12eee7fd5af2ba
###
### This file should be stored in $PROFILE.CurrentUserAllHosts
### If $PROFILE.CurrentUserAllHosts doesn't exist, you can make one with the following:
### PS> New-Item $PROFILE.CurrentUserAllHosts -ItemType File -Force
### This will create the file and the containing subdirectory if it doesn't already
###
### As a reminder, to enable unsigned script execution of local scripts on client Windows,