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> | |
int const schematic[7][7] = { | |
{0,1,1,1,1,0,0}, | |
{2,0,0,0,0,3,0}, | |
{2,0,0,0,0,3,0}, | |
{0,4,4,4,4,0,0}, | |
{5,0,0,0,0,6,0}, | |
{5,0,0,0,0,6,0}, | |
{0,7,7,7,7,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
static GLfloat const minor = 0.5257311f; | |
static GLfloat const major = 0.8506508f; | |
float const icosahedron_position[12][3] = { | |
{0.f, +minor, +major}, | |
{0.f, +minor, -major}, | |
{0.f, -minor, +major}, | |
{0.f, -minor, -major}, | |
{+major, 0.f, +minor}, | |
{+major, 0.f, -minor}, |
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 <xmmintrin.h> | |
inline int as_int_bitwise(float a) | |
{ | |
return _mm_cvtsi128_si32(_mm_set_ss(a)); | |
} | |
inline float as_float_bitwise(int a) | |
{ | |
return _mm_cvtss_f32(_mm_cvtsi32_si128(a)); |
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 dump_table_threshold = 3 | |
local dump_indent = (" "):rep(4) | |
local dumptable = { | |
["nil"] = tostring, | |
["number"] = tostring, | |
["string"] = function(value) return "\"" .. value .. "\"" end, | |
["boolean"] = tostring, | |
["table"] = function(value, depth, markers) | |
if markers[value] then |
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
float sum(float x0, float x1, float x2) | |
{ | |
float accum = x0 + x1; | |
float excess = (accum - x0) - x1; | |
float addend = x2 - excess; | |
return accum + addend; | |
} |
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 <malloc.h> | |
#include <windows.h> | |
static HANDLE FindCrtHeap() | |
{ | |
// Pick a block that we know is in the CRT heap. | |
// | |
_HEAPINFO crtEntry = {}; | |
if (_HEAPOK != _heapwalk(&crtEntry)) |
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
#ifndef INLINED_OBJECT_H | |
#define INLINED_OBJECT_H | |
#include <string.h> | |
template <typename T, size_t Size> | |
class inlined | |
{ | |
public: | |
inlined(); |
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
// Because it was possible to implement std::move and std::forward<T> as library | |
// functions, so that's what happened. Now this header is everywhere. This is | |
// 2,800 lines of kitchen sink for me. | |
#include <utility> | |
// C++ has half-decent pattern matching, but only on types. If only some of this | |
// energy could be thrown at language constructs like `switch'. | |
// | |
// Oh, right, and this relies on partial specialization, which only works on | |
// classes. So you get these pointless classes that contain a single typedef. |
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
import socket | |
create_socket = lambda: socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP) | |
target_port = 49400 # Any port in the ephemeral port range that no process on your machine is using. | |
port = 0 | |
# Create and bind sockets, working our way through the ephemeral port space, until we get close to our target. | |
while not (target_port - 5 < port < target_port): | |
sock = create_socket() | |
sock.bind(('127.0.0.1', 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
Show hidden characters
{ | |
"shell_cmd": "\"%VS120COMNTOOLS%\\..\\..\\VC\\vcvarsall.bat\" amd64 && cl /nologo \"$file\"", | |
"file_regex": "^(.*?)\\(([0-9+])(?:,([0-9+]))?\\)\\s+:\\s+(.*)$", | |
"working_dir": "${file_path}", | |
"selector": "source.c, source.c++" | |
} |
OlderNewer