Skip to content

Instantly share code, notes, and snippets.

View Overv's full-sized avatar

Alexander Overvoorde Overv

View GitHub Profile
import std.socket;
import std.stdio;
import std.conv;
static import file = std.file;
import gzip;
const string content = "{}";
void main() {
TcpSocket server = new TcpSocket();
@Overv
Overv / json.d
Last active January 2, 2016 09:19
Convert any D type to JSON automatically through trait/template magic
import std.stdio;
import std.conv;
import std.array;
import std.traits;
class Foo {
Bar nested;
this(Bar nested) {
this.nested = nested;
@Overv
Overv / json.d
Last active January 2, 2016 09:19
Serialize D types to json
module json;
import std.conv;
import std.array;
import std.traits;
string json(T) (T obj) {
static if (is(typeof(obj) == string)) {
return "\"" ~ obj.replace("\\", "\\\\").replace("\"", "\\\"") ~ "\"";
} else static if (isBasicType!(typeof(obj))) {
@Overv
Overv / hello.asm
Created June 5, 2013 14:38
Hello World in x86 assembly with Intel syntax
extern exit, printf
section .data
msg db "Hello World!", 10, 0
section .text
global main
main:
push msg
call printf
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
#define GLM_FORCE_RADIANS
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
@Overv
Overv / Assembler.cpp
Created April 21, 2012 20:31
A simple runtime assembler written in C++
#include "Assembler.hpp"
Assembler::Assembler()
{
}
int Assembler::Run()
{
if ( code.size() == 0 ) return -1;
@Overv
Overv / Makefile
Last active May 30, 2020 09:08
GPU backed BUSE block device
gpu: gpu.cpp
g++ -std=c++11 -O2 -flto -march=native -o gpu gpu.cpp -L. -lbuse -lOpenCL
@Overv
Overv / main.cpp
Created October 31, 2012 21:11
Direct3D 10 Hello World
// Headers
#include <Windows.h>
#include <D3D10.h>
// Parameters
const int WIDTH = 800;
const int HEIGHT = 600;
// Shader
#define SHADER(x) #x
@Overv
Overv / VulkanClear.cc
Last active April 8, 2023 05:30
Vulkan code for clearing the screen
#include <iostream>
#include <vector>
#define GLFW_INCLUDE_VULKAN
#define VK_USE_PLATFORM_WIN32_KHR
#include <GLFW/glfw3.h>
#define GLFW_EXPOSE_NATIVE_WIN32
#include <GLFW/glfw3native.h>
@Overv
Overv / HelloTriangle.cc
Created April 24, 2016 18:54
Vulkan hello triangle
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <chrono>
#include <functional>
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>