Skip to content

Instantly share code, notes, and snippets.

View MurageKibicho's full-sized avatar
🛼
Working from home

Murage Kibicho MurageKibicho

🛼
Working from home
  • Yale University
  • New Haven, Connnecticut
  • 01:57 (UTC -04:00)
View GitHub Profile
@MurageKibicho
MurageKibicho / main.c
Created April 2, 2024 14:25
FMA's complement Checkpoint
//Compile: gcc main.c -lm -o main.o && ./main.o
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
#include <math.h>
#define FIXEDPT_BITS 32
#include "fixedptc.h"
@MurageKibicho
MurageKibicho / headless.c
Created February 24, 2024 05:33
Iterate through directory in C
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <dirent.h>
#include <string.h>
#include <sys/stat.h>
#define MAX_LENGTH 256
//Ben
@MurageKibicho
MurageKibicho / SDL2Float32.c
Created February 23, 2024 08:09
SDL2 Play float audio
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <SDL2/SDL.h>
#define SAMPLE_RATE 44100
#define CHANNELS 1
#define BUFFER_SIZE 4096
#ifndef AUDIO_F32SYS
#define AUDIO_F32SYS 0x8120
@MurageKibicho
MurageKibicho / Partition.h
Last active February 20, 2024 06:32
GeneratePartitions excluding zero
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <math.h>
int partitionMaxSum = 0;
typedef struct partition_struct Partition;struct partition_struct{int index; int number; int partitionLength; int *partition;};
int PartitionCompareNumber(const void *a, const void *b) {return ((*(Partition *)a).number - (*(Partition *)b).number);}
Partition *CreatePartition(int partitionArrayLength,int partitionLength, int numberBase)
{
@MurageKibicho
MurageKibicho / gist:c833807f02c17e34f92692848062170b
Created February 20, 2024 01:01
Generating pentatopes as the frequencies of sum of digits of numbers in base n, excluding numbers with the digit 0
#include <stdio.h>
#include <stdlib.h>
#define BASE 5
#define LENGTH 5
#define MAX_SUM (BASE * LENGTH - 1)
// Define a structure to hold index, number, and sum of digits
struct NumberInfo {
int index;
def base2_to_base10(binary_string):
return int(binary_string, 2)
def base10_to_base256(decimal_number):
return decimal_number.to_bytes((decimal_number.bit_length() + 7) // 8, 'big')
def base256_to_base10(byte_array):
return int.from_bytes(byte_array, 'big')
def base10_to_base2(decimal_number):
@MurageKibicho
MurageKibicho / gist:485eb5572d6626daf5ea1c2e54c78ef6
Created December 23, 2023 15:41
How to install GSL matrix library on Ubuntu
//sudo apt-get install libgsl-dev
link using -lgsl
// CPP program to generate all unique
// partitions of an integer
//https://www.timvanerven.nl/assets/publications/2010/PhDthesis-TimvanErven.pdf
//https://luna.informatik.uni-mainz.de/mod2-21/slides/S06-Information.pdf
//Bayesian updates the model given past data. i.e the probabilities change whenever new information is given
//I'm a frequentist. Honestly, I don't even think probabilites exist. Probabilities are like astrology signs - super mainstream but
//Meme probability to day trade is similar to astrology girl angry because mercury is in retrograde
#include<iostream>
using namespace std;
#include <stdio.h>
#include <math.h>
void FindResult(int *X, int *Y,int *XR, int *YR,double *affineMap, int XYLength)
{
for(int i = 0; i < XYLength; i++)
{
XR[i] = (int)round(affineMap[0] * (double) X[i] + affineMap[1] * (double)Y[i] + affineMap[4]);
YR[i] = (int)round(affineMap[2] * (double) X[i] + affineMap[3] * (double)Y[i] + affineMap[5]);
printf("(%d,%d) to (%d,%d)\n",X[i], Y[i],XR[i],YR[i]);