Skip to content

Instantly share code, notes, and snippets.

View pampanelson's full-sized avatar

WangJunKai pampanelson

  • China Shanghai
View GitHub Profile
@pampanelson
pampanelson / watch.py
Created July 15, 2020 13:14 — forked from skrat/watch.py
Auto reload file in blender using asyncio sleep
import os
import bpy
import asyncio
GLB = "/tmp/model.glb"
def import_gltf(path):
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete()
bpy.ops.import_scene.gltf(filepath=path)
@pampanelson
pampanelson / configure_cuda_p70.md
Created July 7, 2020 14:14 — forked from alexlee-gk/configure_cuda_p70.md
Use integrated graphics for display and NVIDIA GPU for CUDA on Ubuntu 14.04

This was tested on a ThinkPad P70 laptop with an Intel integrated graphics and an NVIDIA GPU:

lspci | egrep 'VGA|3D'
00:02.0 VGA compatible controller: Intel Corporation Device 191b (rev 06)
01:00.0 VGA compatible controller: NVIDIA Corporation GM204GLM [Quadro M3000M] (rev a1)

A reason to use the integrated graphics for display is if installing the NVIDIA drivers causes the display to stop working properly. In my case, Ubuntu would get stuck in a login loop after installing the NVIDIA drivers. This happened regardless if I installed the drivers from the "Additional Drivers" tab in "System Settings" or the ppa:graphics-drivers/ppa in the command-line.

@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
@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 +
#!/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 / 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>
@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.
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 / 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)
@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