This file contains 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> | |
#include <cmath> | |
struct float2 | |
{ | |
float x = 0.0f; | |
float y = 0.0f; | |
float2() {} | |
float2( float _x, float _y ) { x = _x; y = _y; } | |
}; |
This file contains 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
/* | |
The MIT License (MIT) Copyright (c) 2019 Xi Chen | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and | |
associated documentation files (the "Software"), to deal in the Software without restriction, | |
including without limitation the rights to use, copy, modify, merge, publish, distribute, | |
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all copies or substantial |
This file contains 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
#define MEMTRACK_SZ 16000 | |
struct memory_tracker { | |
void* ptr[MEMTRACK_SZ]; | |
int opnums[MEMTRACK_SZ]; | |
int opnum = 0; | |
// Change this to break somewhere. | |
int break_opnum = -1; | |
memory_tracker() { |
This file contains 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
/* | |
The MIT License (MIT) Copyright (c) 2016 UAA Software | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and | |
associated documentation files (the "Software"), to deal in the Software without restriction, | |
including without limitation the rights to use, copy, modify, merge, publish, distribute, | |
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: |
This file contains 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> | |
#include <cstdlib> | |
#include <cassert> | |
#include <string> | |
#include <algorithm> | |
using namespace std; | |
size_t GetFileSize(FILE * fp) | |
{ |
This file contains 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 MAX_COL 750 | |
#define MAX_ROW 750 | |
#define SQ_OFFSET 0 | |
#define RW_OFFSET 81 | |
#define CL_OFFSET 162 | |
#define BX_OFFSET 243 |
This file contains 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
/* make canon; ./canon | aplay -r 44100 -f U8 */ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
#define rs (1.0/44100.0) | |
#define fr(x) (440*pow(2,(x-57)*(1.0/12))) | |
#define s(x, n) sin((x=(x+fr(n)*rs))*6.2831853) | |
#define tf (((1.0/rs)*60.)*.25/160.0) | |
#define gv(c) (c-(c>'9'?('a'-10):'0')) | |
#define gct(i) (gv(ct[(i)*3]) << 8)+(gv(ct[(i)*3+1]) << 4)+(gv(ct[(i)*3+2])) |