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 <stdint.h> | |
| // Firefox hash or "fxhash". Prefer len to be a compile-time multiple of 8. Zero pad input if necessary. | |
| // This is a rubbish hash function. I just wanted to implement it. | |
| uint64_t fxhash(const uint8_t* s, uint64_t len) | |
| { | |
| const uint32_t ROTATE = 5; | |
| const uint64_t SEED = 0x517CC1B727220A95ULL; | |
| uint64_t state = 0; |
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 <assert.h> | |
| #include <stdio.h> | |
| #include <time.h> | |
| #define COBJMACROS | |
| #include <windows.h> | |
| #include <d3d11_1.h> | |
| #include <d3dcompiler.h> | |
| ////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
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 <assert.h> | |
| #define COBJMACROS | |
| #include <windows.h> | |
| #include <d3d11_1.h> | |
| #include <d3dcompiler.h> | |
| ////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| #define TITLE "D3D11 Triangle C" |
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
| package block_allocator | |
| // Allocator based on Sebastian Aaltonen's Offset Allocator: | |
| // https://github.com/sebbbi/OffsetAllocator/blob/main/offsetAllocator.cpp | |
| import "core:fmt" | |
| import "core:math/bits" | |
| import "core:math/rand" | |
| assert_allocator_layout_good :: proc(allocator: ^Block_Allocator) { |
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> | |
| #define _WINSOCK_DEPRECATED_NO_WARNINGS | |
| #define ENET_IMPLEMENTATION | |
| #include "enet.h" | |
| int main() | |
| { | |
| if (enet_initialize() != 0) | |
| { |
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
| const std = @import("std"); | |
| const ArrayInfo = struct { | |
| rank: usize, | |
| child: type, | |
| }; | |
| fn arrayInfo(comptime artype: type) ArrayInfo { | |
| var rank: usize = 0; | |
| var currentType: type = artype; |
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
| const expect = @import("std").testing.expect; | |
| /// The additive identity for this scalar type. | |
| inline fn zero(comptime T: type) T { | |
| return 0; | |
| } | |
| /// The multiplicative identity for this scalar type. | |
| inline fn one(comptime T: type) T { | |
| return 1; |
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
| const assert = @import("std").debug.assert; | |
| fn make_mask_3_f32(cond: [3]bool) [3]f32 { | |
| var mask: [3]f32 = undefined; | |
| const ar_cond: [3]bool = cond; | |
| comptime var i = 0; | |
| inline while (i < 3) : (i += 1) { | |
| mask[i] = if (ar_cond[i]) 1.0 else 0.0; | |
| } |
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
| package main | |
| import ( | |
| "fmt" | |
| "math/rand" | |
| "time" | |
| ) | |
| // This program starts numProcs goroutines which each generate numSteps random | |
| // numbers and prints the amount of time it takes. |
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
| // This program starts N goroutines which each generate numSteps random | |
| // numbers and prints the amount of time it takes. | |
| // | |
| // See if you can you figure out why it doesn't parallelise properly. | |
| package main | |
| import ( | |
| "fmt" | |
| "math/rand" | |
| "time" |
NewerOlder