Skip to content

Instantly share code, notes, and snippets.

View jmpinit's full-sized avatar

Owen Trueblood jmpinit

View GitHub Profile
@jmpinit
jmpinit / houdini_python_cheatsheet.py
Created May 24, 2021 12:13
Useful Houdini Python snippets.
# Get the project directory
import os
project_dir = os.path.dirname(hou.hipFile.path())
@jmpinit
jmpinit / Command.h
Created August 25, 2020 18:04
Control Jeff Leonard's painting machine from Python over a serial connection.
#ifndef H_COMMAND
#define H_COMMAND
void log_error(const char* message) {
Serial.print("Error: ");
Serial.println(message);
}
char* next_arg(char* command) {
for (char* c = command; *c != 0; c++) {
@jmpinit
jmpinit / get_github_stars.py
Created August 23, 2020 15:57
Use the GitHub API to retrieve all of a user's stars.
# Combine with https://gist.github.com/jmptable/d961e792902b87f6ffccf0d69d900413
import json
import time
import requests
def get_stars(user):
page = 0
stars = []
while True:
@jmpinit
jmpinit / json_to_csv.sh
Created August 23, 2020 14:46
JSON to CSV with JQ.
# The input file contains an array of objects where each object contains fields that we would like to extract
# as the rows of our CSV file
# https://stedolan.github.io/jq/
# -r is to output raw text instead of JSON
# foo and bar are the fields we are interested in
jq -r 'map([.foo, .bar] | join(", ")) | join("\n")' input.json > output.csv
@jmpinit
jmpinit / profiles.json
Created February 2, 2020 15:46
Using zsh in Cygwin through Windows Terminal.
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{07ece1cb-ff14-4179-a738-1781081fd8be}",
"profiles":
[
{
"guid" : "{07ece1cb-ff14-4179-a738-1781081fd8be}",
"closeOnExit" : true,
@jmpinit
jmpinit / lxd-gui-profile.yaml
Last active December 30, 2019 12:51
LXD profile for creating containers which can run graphical applications. https://owentrueblood.com/blog/containerizing-ros-with-lxd/
# LXD profile for creating containers which can run graphical applications. https://owentrueblood.com/blog/containerizing-ros-with-lxd/
# Based on the profile described at https://blog.simos.info/how-to-easily-run-graphics-accelerated-gui-apps-in-lxd-containers-on-your-ubuntu-desktop/
config:
environment.DISPLAY: :0
# Map our own uid and gid to 1000 in the container
# You may need to change the first number to your UID (use the `uid` command to find out what that is)
raw.idmap: both 1000 1000
description: GUI LXD profile
devices:
X0:
@jmpinit
jmpinit / setup-ros.sh
Last active December 30, 2019 03:24
Setup ROS Melodic in Ubuntu 18.04.
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt update
sudo apt install -y ros-melodic-desktop-full
sudo rosdep init
rosdep update
echo "source /opt/ros/melodic/setup.zsh" >> ~/.zshrc
source ~/.zshrc
@jmpinit
jmpinit / persistent_device_naming_with_udev.md
Last active November 18, 2019 00:53
Using udev for persistent names for USB devices.

/etc/udev/rules.d/10-local.rules

Find the unique info for a given device using: udevadm info -a -n /dev/ttyUSB1

ACTION=="add", ATTRS{idVendor}=="dead", ATTRS{idProduct}=="beef", ATTRS{serial}=="deadbeef", SYMLINK+="ttyFoo"

Reload the udev rules: udevadm control --reload-rules && udevadm trigger

@jmpinit
jmpinit / blender_grease_pencil_drawing.py
Created September 22, 2019 21:48
Starting point for using Python to draw with the Grease Pencil in Blender 2.8.
# https://towardsdatascience.com/blender-2-8-grease-pencil-scripting-and-generative-art-cbbfd3967590
import bpy
import math
import numpy as np
def get_grease_pencil(gpencil_obj_name='GPencil') -> bpy.types.GreasePencil:
"""
Return the grease-pencil object with the given name. Initialize one if not already present.
:param gpencil_obj_name: name/key of the grease pencil object in the scene
@jmpinit
jmpinit / blender-cheatsheet.md
Last active February 27, 2021 18:18
Notes from Blender tutorials.
  1. F9 - shows the options for an operation (the "editing context")
  2. ` - pie menu
  3. alt + middle mouse + drag - changes aligned view (e.g. top or front)
  4. z, shift + z, alt + z - pie menu for display mode, wireframe mode, and toggle xray mode
  5. ctrl + r - add edge loop
  6. ctrl + space - make a panel full screen With Node Wrangler add-on:
  7. ctrl + t - create texture mapping nodes