Skip to content

Instantly share code, notes, and snippets.

@emadflash
emadflash / opengl-1.c
Created September 22, 2021 10:33
learnopengl
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <stdio.h>
#include <stdbool.h>
/*
* An iteration of the render loop is more commonly called a frame.
*/
void framebuffer_size_callback(GLFWwindow* window, int width, int height) {
@emadflash
emadflash / weird.c
Created September 7, 2021 16:16
weird things
void error_reporter(const char* sentence, const char* error_message, size_t offset) {
#define extra_error_offset 7
#define extra_error_prefix "^ --- "
#define extra_error_prefix_size 6
u8 n_offset = offset + extra_error_offset;
eprintln("Error: %s", sentence);
eprintln("%*s%s", n_offset, "^", error_message); // this does work
#ifndef FTODO_HPP
#define FTODO_HPP
#include <string_view>
#include <vector>
#include <filesystem>
#include <cstring>
#include <cassert>
#include <memory>
#include <optional>
@emadflash
emadflash / example.c
Created August 24, 2021 11:45
Get request with libcurl
#include <stdio.h>
#include <stdlib.h>
#include <curl/curl.h>
CURL* xcurl_easy_init() {
CURL* curl = curl_easy_init();
if (!curl) exit(0);
return curl;
}
#include <stdio.h>
#include <stdbool.h>
void While(bool *func()) {
LOOP:
if (func()) {
goto LOOP;
} else {
goto DONE;
}
#include <iostream>
#include <optional>
#include <iterator>
#include <fstream>
#include <cassert>
#include <map>
const char* filename = "mfclib/source/file.c";
namespace Utils {
template <typename T, typename It> auto split(It begin, It end, char delm) {
It cursor = begin;
It token;
T sv_line;
std::vector<T> v_sv;
while (cursor != end) {
token = std::find(cursor, end, delm);
if (token != end) {
sv_line = std::string(cursor, token);
struct stringstream {
std::string stream;
stringstream() = default;
stringstream(std::string_view&& sv) : stream { std::move(sv) }
{}
std::string str() {
return stream;
}
#include <stdio.h>
int main()
{
int num = 10;
LOOP:
if (--num) {
printf("%d ", num);
goto LOOP;
}
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
template<typename It, typename OutIt>
OutIt printContainer(It begin, It end, OutIt ot) {