Skip to content

Instantly share code, notes, and snippets.

View caiwan's full-sized avatar
🐺

Caiwan caiwan

🐺
View GitHub Profile
@caiwan
caiwan / 2D-art-collection.md
Last active June 11, 2018 08:41
Art material collection
@caiwan
caiwan / pub_sub_cpp.cpp
Created June 9, 2018 08:51 — forked from makomweb/pub_sub_cpp.cpp
Fun with C++: implementing a pub/sub scenario using std::bind and other standard facilities. The approach is pretty similar to the well known .NET event mechanism.
#include <iostream>
#include <map>
#include <algorithm>
#include <functional>
#include <memory>
using namespace std;
class EventArgs {
public:
@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;