Skip to content

Instantly share code, notes, and snippets.

@Keyframe
Keyframe / template.sh
Created March 6, 2024 09:51
bash template
#!/usr/bin/env bash
set -o errexit -o errtrace -o pipefail -o nounset
function warn() {
>&2 echo "$@"
}
function die() {
local ec=$?; if (( ec == 0 )); then ec=1; fi
warn "$@"; warn "died. backtrace:"
@Keyframe
Keyframe / sdltest.c
Created July 17, 2023 21:45
Static link SDL2
// SDL2 Hello, World!
// This should display a white screen for 2 seconds
// compile with: clang++ main.cpp -o hello_sdl2 -lSDL2
// run with: ./hello_sdl2
#include <SDL2/SDL.h>
#include <stdio.h>
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
@Keyframe
Keyframe / Makefile
Created September 6, 2018 18:17
Generic C Makefile (regular)
TARGET = prog
CFLAGS = -std=c99 -pedantic -Wno-format -Wall -Werror -Wno-unused -Wshadow -O9
LIBS =
LFLAGS =
.PHONY: default all clean
default: $(TARGET)
all: default
@Keyframe
Keyframe / Makefile
Created August 31, 2018 21:52
Generic C Makefile - MinGW
TARGET = prog
CFLAGS = -std=c99 -pedantic -Wno-format -Wall -Werror -Wno-unused -Wshadow -O9
LIBS = -luser32 -lgdi32
LFLAGS = -Wl,-subsystem,windows
.PHONY: default all clean
default: $(TARGET)
all: default
#ifndef BGFX_MESHLOAD_H_BOFRG7SR
#define BGFX_MESHLOAD_H_BOFRG7SR
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
// #include "../extlib/build/osx/release/bgfx/include/bgfx/c99/bgfx.h"
#define DG_DYNARR_IMPLEMENTATION
#include "DG_dynarr.h" // DG_dynarr.h from https://github.com/DanielGibson/Snippets to emulate std::vector
@Keyframe
Keyframe / mingwget.sh
Created October 3, 2016 12:56 — forked from drewwells/mingwget.sh
Cross compile windows on OS X with mingw
#!/bin/sh
# check_error my_cmd --param ...
check_error() {
$* # we execute everything
if [ $? -ne 0 ]; then
echo "check_error(): erreur avec la commande suivante:"
echo "check_error(): $*"
echo "check_error(): Continuer? o/n"
read a
@Keyframe
Keyframe / arr_test_simd_nobuf.c
Created November 13, 2015 01:35
Memory bandwidth, stupid
/*
gcc -pedantic -std=c99 -Wall -Werror -Wextra -Wno-unused -I "[glfw_include_path]" -L "[glfw_lib_path]" arr_test_simd_nobuf.c -o arr_test_simd_nobuf -lglfw3 -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
if AVX on OSX (-mavx doesn't really work with as/homebrew combo - SO USE THIS if on OSX):
clang -pedantic -std=c99 -Wall -Werror -Wextra -Wno-unused -I "[glfw_include_path]" -L "[glfw_lib_path]" arr_test_simd_nobuf.c -o arr_test_simd_nobuf -lglfw3 -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo -mavx
optional: -fprefetch-loop-arrays
*/
#pragma clang diagnostic ignored "-Wunused-parameter"
@Keyframe
Keyframe / gist:6253357
Last active December 21, 2015 04:59
extra lazy change in concat.sh from ttygif in order to work with png files from my gist when creating an animated gif.
#!/bin/bash
output=${1-"output.gif"}
prev_delay=0
skipped=0
gifs=$(find . -name '*.png'| grep -v "$output" | sort | xargs)
# remove -loop 0 if you don't want it to repeat
_convert="convert -loop 0 "
@Keyframe
Keyframe / gist:6253339
Created August 16, 2013 20:39
ttygif OSX hack for iTerm
take_snapshot(int index, int delay, char* window_id)
{
static char cmd [256];
/*if (sprintf(cmd, "import -window %s %05d_%d.gif", window_id, index, delay) < 0) {
return -1;
}*/
if (sprintf(cmd, "screencapture -l$(osascript -e 'tell app \"iTerm\" to id of window 1') -o -m %05d_%d.png", index, delay) < 0) {
return -1;