Skip to content

Instantly share code, notes, and snippets.

@fredrikaverpil
fredrikaverpil / Dockerfile
Created March 23, 2017 11:30
Postgres running in Docker container
#
# example Dockerfile for https://docs.docker.com/examples/postgresql_service/
#
FROM ubuntu
# Add the PostgreSQL PGP key to verify their Debian packages.
# It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc
RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
@fredrikaverpil
fredrikaverpil / storefunc.py
Last active September 15, 2023 13:31
Store function on Nuke NoOp (or on nuke.root()) node and have it made available upon loading of script
"""Store function on node
Usage example:
.. code-block::
# Control node
ctrl_node_name = 'MY_SCRIPT_NODE' # if None, store on nuke.root()
# Define your functions and add them to the dictionary
@fredrikaverpil
fredrikaverpil / settings.json
Last active November 25, 2016 12:35
vscode settings
// Place your settings in this file to overwrite the default settings
{
// Python, virtualenv (for workspace / project settings)
"python.pythonPath": "${workspaceRoot}/../../virtualenvs/vscode_base",
// "python.pythonPath": "${workspaceRoot}/../../virtualenvs/${workspaceRootFolderName}",
// "python.pythonPath": "${workspaceRoot}/.vscode/venv",
// Python, general
@fredrikaverpil
fredrikaverpil / click2dto3d.py
Last active February 27, 2023 21:15
On Maya click: 2d coordinates to 3d world coordinates
import maya.api.OpenMaya as om
import maya.api.OpenMayaUI as omui
import maya.cmds as cmds
# Maya Python API:
# http://help.autodesk.com/view/MAYAUL/2017/ENU/?guid=__py_ref_index_html
def onPress():
"""Take x,y from mouse click, convert into 3d world coordinates"""
@fredrikaverpil
fredrikaverpil / nuke_screengrab.py
Created October 26, 2016 06:25
Grab the viewer from Nuke
from PySide import QtGui
def grab_widget(widget=None, filepath=None):
"""This is a test and is not proofed for production
Note:
See QPixmap members being obsolete in Qt5:
http://doc.qt.io/qt-5/qpixmap-obsolete.html
"""
@fredrikaverpil
fredrikaverpil / maya_floating_win.py
Last active June 26, 2022 11:45
Window floating atop Maya 2017
from PySide2 import QtWidgets, QtCore
def _maya_main_window():
"""Return Maya's main window"""
for obj in QtWidgets.qApp.topLevelWidgets():
if obj.objectName() == 'MayaWindow':
return obj
raise RuntimeError('Could not find MayaWindow instance')
$ docker run --rm -v $(pwd):/Qt.py mottosso/qt.py
/usr/bin/Xvfb
Initializing built-in extension Generic Event Extension
Initializing built-in extension SHAPE
Initializing built-in extension MIT-SHM
Initializing built-in extension XInputExtension
Initializing built-in extension XTEST
Initializing built-in extension BIG-REQUESTS
Initializing built-in extension SYNC
@fredrikaverpil
fredrikaverpil / pyside2_dynamic.py
Last active January 19, 2020 15:35 — forked from cpbotha/pyside_dynamic.py
pyside_dynamic.py with minor improvements - also see http://stackoverflow.com/a/14894550/532513
from __future__ import (print_function, division, unicode_literals,
absolute_import)
import os
import sys
from PySide2.QtCore import Slot, QMetaObject
from PySide2.QtUiTools import QUiLoader
from PySide2.QtWidgets import QApplication, QMainWindow, QMessageBox
@fredrikaverpil
fredrikaverpil / compile_Qt4_Ubuntu_14.04.sh
Last active June 27, 2016 21:06
Compile Qt4 and PyQt4 on Ubuntu 14.04
apt-get update
apt-get install wget make g++ libxext-dev
wget https://download.qt.io/archive/qt/4.8/4.8.6/qt-everywhere-opensource-src-4.8.6.tar.gz
cd qt-everywhere-opensource-src-4.8.6
# Compilation options: http://doc.qt.io/qt-4.8/configure-options.html#cross-platform-options
./configure -fast
# Qt is now configured for building. Just run 'make'.
@fredrikaverpil
fredrikaverpil / macOS_compile_PySide.sh
Last active December 18, 2020 21:22
PyQt4 & PyQt5
brew install Qt4
brew install openssl
brew install cmake
git clone https://github.com/PySide/pyside-setup.git --recurse-submodules
cd pyside-setup
# The following must be executed in a bash shell
python setup.py bdist_wheel --ignore-git --qmake=/usr/local/Cellar/qt/4.8.7_2/bin/qmake --openssl=/usr/local/Cellar/openssl/1.0.2h_1/bin/openssl --cmake=/usr/local/Cellar/cmake/3.5.2/bin/cmake