Skip to content

Instantly share code, notes, and snippets.

View esnosy's full-sized avatar

Eyad Ahmed esnosy

  • Egypt
  • 12:29 (UTC +03:00)
View GitHub Profile
app: Bforartists
ingredients:
script:
- mkdir -p Bforartists_appimage
- tar xzf ../Bforartists-Linux.tar.gz -C ./Bforartists_appimage --strip-components=1
script:
- cp -r ../Bforartists_appimage/* ./usr/bin/;
- cp ./usr/bin/bforartists.svg .
# https://airbus-seclab.github.io/c-compiler-security/
# TODO: Enable stricter flags for clang
if(CMAKE_COMPILER_IS_GNUCC)
target_compile_options(
tiny_stl
PRIVATE -Wdouble-promotion
-fno-common
-O2
-Werror
-Wall
@esnosy
esnosy / blender_pyqt6.py
Last active January 8, 2023 20:31
How to use PyQt6 in Blender
# tip: you can run Blender using an alternative Python environment to get access to PyQt6
# for example I created a conda environment with PyQt6 installed, then executed blender with these args:
# ~/Downloads/blender-3.4.1-linux-x64/blender --env-system-python /home/iyad/miniconda3/envs/pyqt6/
from PyQt6.QtWidgets import QApplication, QLabel
import bpy
# Process Qt event loop using a Blender timer
# note we do not use app.exec() at the end of the script, it will block Blender
def event_loop_timer():
@esnosy
esnosy / macosx_ctypes_file_dialog.py
Created January 4, 2023 04:16
MacOSX file dailog using Python's Ctypes
# References:
# https://stackoverflow.com/a/1490644/8094047
# https://stackoverflow.com/a/13204738/8094047
# https://developer.apple.com/documentation/objectivec/yes
# https://developer.apple.com/documentation/objectivec/no
# https://mrjean1.github.io/PyCocoa/pycocoa.oslibs-module.html
import ctypes
import ctypes.util
app: Bforartists
ingredients:
script:
- wget -c "https://github.com/Bforartists/Bforartists/releases/download/v${BFORARTISTS_VERSION}/Bforartists-${BFORARTISTS_VERSION}-Linux.tar.xz"
- mkdir -p bforartists
- tar xf Bforartists*.tar.xz -C ./bforartists --strip-components=1
script:
- cp -r ../bforartists/* ./usr/bin/;
pip install pygame --only-binary :all:
python -c "from cairosvg import svg2png;svg2png(open(\"input.svg\").read(), write_to=\"output.png\")"
@esnosy
esnosy / bluetooth_led_controller.ino
Created November 21, 2022 22:32
Bluetooth LED Controller
#include <SoftwareSerial.h>
#define LED_1 4
#define LED_2 5
#define LED_3 6
#define LED_4 7
#define LED_5 8
/* Create object named bt of the class SoftwareSerial */
SoftwareSerial bt(2, 3); /* (Rx,Tx) */
@esnosy
esnosy / in_place_parition.cpp
Created November 18, 2022 19:21
In place partition with unsigned indices (a specific problem)
// In-place partition
uint32_t i = parent_node.first_primitive_index;
uint32_t j = i + parent_node.number_of_primitives;
while (i < j) {
if (triangles[i].cached_centroid[split_axis] < split_pos) {
i++;
} else {
assert(j != 0);
j--;
@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");