Skip to content

Instantly share code, notes, and snippets.

fbaierl /
Created November 6, 2018 14:17
HOWTO fork a MIT licensed project

No, you are not allowed to change the copyright notice. Indeed, the license text states pretty clearly:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

But you are allowed to add a copyright notice.

If you want to keep the MIT license, which is what I would advise you to do, you only need to add a single line to the license file, before or after Copyright (c) 2012 Some Name with your own copyright notice. The final LICENSE file will look like this:

The MIT License (MIT)

andrewrk / microsoft_craziness.h
Created September 1, 2018 14:35
jonathan blow's c++ code for finding msvc
View microsoft_craziness.h
// Author: Jonathan Blow
// Version: 1
// Date: 31 August, 2018
// This code is released under the MIT license, which you can find at
sherjilozair / sdl-sokol-sprite.c
Created June 9, 2018 14:05
Minimal sprite rendering example with SDL2 for windowing, sokol_gfx for graphics API using OpenGL 3.3 on MacOS
View sdl-sokol-sprite.c
#include <OpenGL/gl3.h>
#include <SDL2/SDL.h>
#define SOKOL_IMPL
#define SOKOL_GLCORE33
#include <sokol_gfx.h>
#include <stb_image.h>
#define CODE(...) #__VA_ARGS__
shafik /
Last active December 6, 2023 08:26
What is Strict Aliasing and Why do we Care?

What is the Strict Aliasing Rule and Why do we care?

(OR Type Punning, Undefined Behavior and Alignment, Oh My!)

What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.

In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.

Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th

roxlu / CMakeLists.txt
Last active March 9, 2023 07:11
CMake example that shows how you can build Freetype2 with support for Harfbuzz and Harfbuzz with support for Freetype2. This example uses ExternalProject which is the standard way to include external dependencies. Note that we have to patch Freetype2 and Harfbuzz because their CMakelists are not fully CMake compatible (still depend on pkg-config…
View CMakeLists.txt
# This CMake file will build Freetype and Harfbuzz as external
# projects. We follow the build description as described here:
# So,
# first we build Freetype2 w/o Harfbuzz, then we build Harfbuzz with
# freetype support after which we rebuild Freetype2 again.
# Both CMake files of Freetype2 and Harfbuzz are depending on
# pkg-config to find the dependencies for both projects. I've
# included a patch for Freetype2 and Harfbuzz which allows you to
# build Freetype2 and Harbuzz with pure CMake features. So I removed
mortennobel / SingleFileOpenGLTex.cpp
Last active November 5, 2023 13:47
Single file OpenGL 3.3 / WebGL (using Emscripten) example with texture (SDL2 / SDL_Image 2)
View SingleFileOpenGLTex.cpp
// Compile for emscripten using
// emcc -Iinclude SingleFileOpenGLTex.cpp \
-O2 -std=c++14 -s TOTAL_MEMORY=33554432 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='["png"]' --preload-file examples/data -s USE_SDL=2 -o html/SingleFileOpenGLTex.html
// where the following images must be located in a subfolder
// - examples/data/test.png
// - examples/data/cartman.png
// - examples/data/cube-negx.png
// - examples/data/cube-negz.png
evilactually / CMakeLists.txt
Created August 8, 2016 21:00
Compiling GLSL to SPIR-V from CMake
View CMakeLists.txt
set(GLSL_VALIDATOR "$ENV{VULKAN_SDK}/Bin/glslangValidator.exe")
set(GLSL_VALIDATOR "$ENV{VULKAN_SDK}/Bin32/glslangValidator.exe")
danielfbm / git2go-checkout-branch.go
Last active June 8, 2023 07:43
How to do a git checkout branch using git2go
View git2go-checkout-branch.go
package main
import (
func checkoutBranch(repo *git.Repository, branchName string) error {
checkoutOpts := &git.CheckoutOpts{
sheredom / VkComputeSample
Created May 29, 2016 19:14
A simple Vulkan compute sample
View VkComputeSample
// This is free and unencumbered software released into the public domain.
// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
// binary, for any purpose, commercial or non-commercial, and by any
// means.
// In jurisdictions that recognize copyright laws, the author or authors
// of this software dedicate any and all copyright interest in the
// software to the public domain. We make this dedication for the benefit