Skip to content

Instantly share code, notes, and snippets.

View bohdon's full-sized avatar
🏔️

Bohdon Sayre bohdon

🏔️
View GitHub Profile
@bohdon
bohdon / aggregate_senders.gs
Last active December 25, 2023 20:29
Google app script to aggregate email sender domains by count for finding who sends you the most email.
/**
* A Google app script that gathers threads from your inbox and sorts the
* sender domains by quantity of emails, then outputs to a spreadsheet.
*/
/** Given a sender, return just the domain of the email address. */
function getSenderDomain(sender) {
// parse from '"My Name" <myemail@domain.com>'
var regex = RegExp("(?:<.*@)([^>]*)");
var matches = regex.exec(sender);
@bohdon
bohdon / p4fw_create_standard_client.py
Created April 22, 2023 14:20
Create a standard p4 workspace using the primary root, sgtk user, and current host name.
# Create a standard workspace using the primary root, sgtk user, and current host name.
# Intended to be run in the Python Console from ShotGrid Desktop.
import os
import socket
from pathlib import Path
import sgtk
p4fw = sgtk.platform.framework.load_framework(engine, engine.get_env(), 'tk-framework-perforce2_v0.x.x')
root_path = tk.roots['primary']
@bohdon
bohdon / quill_anim_import.py
Created April 10, 2023 20:29
Imports quill animation into maya directly from the Quill.json.
import sys
import json
def import_anim(path: str):
with open(path) as fp:
data = json.load(fp)
all_layers = get_layers(data)
@bohdon
bohdon / sgtk_app_bg_shotgun_request.py
Last active April 6, 2023 17:03
ShotGrid Toolkit App background shotgun request.
shotgun_data = sgtk.platform.import_framework("tk-framework-shotgunutils", "shotgun_data")
shotgun_globals = sgtk.platform.import_framework("tk-framework-shotgunutils", "shotgun_globals")
shotgun_model = sgtk.platform.import_framework("tk-framework-shotgunutils", "shotgun_model")
task_manager = sgtk.platform.import_framework("tk-framework-shotgunutils", "task_manager")
class MyWidget(QtGui.QWidget):
def __init__(self, parent):
super().__init__(parent)
self._task_manager = task_manager.BackgroundTaskManager(self)
@bohdon
bohdon / unlock_soft_edge_normals.py
Last active January 24, 2023 21:08
Unlock normals on a mesh in Maya, but detect and preserve soft edges.
import pymel.core as pm
def is_soft_edge(edge):
vtx_faces = pm.polyListComponentConversion(edge, fromEdge=True, toVertexFace=True)
expanded_vtx_faces = pm.filterExpand(vtx_faces, expand=True, selectionMask=70)
vtx_faces_by_vtx = dict()
for vtx_face in expanded_vtx_faces:
vtx = pm.polyListComponentConversion(vtx_face, fromVertexFace=True, toVertex=True)
vtx_str = str(vtx)
@bohdon
bohdon / center_twist_joint.py
Created January 24, 2023 19:17
Center a twist joint between it's parent joint and an end joint in Maya.
import pymel.core as pm
def center_twist_joint(twist_joint, end_joint):
"""
Center a twist joint between it's parent and an end joint
"""
root_joint = twist_joint.getParent()
center = (root_joint.getTranslation(space='world') + end_joint.getTranslation(space='world')) / 2.0
twist_joint.setTranslation(center, space='world')
@bohdon
bohdon / sort_nodes.py
Created January 24, 2023 15:49
Sort the selected Maya nodes by name.
import pymel.core as pm
def sort_by_name(nodes):
# get sorted list of nodes
sorted_nodes = sorted(nodes)
for node in sorted_nodes:
pm.reorder(node, back=True)
@bohdon
bohdon / shotgrid_boostrap_maya.py
Created July 11, 2022 14:58
Bootstraps ShotGrid in Maya from a standalone launch.
import sys
# assumes a specific tk-core version is installed, other tk-core acquisition methods are available
tk_core_path = "C:/Program Files/Shotgun/Resources/Desktop/Python/bundle_cache/app_store/tk-core/v0.20.12/python"
# the project id to use for the context
project_id = 369
sys.path.append(tk_core_path)
import sgtk
@bohdon
bohdon / snap_ctls_to_joints.py
Last active August 23, 2021 20:59
Maya snippet to snap controls to joints, update CONTROL_JOINT_MAP with your own mappings
import pymel.core as pm
def snap_ctls_to_joints(ctl_joint_map):
for ctl_name, joint_name in CONTROL_JOINT_MAP.items():
ctl = pm.PyNode(ctl_name)
joint = pm.PyNode(joint_name)
ctl.setMatrix(joint.wm.get(), worldSpace=True)
CONTROL_JOINT_MAP = {
@bohdon
bohdon / rocket_chat_dark_theme.css
Last active August 19, 2021 16:58
A dark theme for Rocket Chat, intended for use with User JavaScript and CSS Chrome plugin
/******************************************
*************General Settings*************
******************************************/
/* Note: Highest CSS priority should be enabled */
:root {
--primary-font-color: #444;
--info-font-color: #a0a0a0;
}