Skip to content

Instantly share code, notes, and snippets.

View andreberg's full-sized avatar
💭
I may be slow to respond.

André Berg andreberg

💭
I may be slow to respond.
View GitHub Profile
@andreberg
andreberg / show_all_operators.md
Last active June 4, 2021 13:47
[Show All Operators] Echo all operators as they are executed instead of just REGISTER'ed ones. #blender #python #bpy #api #debug #tricks #tips

While Blender logs operators in the Info editor, this only reports operators with the REGISTER option enabled so as not to flood the Info view with calls to bpy.ops.view3d.smoothview and bpy.ops.view3d.zoom. Yet for testing it can be useful to see every operator called in a terminal, do this by enabling the debug option either by passing the --debug-wm argument when starting Blender or by setting bpy.app.debug_wm to True while Blender is running.

See also Show All Operators

@andreberg
andreberg / macos_disable_startup_sound_catalina.zsh
Last active June 7, 2021 11:55
[Disable macOS Startup Sound] Disable startup chime without muting Volume (pre Big Sur) #macos #terminal #nvram #sounds #disable #catalina
sudo nvram SystemAudioVolume=%80
# If the above command doesn’t work for your particular Mac,
# then try repeating the above steps, but replace the Terminal
# command with one of the following:
sudo nvram SystemAudioVolume=%01
sudo nvram SystemAudioVolume=%00
sudo nvram SystemAudioVolume=" "
@andreberg
andreberg / rename_files.py
Last active May 26, 2021 16:52
[Rename Files] Recursive regex file renamer #python #cli #files #renamer #script #batch #bulk
#!/usr/bin/python
# encoding: utf-8
import os
import re
import sys
import time
import argparse
from datetime import date
@andreberg
andreberg / get_active_object_bpy28.py
Created February 24, 2021 17:54
[Get Active Object] Access selected object from bpy scene context (blender 2.8) #blender #python #scene #context #object #scripting #blender28 #bpy
import bpy
active_object = bpy.context.view_layer.objects.active
@andreberg
andreberg / sphinx_rtd_theme_search_issue_fix.md
Created January 20, 2021 18:32
[Sphinx RTD Theme Search Fix] Fixes the hanging search. #python #documentation #docs #sphinx #read-the-docs #theme #bugfix

In site-packages\sphinx_rtd_theme > layout.html

After

{% if sphinx_version >= "1.8.0" %}
  	<script type="text/javascript" id="documentation_options" data-url_root="{{ pathto('', 1) }}" src="{{ pathto('_static/documentation_options.js', 1) }}"></script>

Add

@andreberg
andreberg / confluence_inline_css_styling.md
Last active January 13, 2021 17:09
[Confluence Inline CSS Styling] Make your inline code literals like paths, variable values etc. look nicer than admin intended. #confluence #css #styles #inline #markup #markdown

In Confluence use the Insert Markup featureset it to Markdown and add any CSS styles you want

for example:

<span style="background-color: #eee; border-top: 1px solid #aaa; border-bottom: 1px solid #aaa; font-family: monospace; padding: 2px;">
//path/to/folder/with/some_file.ext
</span>

easy copy+paste

@andreberg
andreberg / houdini_read_point_attrib_values.py
Created November 17, 2020 17:47
[Read Point Attrib Values] Example for converting quaternions to euler angles. #houdini #hom #python #attribs
# read geometry from input node (otherwise inf recursion error)
n = pwd().inputs()[0]
g = n.geometry()
# here's how you access point attrib values from the geometry
# orient is a list of float values
orient = g.pointFloatAttribValues("orient")
x = orient[0]
y = orient[1]
z = orient[2]
w = orient[3]
@andreberg
andreberg / fix_network_drives_missing_in_elevated_shell.ps1
Last active March 2, 2020 16:20
[From WeakShell to PowerShell] Fixing the broken mess that is 'PowerShell' so it resembles something actually worthy of its name. #powershell #weakshell #fixes #tips
# Reconnect PSDrives for network connections when running with elevated privileges
$elevated = (([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
if( $elevated ) {
net use | ?{ $_ -match ":\s+\\\\" -and !$_.StartsWith("Unavailable") } | %{
$tokens = $_.split(":")
$psdrivename = $tokens[0][$tokens[0].length-1]
$path = $tokens[1].trim().split(" ")[0].trim()
if( !(get-psdrive | ?{ $_.Name -eq $psdrivename } )) {
write-host ( "Restoring PSDrive for {0}: {1}" -f $psdrivename, $path )
@andreberg
andreberg / creating_hard_and_soft_links_in_powershell.ps1
Last active May 9, 2020 19:44
[Creating hard and soft links using PowerShell] #weakshell #powershell #console #terminal #command
@andreberg
andreberg / anaconda_add_custom_env_manually.md
Last active March 2, 2020 15:26
[Anaconda: Add Custom Env Manually] Configure environment with external Python interpreter. #anaconda #python #env #environment

NOTE: This solution is not permanent! Everytime Anaconda Navigator is being used to update the envs, ~/.conda/environments.txt will be re-created which will lose all manually added envs.

Add New Custom Env

  1. Navigate to ~/.conda
  2. Make directory <new_env_name> in ~/.conda/envs
  3. Edit ~/.conda/environments.txt to include ~/.conda/envs/<new_env_name>

Add Pre-Existing Env (soft-linked)