Skip to content

Instantly share code, notes, and snippets.

View esnosy's full-sized avatar

Eyad Ahmed esnosy

  • Egypt
  • 13:22 (UTC +03:00)
View GitHub Profile
@esnosy
esnosy / fread_error_checking.cpp
Created September 5, 2022 01:58
fread wrapper with error checking
// fread wrapper with error checking
static void fread_e(void *output, size_t size, size_t n, FILE *file) {
size_t num_read_items = fread(output, size, n, file);
if (num_read_items != n) {
if (ferror(file)) {
throw std::runtime_error("Error reading file");
} else if (feof(file)) {
throw std::runtime_error("EOF found");
} else {
throw std::runtime_error("Unknown file error");
make lite ninja ccache BUILD_CMAKE_ARGS="-DWITH_GHOST_SDL=ON -DWITH_SDL=ON -DCMAKE_BUILD_TYPE=Release"
@esnosy
esnosy / install_xproto._termux
Last active July 28, 2022 17:52
Install xproto from source on termux android on aarch64 devices
wget https://www.x.org/archive/individual/proto/xproto-7.0.31.tar.gz
tar xvfz xproto-7.0.31.tar.gz
cd xproto-7.0.31
./configure --prefix=/data/data/com.termux/files/usr/local/xproto/7_0_31 --build=aarch64-unknown-linux-gnu
make
make install
# Export before building vscode for example
export PKG_CONFIG_PATH=/data/data/com.termux/files/usr/local/xproto/7_0_31/lib/pkgconfig/
inline bool is_tet_positive(const Vec3 &a, const Vec3 &b, const Vec3 &c, const Vec3 &d)
{
return (a - d).dot((b - d).cross(c - d)) > 0;
}
inline bool do_intersect_segment_tri(const Vec3 &segment_a,
const Vec3 &segment_b,
const Vec3 &tri_a,
const Vec3 &tri_b,
const Vec3 &tri_c)
sudo apt install llvm-12 clang-12 libclang-12-dev
git clone https://github.com/illuhad/hipSYCL
mkdir hipSYCL_build
cd hipSYCL_build
cmake ../hipSYCL -DWITH_ROCM_BACKEND=ON -DLLVM_DIR=/opt/rocm/llvm/lib/cmake/llvm/
sudo make install
@esnosy
esnosy / split_to_manifold_parts.py
Created June 26, 2022 22:32
Split Blender BMesh to manifold patches
non_manifold_verts = [v for v in bm.verts if not v.is_manifold]
for v in non_manifold_verts:
bmesh.utils.vert_separate(v, v.link_edges)
@esnosy
esnosy / clamped_qdobulespinbox.py
Created April 11, 2022 15:36
Python Qt clamped spinbox
# You can ofcourse adapt this to QSpinBox
# And also use PyQt instead of PySide
from PySide2.QtWidgets import QDoubleSpinBox
from PySide2.QtGui import QValidator
class ClampedDoubleSpinbox(QDoubleSpinBox):
def validate(self, text: str, pos: int) -> QValidator.State:
try:
#include <iostream>
using namespace std;
// Reference https://www.asciitable.com/
const char *special_codes[] = {
"null",
"start of heading",
"start of text",
"end of text",
"end of transmission",
@esnosy
esnosy / sum_digits.py
Created March 23, 2022 14:13
Sum of digits in Python
def sum_digits(number: int):
s = 0
while (number > 0):
d = number % 10
s += d
number //= 10
return s
@esnosy
esnosy / green_on_button.svg
Created March 9, 2022 09:00
Green On Button SVG (CC-0)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.