This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
constexpr size_t N = 900; | |
Eigen::Matrix<uint8_t, -1, -1> output(N, N); | |
output.fill(255); | |
std::ofstream ofs("output.pgm", std::ofstream::binary); | |
ofs << "P5\n" | |
<< N << ' ' << N << "\n255\n"; | |
// Otherwise the image will be flipped due to how PGM file format is layed out | |
output.rowwise().reverseInPlace(); | |
ofs.write(reinterpret_cast<char *>(output.data()), N * N * sizeof(uint8_t)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(MSVC) | |
target_compile_options(eigen_vis_cpp PRIVATE $<$<CONFIG:RelWithDebInfo,Debug>:/fsanitize=address>) | |
elseif() | |
target_compile_options(eigen_vis_cpp PRIVATE $<$<CONFIG:RelWithDebInfo,Debug>:-fsanitize=address -fno-omit-frame-pointer>) | |
target_link_options(eigen_vis_cpp PRIVATE $<$<CONFIG:RelWithDebInfo,Debug>-fsanitize=address>) | |
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void skip_line(std::ifstream &ifs) | |
{ | |
// Thanks to Eljay and CPPReference | |
// https://stackoverflow.com/questions/53693218/how-to-skip-a-line-of-standard-input#comment94242047_53693218 | |
// https://en.cppreference.com/w/cpp/string/basic_string/getline#Notes | |
// ifs.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); | |
// also thanks to https://stackoverflow.com/a/72365435/8094047 | |
// and https://jdhao.github.io/2018/12/08/newline_vim_python_sublime_notepad/ | |
// Skip all characters until newline or carriage return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import ctypes | |
def fast_foreach_set_vertices(mesh: bpy.types.Mesh, array: NDArray): | |
# Ultra fast vertices setting | |
# Thanks a ton!: https://blender.stackexchange.com/a/298488/53664 | |
# beware all things could go wrong here! | |
assert array.dtype == np.float32 | |
assert len(array.shape) == 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// License Public Domain | |
// These constants are arbitrary but make sure they do not accidentally collide with other things | |
const animationAttributeName = 'animation__onkeydown_space'; | |
const animationStartEvent = 'onkeydown_space'; | |
AFRAME.registerComponent('simple-jump', { | |
schema: {}, | |
init: function () { | |
var el = this.el; | |
// Thank you!!!: https://stackoverflow.com/a/47019444/8094047 | |
// https://stackoverflow.com/a/51050251/8094047 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mmap | |
from struct import Struct | |
from multiprocessing import Pool | |
import numpy as np | |
from bs4 import BeautifulSoup | |
from selenium import webdriver | |
from selenium.webdriver.chrome.service import Service as ChromeService | |
from selenium.webdriver.common.by import By | |
from webdriver_manager.chrome import ChromeDriverManager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GPLv3 iyadahmed430@gmail.com (Iyad Ahmed) | |
#pragma once | |
#include <chrono> | |
#include <functional> | |
void time_function(const char *message, std::function<void()> function) | |
{ | |
auto start = std::chrono::high_resolution_clock::now(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"[python]": { | |
"editor.defaultFormatter": "ms-python.black-formatter", | |
"editor.formatOnType": false | |
}, | |
"cmake.configureOnOpen": true, | |
"editor.fontFamily": "'Fira Code', 'IntelOne Mono', 'JetBrains Mono', 'Cascadia Code', 'Droid Sans Mono', 'monospace', monospace", | |
"workbench.tree.indent": 20, | |
"cSpell.userWords": [ | |
"AABB", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <type_traits> | |
template <typename Integer, | |
std::enable_if_t<std::is_integral<Integer>::value, bool> = true> | |
static Integer swap_bytes(Integer value) | |
{ | |
Integer out; | |
for (int i = 0; i < sizeof(value); i++) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# All expect last dependency were covered in this answer: https://forum.qt.io/post/636988 | |
sudo apt-get install libxcb-randr0-dev libxcb-xtest0-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-xkb-dev libxkbcommon-x11 |
NewerOlder