Skip to content

Instantly share code, notes, and snippets.

@hsab
hsab / bokeh_notebook_image_figure.py
Created March 14, 2021 16:56 — forked from victor-shepardson/bokeh_notebook_image_figure.py
dynamic RGB image figure in bokeh+jupyter for monitoring GAN training, etc. import or paste into cell.
try:
from bokeh.io import push_notebook, output_notebook, show
from bokeh.plotting import figure
output_notebook()
def dynamic_image_figure(w,h):
"""create an RGB image figure in current cell and return an update function for it"""
def im2bokeh(img):
img = (img*255).astype(np.uint8)
img = np.dstack([img, np.ones(img.shape[:2], np.uint8) * 255])
img = np.squeeze(img.view(np.uint32))
@hsab
hsab / worldSpace_to_RenderSpace.py
Created May 22, 2019 20:54
Blender World Space to Render Pixel Space
# from https://blender.stackexchange.com/questions/882/how-to-find-image-coordinates-of-the-rendered-vertex
# ===================
# |(0,0) |
# | |
# | |
# | |
# | (x,y)|
# ===================
import bpy
@hsab
hsab / text.sh
Created April 13, 2019 01:52
convert --> mkbitmap --> potrace
for file in ./Layers\ PNG/*.png; do
filename=$(basename -- "$file")
filename=${filename%.*}
convert $file ./Layers\ BMP/"${filename}.bmp"
done
for file in ./Layers\ BMP/*.bmp; do
filename=$(basename -- "$file")
filename=${filename%.*}
mkbitmap -o ./Layers\ PBM/"${filename}.pbm" -x -t 0.9 -i -b 20 $file
@hsab
hsab / open_text_in_external.py
Created September 5, 2018 03:21
Add a button to Text Editor header to open the file with the default application.
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@hsab
hsab / run-program.ahk
Created September 2, 2018 21:59
Run a program with a keyboard shortcut with AutoHotKey
; This is a simple and pretty generic example of an AutoHotkey script to run a
; program when you press a keyboard shortcut. Add as many of these as you want
; to a .ahk file, and set that to be run at startup.
; See the Hotkeys reference [1] for details of the modifiers and keys available.
; [1]: http://www.autohotkey.com/docs/Hotkeys.htm
; Win+Alt+G - Open Gmail in Chrome
@hsab
hsab / camera_image_plane_fix_for_all.py
Created August 29, 2018 15:48
Blender: Fix depth and ratio of CameraImagePlanes for all scenes
import bpy
from bpy_extras.image_utils import load_image
from mathutils import Vector, Euler
import math
from math import sqrt
C = bpy.context
D = bpy.data
def SetupDriverVariables(scene, driver, imageplane):
@hsab
hsab / import_scenes.py
Last active August 29, 2018 16:12
Blender: Import Scenes from Bunch of Files
import bpy
import os
import ntpath
D = bpy.data
C=bpy.context
path = 'D:\odrive\Cloud\Gutter\Outlier 2.0\Blends'
def listdir_fullpath(d):
@hsab
hsab / CSS SVG Liquid Distortion
Created March 19, 2018 12:06
css-svg-distort.html
<svg width="0" height="0">
<defs>
<filter id="distort">
<feTurbulence baseFrequency=".001" type="fractalNoise" seed="200" />
<feColorMatrix type="hueRotate" values="0">
<animate attributeName="values" from="0" to="360" dur="8s" repeatCount="indefinite" />
</feColorMatrix>
<feDisplacementMap in="SourceGraphic" in2="main" xChannelSelector="R" yChannelSelector="B" scale="200" />
<feGaussianBlur id="blur-amount" stdDeviation="3" />
<feComponentTransfer result="main">
@hsab
hsab / ffmpeg_tut_.md
Last active April 2, 2024 23:14
FFMPEG Tutorial: 2-Pass & CRF in x264 & x265

Google FFMPEG H264

Two-Pass: Requires a bitrate. This defines the quality of the video. Youtube and Vimeo usually reduce your bitrate to 25mbs. So if it is higher, it will be compressed by these websites.

Lower bitrate means lower files size.

Calculating Bitrate:

@hsab
hsab / GLSL-Noise.md
Created October 26, 2017 03:53 — forked from patriciogonzalezvivo/GLSL-Noise.md
GLSL Noise Algorithms

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
	return mix(rand(fl), rand(fl + 1.0), fc);
}