Skip to content

Instantly share code, notes, and snippets.

@cedarz
cedarz / kill_proc_by_port.cmd
Created June 23, 2025 08:54
kill procedure by port
netstat -ano | findstr 4000
taskkill -PID 43804 -f
@cedarz
cedarz / catmull-rom.js
Created June 23, 2025 08:52 — forked from nicholaswmin/catmull-rom.js
catmull-rom
/* Catmull-Rom interpolating splines in ES6
----
authors: Nicholas Kyriakides (2017) & Unknown
from: "A class of local interpolating splines"
Catmull, Edwin; Rom, Raphael | University of Utah, 1974
Barnhill, Robert E.; Riesenfeld, Richard F. (eds.).
Computer Aided Geometric Design.
@summary
@cedarz
cedarz / formats.txt
Created April 18, 2025 02:28 — forked from Kos/formats.txt
OpenGL image formats along with their unsized variants and preferred formats for pixel transfer (Written by hand, needs verification) Pixel store for compressed textures not provided because there are glCompressedTexImage and family for them. EXT_texture_compression_s3tc formats not included.
| Image format (sized) | Unsized | Compr | Pixel format | Pixel type |
|---------------------------------------|--------------------|-------|--------------------|-----------------------------------|
| GL_R8 | GL_RED | False | GL_RED | GL_UNSIGNED_BYTE |
| GL_R8_SNORM | GL_RED | False | GL_RED | GL_BYTE |
| GL_R16 | GL_RED | False | GL_RED | GL_UNSIGNED_SHORT |
| GL_R16_SNORM | GL_RED | False | GL_RED | GL_SHORT |
| GL_R32F | GL_RED | False | GL_RED | GL_FLOAT |
| GL_R8I | GL_RED | False | GL_RED_INTEGER | GL_INT |
@cedarz
cedarz / gl_texture_format_util.hpp
Created April 18, 2025 02:28 — forked from alexsr/gl_texture_format_util.hpp
OpenGL internal texture format conversion
enum class format : GLenum {
r = GL_RED,
g = GL_GREEN,
b = GL_BLUE,
rg = GL_RG,
rgb = GL_RGB,
bgr = GL_BGR,
rgba = GL_RGBA,
bgra = GL_BGRA,
r_int = GL_RED_INTEGER,
@cedarz
cedarz / projection.hpp
Created February 28, 2025 08:17 — forked from pezcode/projection.hpp
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) {
@cedarz
cedarz / main.cpp
Created February 19, 2025 03:24 — forked from tilkinsc/main.cpp
WGL Full Demo
/**
*
* MIT License
*
* Copyright (c) 2017-2022 Cody Tilkins
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@cedarz
cedarz / conversion.cpp
Created June 17, 2024 02:47 — forked from pezy/conversion.cpp
Encoding Conversion In C++
// Convert a wide Unicode string to an UTF8 string
std::string utf8_encode(const std::wstring &wstr)
{
int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
std::string strTo(size_needed, 0);
WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL);
return strTo;
}
// Convert an UTF8 string to a wide Unicode String
@cedarz
cedarz / chrono_gettime.cpp
Last active February 28, 2024 09:13 — forked from Changes729/chrono_gettime.cpp
[ C/C++ ] function run time.
#include <iostream>
#include <chrono>
using namespace std;
int main(void)
{
// unsync the I/O of C and C++.
ios_base::sync_with_stdio(false);
@cedarz
cedarz / wget.md
Last active August 25, 2025 01:55 — forked from simonw/wget.md
Recursive wget ignoring robots

wget

$ wget -c -m -np -k -p -E -e robots=off 'http://example.com/folder/'
  • -c Continue getting a partially-downloaded file
  • -m This option turns on recursion and time-stamping, sets infinite recursion depth and keeps FTP directory listings. It is currently equivalent to ‘-r -N -l inf --no-remove-listing’
  • -k --convert-links After the download is complete, convert the links in the document to make them suitable for local viewing
  • -p This option causes Wget to download all the files that are necessary to properly display a given HTML page
  • -E cause the suffix ‘.html’ to be appended to the local filename
  • -e robots=off causes it to ignore robots.txt for that domain
  • -r makes it recursive