Navigation Menu

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 / python.json
Last active February 27, 2024 15:18
[VSCode: Python Snippets] Python snippet collection. #vscode #python #snippets #template #json
{
// Place your snippets for python here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
@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 / PoE-Macros.ahk
Last active June 21, 2022 18:16
[Path of Exile Autohotkey Macros] Shows how to bind some (really outdated!) commands to hotkeys. #pathofexile #poe #ahk #autohotkey #macros
#IfWinActive, Path of Exile ahk_class Direct3DWindowClass
#SingleInstance force
; Menu tooltip
Menu, tray, Tip, Path of Exile Macros
; NOTE: Adjust this path so it is correct.
; If you are using my PoE-Item-Info script you can find
; the tray icons inside its data directory.
Menu, tray, Icon, PoE Item Info\data\poe-web.ico
@andreberg
andreberg / CINEMA 4D Python Helpers.py
Last active March 25, 2022 05:43
[CINEMA 4D: Python Helpers Class] The Helpers class is collection of reusable methods from cgsociety, the Plugin Café and from my own scripts. #cinema4d #c4d #python #class #helpers #computergraphics #cg
class Helpers(object):
"""Contains various helper methods."""
def __init__(self, arg):
super(Helpers, self).__init__()
@staticmethod
def readConfig(filepath=None):
"""
Read settings from a configuration file.
@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 / 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 / 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 / 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]