Skip to content

Instantly share code, notes, and snippets.

View cynthia2006's full-sized avatar

Cynthia cynthia2006

  • India
View GitHub Profile
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
// Chained hashmap.
//
// TODO Keep load-factor constant
// TODO Use union instead of void*
struct my_hash_node
{
function setEqual(a, b) {
for (var i = 0; i < a.length; ++i)
if (b.indexOf(a[i]) === -1)
return false;
for (var i = 0; i < b.length; ++i)
if (a.indexOf(b[i]) === -1)
return false;
return true;
@cynthia2006
cynthia2006 / enum-libavdevice.c
Created April 12, 2024 14:20
Enumerate input/output devices discoverable though libavdevice
#include <stdio.h>
#include <libavformat/avformat.h>
#include <libavdevice/avdevice.h>
#include <libavutil/avutil.h>
static char errbuf[AV_ERROR_MAX_STRING_SIZE];
static void print_streams (int i, int ddev, AVDeviceInfo *d)
{
#include <array>
#include <vector>
/* This idea was inspired by how std::tuple<...> is implemented, that is, using std::pair<K, V>
* as linked-lists. The same idea here is applied in a different fashion to create multidimensional
* std::array<T, N> of homogenous types. A std::vector<T> variant is also made.
*/
template<typename T, int N, int ...dims>
class ndarray {
@cynthia2006
cynthia2006 / line-draw.c
Last active August 28, 2024 05:42
Simple SDL2 program to draw lines (left-click and drag to draw lines, right to erase)
#include <SDL2/SDL.h>
#include <stdbool.h>
struct pt_pair {
SDL_Point begin;
SDL_Point end;
};
int main() {
SDL_Init(SDL_INIT_VIDEO);