Skip to content

Instantly share code, notes, and snippets.

View esnosy's full-sized avatar

Eyad Ahmed esnosy

  • Egypt
  • 23:00 (UTC +03:00)
View GitHub Profile
@reduz
reduz / godot_over_time1.md
Last active February 6, 2024 23:55
Godot source code in 2002

This is a walkthrough to the Godot codebase over time. I can't publish full repositories, but I will put here the interfaces of some APIs including the year they were created and how they looked like at the time.

2002, Larvotor

This was the first version of the engine as such. It was later on used to create Regnum Oline. This is source code where I am sure I can still put legally here. Here are some class interfaces.

Mesh class:

@esnosy
esnosy / timer.hpp
Created June 30, 2023 22:40
Neat TIMER macro for C++11
# 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();
import folium
import numpy as np
import pandas as pd
from python_tsp.exact import solve_tsp_dynamic_programming
from sklearn.metrics import DistanceMetric
cities = ["London", "Paris", "Madrid", "Berlin", "Rome"]
print("Cities:", cities, "\n")
# Source: https://www.kaggle.com/datasets/juanmah/world-cities
df = pd.read_csv("worldcities.csv")
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SuddenDevelopment
SuddenDevelopment / facetheworld.py
Created March 9, 2023 18:26
blender python function to orient an object based on a face normal
def faceTheWorld(obj, strMode="EDIT"):
# Thanks to JohnKaz and Kritskiy on BPY Discord for this function, looks simple, but not easy to figure out!
mw = obj.matrix_world.copy()
bm = bmesh.new()
if strMode == 'OBJECT':
bm.from_mesh(obj.data)
else:
bm = bmesh.from_edit_mesh(obj.data)
face = next(iter(face for face in bm.faces if face.select), None)
@semagnum
semagnum / face_raycast.py
Created March 7, 2023 21:08
Blender operator to shoot a ray into the scene and draw a 3D cube on the closest face
import bpy
from bpy_extras import view3d_utils
import gpu
from gpu_extras.batch import batch_for_shader
from mathutils import Vector
def draw(shade, bat):
shade.bind()
shade.uniform_float("color", (1, 0, 0, 0.25))
bat.draw(shade)
import bpy
from bpy.types import SpaceNodeEditor, Area
from bpy.app.timers import register as run_coroutine
from bpy.app.handlers import load_post, persistent
from uuid import uuid4
# Change this name to match the 'NodeTree.bl_idname' of your custom NodeTree class.
node_tree_idname = "CustomNodeTree"
@SuddenDevelopment
SuddenDevelopment / blender_batch_object_transforms.py
Last active March 2, 2023 20:19
a blender function to do a bunch of transforms and then update the view. so that view updates dont need to be run per object
def batchTransform(arrBatch, context=None, update_view=False):
# {
# object: string name_full,
# action: string = SCALE | ROTATE | ORIGIN | MOVE,
# value: (x,y,z), or string for parent or collection name
# mode: LOCAL=relative or adding, WORLD= world coordinates or setting value
# }
# return an array of issues, or empty array if all good.
arrErrors=[]
if context == None:
@m1lkweed
m1lkweed / xsetjmp.c
Last active November 20, 2023 02:35
Assembly-free setjmp in C. Compile with `-znoexecstack` on any optimization level
#pragma once
// (c) M1lkweed, 2022-2023
// Released as GPLv3+
// Differences from normal setjmp:
// 1.) volatile is not required to prevent clobbering
// 2.) sizeof(xjmp_buf) is 8
// 3.) xlongjmp can be used more than once per buffer
// 4.) reading the return value of xsetjmp is not UB
// 5.) all of the points also apply to the sig*jmp family
//This code was generated by Verilator and manually adapted to C++
//Adaptations by Victor Suarez Rovere <suarezvictor@gmail.com>
//original sources https://github.com/BrunoLevy/learn-fpga/blob/master/FemtoRV/README.md
//by Bruno Levy - BSD-3-Clause license
#include "cpu.h"
void cpu_instance::simstep0(uint32_t mbus_rdata0)
{
uint5 __Vdlyvdim0__registerFile__v0;