Skip to content

Instantly share code, notes, and snippets.

@bkaradzic
bkaradzic / orthodoxc++.md
Last active May 24, 2024 00:10
Orthodox C++

Orthodox C++

What is Orthodox C++?

Orthodox C++ (sometimes referred as C+) is minimal subset of C++ that improves C, but avoids all unnecessary things from so called Modern C++. It's exactly opposite of what Modern C++ suppose to be.

Why not Modern C++?

// [src] https://github.com/ocornut/imgui/issues/351
// [src] https://github.com/ocornut/imgui/issues/123
// v1.0
#define IMGUI_DOCK_ENABLE_SERIALIZATION 0
// header
// #pragma once
namespace Lumix { namespace FS { class OsFile; } }
@rianhunter
rianhunter / random-read.sh
Created January 18, 2016 18:16
Cron job to read randomly from disk
#!/bin/sh
for a in /dev/sd*1
do
SECTORS=$(/sbin/blockdev --getsize $a)
SECTOR=$(python -c "import random; print random.randint(0, $SECTORS - 1);")
dd if=$a of=/dev/null iflag=direct skip=${SECTOR} bs=512 count=1 2>/dev/null &
done
wait
@nothings
nothings / foo.c
Last active April 14, 2016 18:51
stbwingraph_MenuBegin(NULL); // top-level menu needs no name
stbwingraph_MenuBegin("&File");
stbwingraph_MenuItem(0 , "&New" , MENU_new);
stbwingraph_MenuItem('O', "&Open" , MENU_open);
stbwingraph_MenuItem('S', "&Save" , MENU_save);
stbwingraph_MenuItem(0 , "Save &As...", MENU_save_as);
stbwingraph_MenuItem(0,0,0);
stbwingraph_MenuItem(0 , "&Export", MENU_export);
stbwingraph_MenuItem(0,0,0);
stbwingraph_MenuItemExit("E&xit", MENU_exit);
// Xeno
enum Xeno_Kind {
XENO_POINTER,
XENO_AGGREGATE,
XENO_FIRST_PRIMITIVE_TYPE,
XENO_UINT8 = XENO_FIRST_PRIMITIVE_TYPE,
XENO_UINT16,
XENO_UINT32,
XENO_UINT64,
struct Xeno_Win64CallContext {
void *function_pointer;
uint64_t integer_return_value;
uint64_t floating_point_return_value;
uint64_t register_arguments[4];
uint64_t *stack_arguments;
size_t stack_arguments_count;
};
extern "C" void Xeno_Win64Call(Xeno_Win64CallContext *context);
@rygorous
rygorous / gist:e0f055bfb74e3d5f0af20690759de5a7
Created May 8, 2016 06:54
A bit of background on compilers exploiting signed overflow
Why do compilers even bother with exploiting undefinedness signed overflow? And what are those
mysterious cases where it helps?
A lot of people (myself included) are against transforms that aggressively exploit undefined behavior, but
I think it's useful to know what compiler writers are accomplishing by this.
TL;DR: C doesn't work very well if int!=register width, but (for backwards compat) int is 32-bit on all
major 64-bit targets, and this causes quite hairy problems for code generation and optimization in some
fairly common cases. The signed overflow UB exploitation is an attempt to work around this.
@galloscript
galloscript / imgui_color_gradient.cpp
Last active July 19, 2023 12:17
Gradient color generator and editor for ImGui
//
// imgui_color_gradient.cpp
// imgui extension
//
// Created by David Gallardo on 11/06/16.
#include "imgui_color_gradient.h"
#include "imgui_internal.h"
@flibitijibibo
flibitijibibo / flibitPackaging.md
Created June 17, 2016 16:00
Hope you like reading ldd output!

A week ago I was CC'd in on a thread about Linux packaging, and how to avoid doing it the wrong way (i.e. RPM, Deb, etc.). I've always used MojoSetup and I've never forced distributions to do any additional work, but this is still a new concept to a lot of people. Additionally, Amos suggested that I expand on Itch's FNA appendix, so here's a guide on how I package my games.

This is a bit of an expansion on my MAGFest 2016 presentation, which you can find here:

http://www.flibitijibibo.com/magfest2016/

https://www.youtube.com/watch?v=B83CWUh0Log

I would recommend looking at that first! After that, read on...