Skip to content

Instantly share code, notes, and snippets.

View caiwan's full-sized avatar
🐺

Caiwan caiwan

🐺
View GitHub Profile
@caiwan
caiwan / keypad.lua
Created May 8, 2018 23:11
External key macros for Photoshop for a numeric keypad
clear()
local keyboardIdentifier = '16BFD3AF'
lmc_print_devices()
-- assign logical name to macro keyboard
if keyboardIdentifier == '0000AAA' then
lmc_assign_keyboard('MACROS');
else lmc_device_set_name('MACROS', keyboardIdentifier);
@caiwan
caiwan / .vimrc
Created September 21, 2017 08:05
My own vimrc file to make vim more comortable
set encoding=utf-8
set fileencoding=utf-8
filetype plugin indent on
syntax on
set smartindent
set expandtab
set ignorecase
set smartcase
@caiwan
caiwan / add_pbr.py
Last active September 4, 2017 09:13
Handy blender scripts
# quick add pbr texture names to properties
# used in grafkit2
for material in bpy.data.materials:
for key in ["metalness", "normal", "roughness"]:
material["mat_{0}".format(key)] = "pbr_{0}_{1}.jpg".format(material.name, key)
# a bit refined version, which add emissive map if emission was set
for material in bpy.data.materials:
@caiwan
caiwan / bake.py
Created September 1, 2017 13:10
Blender bake
import bpy
def do_bake(scene):
""" This thing tries to bake all the object animations
and camera movement into a single track
Drawback: it eleminates scenegraph hierarchy and flattens everzthing
This suposed to be it, but fingers crossed:
https://wiki.blender.org/index.php/Dev:2.4/Source/Animation/AnimationBaking
@caiwan
caiwan / .bashrc
Last active November 25, 2017 20:43
Bashrc for GitBash on windows to init ssh-agent and load keys
env=~/.ssh/agent.env
agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }
agent_start () {
(umask 077; ssh-agent >| "$env")
. "$env" >| /dev/null ; }
agent_load_env
@caiwan
caiwan / .vimrc
Last active June 7, 2017 13:56
vimrc for py
set encoding=utf-8
set fileencoding=utf-8
filetype plugin indent on
syntax on
set smartindent
set expandtab
set ignorecase
set smartcase
@caiwan
caiwan / launch.json
Created August 20, 2016 15:35
Quick and dirty VScode
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Chrome against localhost, with sourcemaps",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000",
"sourceMaps": true,
"webRoot": "${workspaceRoot}/src/ts/main.ts"
@caiwan
caiwan / BKE_curve_forward_diff_bezier.c.inc
Last active November 14, 2015 10:44
Code snippetst from blender source to interpolate it's own bezier types
/* forward differencing method for bezier curve */
void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride)
{
float rt0, rt1, rt2, rt3, f;
int a;
f = (float)it;
rt0 = q0;
rt1 = 3.0f * (q1 - q0) / f;
f *= f;
import sys
import xml.etree.ElementTree as ET
class XMLBuilder(object):
def __init__(self, _outfile):
self._outfile = _outfile
self._outXML = None
def __enter__(self):
IHR stands for interpolated HiRes.
This basically interpolates two HiRes images, one in even frames, and the
other in odd frames resulting in more colors, and up to 4 colors per 8x8
block. The selection of colors are limited though: they can be a mix of the
colors selected for the two source planes. It also limits mixing that if two
colors which supposed to make the displayed color are too far from each
other, the image will noticably flicker, and will be tiring for the eye to
look at it (Mixing black and white would result in 25Hz or 30Hz pratical
update rate what is simply miserable). There are several combinations though