Skip to content

Instantly share code, notes, and snippets.

@pezcode
pezcode / server-cross-origin.py
Last active May 20, 2024 14:46
Local HTTP server with COEP+COOP enabled for SharedArrayBuffer
# Based on:
# https://stackoverflow.com/a/21957017
# https://gist.github.com/HaiyangXu/ec88cbdce3cdbac7b8d5
from http.server import SimpleHTTPRequestHandler
import socketserver
import sys
class Handler(SimpleHTTPRequestHandler):
extensions_map = {
@pezcode
pezcode / quat_to_mat3.glsl
Created June 15, 2022 14:05
GLSL quaternion to 3x3 matrix
mat3 quat_to_mat3(vec4 q) {
// multiply by sqrt(2) to get rid of all the 2.0 factors in the matrix
q *= 1.414214;
float xx = q.x*q.x;
float xy = q.x*q.y;
float xz = q.x*q.z;
float xw = q.x*q.w;
float yy = q.y*q.y;
@pezcode
pezcode / spherical_camera.gd
Created October 24, 2020 22:23
Spherical camera mouse controller for Godot
extends Camera
# left mouse = rotate around pivot point
# right mouse = move pivot point left/right/up/down
# scroll wheel = move towards/away from pivot point
export var angular_speed := 1.0
export var movement_speed := 1.0
export var scroll_speed := 1.0
export var pivot := Vector3(0, 0, 0)
@pezcode
pezcode / settings.json
Last active December 10, 2020 15:54
Windows Terminal config (1.4.3243.0)
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"disabledProfileSources":
[
@pezcode
pezcode / projection.hpp
Last active April 23, 2024 14:25
Reversed Z + infinite far plane projection matrices with GLM
// these matrices are for left-handed coordinate systems, with depth mapped to [1;0]
// the derivation for other matrices is analogous
// to get a perspective matrix with reversed z, simply swap the near and far plane
glm::mat4 perspectiveFovReverseZLH_ZO(float fov, float width, float height, float zNear, float zFar) {
return glm::perspectiveFovLH_ZO(fov, width, height, zFar, zNear);
};
// now let zFar go towards infinity
glm::mat4 infinitePerspectiveFovReverseZLH_ZO(float fov, float width, float height, float zNear) {
@pezcode
pezcode / cmder_shell.reg
Created October 6, 2018 21:22
Open cmder [http://cmder.net] from the Windows Explorer right-click context menu. Save to .reg file, change path to your installation of cmder and double-click .reg file.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\cmder]
"Icon"="\"S:\\bin\\cmder\\icons\\cmder.ico\""
@="Open Cmder here"
[HKEY_CLASSES_ROOT\Directory\shell\cmder\command]
@="\"S:\\bin\\cmder\\cmder.exe\" \"%1\""
[HKEY_CLASSES_ROOT\Directory\Background\shell\cmder]
@pezcode
pezcode / cmder_run_bat.reg
Last active October 6, 2018 21:21
Run/double-click .bat files with cmder [http://cmder.net]. Save to .reg file, change path to your installation of cmder and double-click .reg file.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\batfile\shell\open\command]
@="\"S:\\bin\\cmder\\vendor\\conemu-maximus5\\ConEmu64.exe\" -run cmd /k \"%1\""
@pezcode
pezcode / lststyle-VS2017.sty
Created July 1, 2018 01:39
Visual Studio 2017 C++ color scheme for the LaTeX listing package
% VS2017 C++ color scheme
\definecolor{clr-background}{RGB}{255,255,255}
\definecolor{clr-text}{RGB}{0,0,0}
\definecolor{clr-string}{RGB}{163,21,21}
\definecolor{clr-namespace}{RGB}{0,0,0}
\definecolor{clr-preprocessor}{RGB}{128,128,128}
\definecolor{clr-keyword}{RGB}{0,0,255}
\definecolor{clr-type}{RGB}{43,145,175}
\definecolor{clr-variable}{RGB}{0,0,0}
\definecolor{clr-constant}{RGB}{111,0,138} % macro color
@pezcode
pezcode / export_ipynb.py
Last active June 16, 2018 13:32
Export IPython Notebook to presentation slides (this is handy to do from within the notebook)
from nbconvert import SlidesExporter
from traitlets.config import Config
infile = "Notebook.ipynb"
outfile = "Presentation.html"
config = Config({
'SlidesExporter': {
'reveal_theme': 'serif',
'reveal_transition':'fade'
}
@pezcode
pezcode / open_ipynb.bat
Created May 10, 2018 00:30
Open IPython notebooks in Jupyter Lab with a double click on Windows. Just set Windows to open .ipynb files with this .bat
@echo off
cd %~dp0
start jupyter-lab %1