Skip to content

Instantly share code, notes, and snippets.

Avatar

Al-buharie harieamjari

View GitHub Profile
View calc.c
/* 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>
@harieamjari
harieamjari / diwav.c
Last active Jan 26, 2021
Wave equation
View diwav.c
/*
DO WHAT THE FUCK YOU WANT TO BUT IT'S NOT MY FAULT PUBLIC LICENSE
Version 1, October 2013
Copyright (c) 2020 Al-buharie Amjari <healer.harie@gmail.com>
Everyone is permitted to copy and distribute verbatim or modified copies
of this license document, and changing it is allowed as long as the name
is changed.
DO WHAT THE FUCK YOU WANT TO BUT IT'S NOT MY FAULT PUBLIC LICENSE TERMS
@harieamjari
harieamjari / sphere.c
Last active Dec 25, 2020
Minimal ray sphere intersection in C
View sphere.c
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <png.h>
#include <assert.h>
struct vec3D {
double x,y,z;
};
@harieamjari
harieamjari / circle.c
Last active Nov 8, 2020
Simple raytracer in C
View circle.c
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <png.h>
#include <assert.h>
int width, height;
int main(int argc, char *argv[]){
if (argc != 4) {printf("usage: %s Pz c r\n", argv[0]); return 1;}
@harieamjari
harieamjari / template_ping.c
Created Oct 27, 2020
Writing libpng template
View template_ping.c
#include <stdio.h>
#include <stdlib.h>
#include <png.h>
int width, height;
int main(){
width = 1500; height = 1000;
char filename[] = "t.png";
/*open stream */
@harieamjari
harieamjari / project.c
Last active Jan 26, 2021
Project a 3D vector to a 2D plane.
View project.c
/*
DO WHAT THE FUCK YOU WANT TO BUT IT'S NOT MY FAULT PUBLIC LICENSE
Version 1, October 2013
Copyright (c) 2020 Al-buharie Amjari <healer.harie@gmail.com>
Everyone is permitted to copy and distribute verbatim or modified copies
of this license document, and changing it is allowed as long as the name
is changed.
DO WHAT THE FUCK YOU WANT TO BUT IT'S NOT MY FAULT PUBLIC LICENSE TERMS
@harieamjari
harieamjari / mathrix.c
Created Oct 3, 2020
Matrix multiplication of a vertex of a cube.
View mathrix.c
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define _USE_MATH_DEFINES
struct vector {
double x, z, y;
};
@harieamjari
harieamjari / delay_wav.c
Last active Jan 26, 2021
Add a delay line to a s16le mono 44100 wav file.
View delay_wav.c
/*
DO WHAT THE FUCK YOU WANT TO BUT IT'S NOT MY FAULT PUBLIC LICENSE
Version 1, October 2013
Copyright (c) 2020 Al-buharie Amjari <healer.harie@gmail.com>
Everyone is permitted to copy and distribute verbatim or modified copies
of this license document, and changing it is allowed as long as the name
is changed.
DO WHAT THE FUCK YOU WANT TO BUT IT'S NOT MY FAULT PUBLIC LICENSE TERMS
@harieamjari
harieamjari / exp.c
Created Aug 24, 2020
Compute the product of base and exponent.
View exp.c
#include <stdio.h>
#define INF 0x7F800000
int inf = INF;
long double factorial(const int temp) {
if (temp == 0)
return 1.0;
long double fact = 1;
for (int i = 1; i <= temp; i++) {
@harieamjari
harieamjari / t_wav.c
Created Aug 18, 2020
A (not complete) template for writing convolution algorithms in C.
View t_wav.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char wav_struct[] = {
'R', 'I', 'F', 'F',
0, 0, 0, 0, /* chunksize */
'W', 'A', 'V', 'E',
'f', 'm', 't', ' ', /* subchunk1id */
16, 0, 0, 0, /* subchunk1size */