Skip to content

Instantly share code, notes, and snippets.

@bcrist
bcrist / main.cpp
Created June 10, 2014 15:25
MSVC optimizer bug
#include <iostream>
using namespace std;
int main()
{
int A[12] = {
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1
@bcrist
bcrist / gist:3c15d27fd51d7c7c43b1
Last active March 10, 2016 14:31
Limiting Velocity
MAXIMUM_VELOCITY = <any number>;
SQUARED_MAXIMUM_VELOCITY = MAXIMUM_VELOCITY * MAXIMUM_VELOCITY;
function animate(){
var squared_horizontal_velocity = (x_velocity * x_velocity) + (z_velocity * z_velocity);
if( squared_horizontal_velocity > SQUARED_MAXIMUM_VELOCITY ){
var velocity_magnitude = sqrt(squared_horizontal_velocity);
var scalar = MAXIMUM_VELOCITY / velocity_magnitude;
@bcrist
bcrist / fnv.cpp
Last active January 25, 2021 10:11
256-bit FNV-0, FNV-1, and FNV-1a implementations in C++
#include <cstdint>
#include <cassert>
#include <sstream>
#include <iomanip>
namespace {
typedef uint8_t U8;
typedef uint16_t U16;
typedef uint32_t U32;
@bcrist
bcrist / pushpop.cpp
Created April 12, 2014 03:19
Menu Stack
#include <stack>
#include <memory>
#include <cassert>
// Polymorphic base class for menus
class Menu
{
public:
// Common to all menus:
// (for example)