This file contains hidden or 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
def execute_file_content(file_path): | |
if file_path: | |
with open(file_path, 'r') as file: | |
code = compile( file.read(), file_path, 'exec') | |
exec(code, globals()) | |
print("loaded :", file_path) | |
execute_file_content(r"C:\Users\x\my_module.py") | |
#some_func() |
This file contains hidden or 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
#include <iostream> | |
#include <cstdlib> | |
int executePythonFromCpp(const std::string& file_path_to_python, const std::string& file_path_to_script) | |
{ | |
std::string command = file_path_to_python + " " + file_path_to_script; | |
int result = system(command.c_str()); | |
// Check the result of the system call | |
if (result == 0) { |
This file contains hidden or 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
#include <cstdlib> // for rand and RAND_MAX | |
#include <glm/glm.hpp> | |
glm::vec3 generate_random_position(const glm::vec3& min_value, const glm::vec3& max_value) | |
{ | |
glm::vec3 result; | |
result.x = min_value.x + static_cast<float>(rand()) / static_cast<float>(RAND_MAX) * (max_value.x - min_value.x); | |
result.y = min_value.y + static_cast<float>(rand()) / static_cast<float>(RAND_MAX) * (max_value.y - min_value.y); | |
result.z = min_value.z + static_cast<float>(rand()) / static_cast<float>(RAND_MAX) * (max_value.z - min_value.z); | |
return result; |
This file contains hidden or 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
#include <cstdlib> // for rand() and srand() | |
#include <ctime> // for time() | |
int generate_random_int(int min_value, int max_value) | |
{ | |
srand(time(nullptr)); // seed the random number generator with the current time | |
int range = max_value - min_value + 1; | |
int random_value = rand() % range + min_value; // generate a random integer in the specified range | |
return random_value; | |
} |
This file contains hidden or 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
#include <iostream> | |
#include <fstream> | |
#include <cmath> | |
int write_wav_sound() | |
{ | |
const int SAMPLE_RATE = 44100; | |
const double PI = 3.14159265359; | |
const double FREQUENCY = 440.0; | |
const double DURATION = 2.0; |
This file contains hidden or 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
//To convert this timestamp to a human-readable date and time, you can use JavaScript's Date object. Here's an example: | |
//The output of this code will be a string representation of the date and time in the local time zone of the computer running the code. | |
const timestamp = 1676456193458; | |
const date = new Date(timestamp); | |
console.log(date); |
This file contains hidden or 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
#include <iostream> | |
#include <chrono> | |
#include <thread> | |
struct Timer | |
{ | |
std::chrono::time_point<std::chrono::steady_clock> start, end; | |
std::chrono::duration<float> duration; | |
Timer() |
This file contains hidden or 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
#include <iostream> | |
#include <memory> | |
// we override the new operator globally | |
// By overring the new operator we ara saying don't use the new operator that is in the standard library | |
struct AllocationMetrics | |
{ | |
uint32_t total_allocated = 0; | |
uint32_t total_freed = 0; |
This file contains hidden or 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
#include <iostream> | |
namespace Without_explicit | |
{ | |
struct Entity | |
{ | |
int a; | |
int b; |
This file contains hidden or 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
#include <iostream> | |
#include <string> | |
struct IDescription | |
{ | |
virtual std::string get_description() = 0; | |
}; | |
struct Gallery : public IDescription |