Skip to content

Instantly share code, notes, and snippets.

View harieamjari's full-sized avatar

Al-buharie harieamjari

View GitHub Profile
@harieamjari
harieamjari / calc.c
Last active May 1, 2021 09:46
Calculator
/* Tiny calc
*
* Copyright (c) 2021 Al-buharie Amjari <healer.harie@gmail.com>
*
* This file is license under MIT license
*
*/
#include <ctype.h>
#include <stdio.h>
/* REPLY CHALLENGE
*
* Minimal deterministic parser
*/
#include <stdio.h>
#include <stdlib.h>
#define ERROR(...) fprintf(stderr, __VA_ARGS__)
#define UNEXPECTED(x) {\
if (x!=TOK_ERR) \
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <png.h>
#ifdef NDEBUG
#error "Don't turn NDEBUG!!"
#endif
@harieamjari
harieamjari / 2dwave00.c
Last active April 7, 2021 08:34
2D wave equation solver
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <png.h>
#ifdef NDEBUG
#error "Don't turn NDEBUG!!"
#endif
const int main[] = {
-476053503, -443744256, -442695680, -494927871,
-443744256, -476045300, -509603825, -494858196,
-476053503, -476024828, -285212672, -352321537,
-442695680, -481296284, -905969664, -352321551,
-476053504, -476024831, -285212672, 1819043176,
1634017391, 174617714, -1610612736, 805248739,
225, 2147483420, 1
};
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#define UNEXPECTED(c) \
{ \
if (c != TOK_ERROR) { \
fprintf(stderr, "stream:%d:%d error: unexpected %s\n", line_tok_found, \
column_tok_found, tok_str(c)); \
} \
#include <assert.h>
#include <math.h>
#include <png.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define FRAMES 300
struct vec3D {
double x, y, z;
#include <assert.h> // so I wont have to do error handling
#include <math.h>
#include <png.h> // to output frames as png files
#include <stdio.h> // I/O
#include <stdlib.h>
#include <string.h>
#define FRAMES 50
/* this may be a vertex or a vector */
@harieamjari
harieamjari / half.c
Created April 24, 2021 13:58
Integration of a normal distribution from 0 to +inf
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
static double derivative(double x){
return pow(M_E, -pow(x, 2.0)/2.0)/sqrt(2.0*M_PI);}
int main(int argc, char **argv) {
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
double init_fluid(double x) {
return 100.0 * sin(2.0 * M_PI * 0.4 * x) *
pow(M_E, -pow(x - 15.0, 2.0) / (3.6 * 2.0)) / (3.6 * sqrt(2.0 * M_PI));
}