Skip to content

Instantly share code, notes, and snippets.

@rygorous
rygorous / gist:c6831e60f5366569d2e9
Last active February 4, 2021 18:56
Please tell me more about your "zero-cost abstractions".
// Conjugate split-radix FFT inner loop
// Both of these compiled with VC++ 2012, 32-bit, "/O2 /fp:fast".
// NOTE: I also tried clang-cl and it seems to be primarily a VC++
// problem. (Which doesn't help me much.)
//
// NOTE 2: argh, did the Clang test wrong. It's still primarily a
// VC++ problem, but Clang has a notable slowdown too. Anyway, new
// results generated automatically from a simpler standalone test
// where I can toggle between versions using a single commandline
@joesavage
joesavage / brainfuck.cpp
Created November 17, 2014 19:28
Brainfuck Compiler/Interpreter
// A small, and relatively primitive, C-style Brainfuck compiler/interpreter.
// Written by Joe Savage, 2014
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <limits.h>
#define STACK_SIZE 512
#define DATA_SIZE 65535
@aras-p
aras-p / preprocessor_fun.h
Last active April 12, 2024 17:24
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@tobitailor
tobitailor / index.html
Created May 14, 2012 12:57
How to implement synchronous(ish) Web Worker tasks in Firefox, using JS1.7 Generators.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script type="application/javascript;version=1.7">
var worker = new Worker('worker.js');
var g;
@rygorous
rygorous / gist:2203834
Created March 26, 2012 08:03
float->sRGB8 using SSE2 (and a table)
// float->sRGB8 conversions - two variants.
// by Fabian "ryg" Giesen
//
// I hereby place this code in the public domain.
//
// Both variants come with absolute error bounds and a reversibility and monotonicity
// guarantee (see test driver code below). They should pass D3D10 conformance testing
// (not that you can verify this, but still). They are verified against a clean reference
// implementation provided below, and the test driver checks all floats exhaustively.
//
@zliuva
zliuva / gist:1084476
Last active July 31, 2023 21:32
A minimal Mach-o x64 executable for OS X
; A minimal Mach-o x64 executable for OS X (also see below Mountain Lion version)
;
; $ nasm -f bin -o tiny_hello tiny_hello.s
; $ chmod +x tiny_hello
; $ ./tiny_hello
; Hello World!
; $
; c.f.
; http://osxbook.com/blog/2009/03/15/crafting-a-tiny-mach-o-executable/ ( the original tiny mach-o executable )