Skip to content

Instantly share code, notes, and snippets.

#include <assert.h>
#include <OpenGL/gl3.h>
#include <SDL2/SDL.h>
int main () {
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS,
SDL_GL_CONTEXT_DEBUG_FLAG |
SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3 );
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/ioctl.h>
@croepha
croepha / merge_dir.cpp
Created August 24, 2018 23:13
filesystem filtering tools
// cro_build:release,noasan,raw, -static-libstdc++
#define _XOPEN_SOURCE 700
#define _POSIX_C_SOURCE 200809L
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/types.h>
#include <dirent.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <assert.h>
using System;
using System.ServiceProcess;
using System.Net.Sockets;
using System.Net;
using System.Text;
public partial class MyService : ServiceBase
{
int main() {
SBDebugger::Initialize();
SBDebugger debugger(SBDebugger::Create());
assert(debugger.IsValid());
debugger.SetAsync(false);
SBStream out_stream;
bool thread2_is_waiting_for_sync = false;
auto mutex = PTHREAD_MUTEX_INITIALIZER;
auto cond_m = PTHREAD_MUTEX_INITIALIZER;
auto cond = PTHREAD_COND_INITIALIZER ;
void* thread1(void*) {
#include <stdio.h>
#include "stb/stretchy_buffer.h"
struct StringStretchyBuffers {
char *string_space;
size_t*strings ;
};
void push_string(struct StringStretchyBuffers*ssb, char*str) {
@croepha
croepha / v1.cpp
Created March 16, 2018 02:10
cpp_template_stretchy_buffers
template<typename T> struct buf_Meta {
size_t len;
size_t cap;
T buf[0];
};
template <typename T> inline buf_Meta<T>& buf__meta(T*b) {
return *(buf_Meta<T>*)((size_t)(b) - __builtin_offsetof(buf_Meta<T>, buf));
}
@croepha
croepha / misc.h
Last active March 15, 2018 17:42
template<class T> void inline system_alloc(T*&ptr, size_t count) {
ptr = (T*)realloc(ptr, count * sizeof(T));
assert(ptr || count == 0);
}
struct DefaultCtrNoCopy { // Thanks mmozeiko!
DefaultCtrNoCopy() = default;
DefaultCtrNoCopy(DefaultCtrNoCopy const&) = delete;
DefaultCtrNoCopy& operator=(DefaultCtrNoCopy const&) = delete;
};