This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local fonts | |
if (jit.os == 'Windows') then | |
fonts = { | |
'DejaVuSansMono Nerd Font Mono', | |
'CaskaydiaCove NF', | |
'Hack NF', | |
'Monofur NF', | |
'VictorMono NF', -- Doesn't work well with telescope | |
'Hurmit NF', -- Doesn't work well with telescope |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io; | |
use std::fs::File; | |
use std::io::Write; | |
use std::mem; | |
use std::slice; | |
#[derive(Clone)] | |
struct Color(u8, u8, u8); | |
struct Image { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Parser for C(++) code, aimed at generating | |
// code instead of using C macros | |
typedef int i32; | |
typedef struct { | |
const char *Code; | |
i32 CodeLength; | |
i32 CurrentLine; | |
} cpp_lexer; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// So, I discovered you can actually iterate over array literals in C++, which is kinda nice, | |
// but only if you include <initializer_list>. As that will drag in >9K LOC from the standard | |
// libraries, I tried implementing my own by trimming the MSVC one, and hey, it works. And | |
// in just 30 LOC (and an stddef.h include I couldn't avoid (for size_t)) | |
// Here it goes, with an example at the end | |
// ---------------------------------->8---------------------------------- | |
#include <stddef.h> | |
namespace std { | |
template <class _Elem> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
// In response to watching Casey Muratori think about in-place de-interleaving of audio samples | |
// in Handmade Hero ep 138, here's a solution for sequences with power-of-two length. | |
// | |
// Algorithm swaps the 2 internal elements in blocks of 4 elems, then grows block size to 8, 16, etc | |
// For example, for a sequence of length 8: | |
// a,1,b,2,c,3,d,4 --> a,b,1,2,c,d,3,4 --> a,b,c,d,1,2,3,4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
using namespace std; | |
template <size_t dim> struct c_array { | |
char value[dim]; | |
}; | |
// helper; construct a sequence of non-type template arguments | |
template <size_t... tt_i > struct seq {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a:0 | |
a:1 | |
a:2 | |
a:3 | |
a:4 | |
a:5 | |
a:6 | |
a:7 | |
a:8 | |
a:9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Needed a function would spiral out to cover a tiled world, then remembered these posts by John Carmack: | |
* https://twitter.com/ID_AA_Carmack/status/308678512099852288 | |
* https://twitter.com/ID_AA_Carmack/status/308676302079160320 | |
Derived the solution with an initial implementation that uses several arrays to calculate positions, | |
then removed those array values for a more compact implementation. There's probably still room for | |
improvement, though. | |
It uses uniform initialisation from c++11, so you'll have to enable compiler support for it if you want |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
template <int T> void func(){printf("Number %d\n", T);} | |
typedef void (*functype)(); | |
template <int T> struct funcs | |
{ | |
funcs<T-1> rest ; | |
functype f ; |