Skip to content

Instantly share code, notes, and snippets.

View zenmumbler's full-sized avatar
🕳️
There was a HOLE here. It's gone now.

zenmumbler

🕳️
There was a HOLE here. It's gone now.
View GitHub Profile
// -------------------------------------------------------------------------------
// CoreAudio continuous play test
// (c) 2014 by @zenmumbler
// created: 2014-12-07
//
// As part of my efforts for stardazed and to create a Mac OS X version of
// Handmade Hero.
//
// compile with:
// clang++ -std=c++11 -stdlib=libc++ -framework AudioToolbox catest.cpp -o catest
@zenmumbler
zenmumbler / hamahe.m
Created July 26, 2020 13:06
Handmade Hero-like Mac OS X setup and gfx code
// Bare bones Handmade Hero-like functionality (but not in HH coding style)
// Simple graphics, runloop and initialization only, needs a XIB for the menubar etc.
// Compiles as normal Objective-C
// (c) 2014 by @zenmumbler
#import <Cocoa/Cocoa.h>
#import <CoreGraphics/CoreGraphics.h>
#include <stdint.h>
static bool running = false;
@zenmumbler
zenmumbler / coroutine.html
Created July 26, 2020 13:00
Basic Unity-like Coroutines in ES6
<!DOCTYPE html>
<html>
<head>
<title>Basic Unity-like Coroutines</title>
<script>
/*
This example illustrates a simple coroutine controller to act similarly to how Unity's
system works. The payload here is not very exciting but focus on the fact that the actual effort
in a normal usage scenario would just be writing the more() function and starting it somewhere.
This example will run happily in Safari 10+, Edge 13+, Firefox and Chrome.
@zenmumbler
zenmumbler / suso.c
Created July 26, 2020 12:42
SuSo - the happy sudoku solver — live at https://zenmumbler.net/suso/
/**
* SuSo - C version - (c) 2018 by @zenmumbler
* The C version of my implementation of a brute-force Sudoku solver.
* For a web version see https://zenmumbler.net/suso/
* Compiled with -O3 this takes about 2.3ms to solve on my 2013 iMac
* I found the puzzle online by looking for "very hard sudoku"
*/
#include <stdio.h>
#include <stdlib.h>
@zenmumbler
zenmumbler / memoize.cpp
Last active July 26, 2020 13:01
Source file to play with the C++14 memoize method
#include <iostream>
#include <functional>
#include <unordered_map>
#include <chrono>
// This file was tested only in clang 3.4
// It requires -std=c++1y and a stdlib conforming to at least C++11
template <typename T, typename U>
auto memoize(std::function<U(T)>&& f) {