Skip to content

Instantly share code, notes, and snippets.

View pampanelson's full-sized avatar

WangJunKai pampanelson

  • China Shanghai
View GitHub Profile
import bpy
# https://blender.stackexchange.com/questions/5281/blender-sets-compute-device-cuda-but-doesnt-use-it-for-actual-render-on-ec2
bpy.context.user_preferences.addons['cycles'].preferences.compute_device_type = 'CUDA'
bpy.context.user_preferences.addons['cycles'].preferences.devices[0].use = True
bpy.context.scene.cycles.device = 'GPU'
bpy.data.scenes["Scene"].render.filepath = "/tmp/output.png"
bpy.ops.render.render(write_still=True)
# https://blender.stackexchange.com/q/57306/3710
bl_info = {
"name": "Add-on Template",
"description": "",
"author": "p2or",
"version": (0, 0, 3),
"blender": (2, 80, 0),
"location": "3D View > Tools",
"warning": "", # used for warning icon and text in addons panel
@pampanelson
pampanelson / 1.rreaddir.js
Created February 4, 2020 07:14 — forked from timoxley/1.rreaddir.js
async/await recursive fs readdir
import { join } from 'path'
import { readdir, stat } from 'fs-promise'
async function rreaddir (dir, allFiles = []) {
const files = (await readdir(dir)).map(f => join(dir, f))
allFiles.push(...files)
await Promise.all(files.map(async f => (
(await stat(f)).isDirectory() && rreaddir(f, allFiles)
)))
return allFiles
@pampanelson
pampanelson / subprocess_pipe.md
Created April 5, 2020 07:47 — forked from waylan/subprocess_pipe.md
Writing to a python subprocess pipe

Here's a few things I tried to write output to a python subprocess pipe.

from subprocess import Popen, PIPE

p = Popen('less', stdin=PIPE)
for x in xrange(100):
    p.communicate('Line number %d.\n' % x)
import bpy
# current scene
scn = bpy.context.scene
# path to the blend
filepath = "/path/to/file.blend"
# name of object to import
obj_name = "Cube"
@pampanelson
pampanelson / runblender.ipynb
Created May 4, 2020 02:09 — forked from donmahallem/README.md
This script can be used to render with blender on google collab
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pampanelson
pampanelson / LogExportButton.cs
Created June 5, 2020 02:27
Unity Debug.Log exporter
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Text;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
#!/bin/bash -e
ln -s /usr/lib/x86_64-linux-gnu/amdgpu-pro .
ln -s /etc/OpenCL .
tar -czvf libs.tar.gz amdgpu-pro/*
tar -czvf conf.tar.gz OpenCL/*
cat > .dockerignore << EOF
OpenCL
@pampanelson
pampanelson / host-setup.sh
Created June 23, 2020 01:09 — forked from tomzo/host-setup.sh
Running docker with X on host and GPU acceleration - PoC
#!/bin/bash
# Install host GPU drivers
# ...
# Start a bare X-server
X :0 &
# Make it possible to connect from other hosts
export DISPLAY=:0
xhost +
@pampanelson
pampanelson / fix.md
Created July 5, 2020 14:03 — forked from alepez/fix.md
Ubuntu 16.04 (EE) xf86OpenConsole: Cannot open virtual console 2 (Permission denied)
sudo apt-get install xserver-xorg-legacy

Edit /etc/X11/Xwrapper.config

allowed_users=anybody
needs_root_rights=yes