Skip to content

Instantly share code, notes, and snippets.

View abenezeradane's full-sized avatar

Abenezer Adane abenezeradane

View GitHub Profile
@jdah
jdah / network_demo.c
Created January 31, 2024 14:22
the world's most basic client/server
#include <stdio.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netdb.h>
#include <unistd.h>
static void server() {
// create socket
@jdah
jdah / macro_explanation.c
Created January 31, 2024 14:21
explaining some C macro magic
// so a cool trick with macros in C (and C++) is that since macros inside of
// macros are stille evaluated by the preprocessor, you can use macro names as
// parameters to other macros (and even construct macro names out of out of
// parameters!) - so using this trick if we have some macro like
// this:
#include <stddef.h>
#define MY_TYPES_ITER(_F, ...) \
_F(FOO, foo, 0, __VA_ARGS__) \
@abenezeradane
abenezeradane / Application.h
Last active August 16, 2022 02:52
Simple SDL2 window creation implementation in C
#ifndef APPLICATION_H
#define APPLICATION_H
#include <stdio.h>
#include <SDL2/SDL.h>
typedef struct Application {
SDL_Window* window;
char* title;
@jdah
jdah / wfc.hpp
Created August 5, 2022 15:18
Wave Function Collapse
#pragma once
#include "util/types.hpp"
#include "util/std.hpp"
#include "util/ndarray.hpp"
#include "util/collections.hpp"
#include "util/rand.hpp"
#include "util/hash.hpp"
#include "util/assert.hpp"
#include "util/bitset.hpp"
@abenezeradane
abenezeradane / Queue.h
Created July 30, 2022 01:45
Basic Queue implementation in C, what I'm currently using when designing an ECS
#ifndef QUEUE_H
#define QUEUE_H
#define NULL_ITEM 65536
typedef struct Queue {
unsigned int front, rear, size;
unsigned int capacity;
unsigned int* array;
} Queue;
@abenezeradane
abenezeradane / Application.h
Last active August 6, 2022 03:05
Custom boilerplate C++ code to create a window using the Windows API (Win32).
#include <windows.h>
#include <stdbool.h>
enum {
KEY_UNKNOWN,
KEY_MOUSE_LEFT,
KEY_MOUSE_RIGHT,
KEY_MOUSE_MIDDLE,
@abenezeradane
abenezeradane / gridtools.java
Last active August 6, 2022 03:04
Java Swing class used to draw grids
package Gridtools;
import java.awt.*;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.WindowConstants;
public class Grid extends JPanel {
protected static final long serialVersionUID = 0L;
protected static final int MARGIN_SIZE = 5;
@abenezeradane
abenezeradane / vcxsrv.sh
Last active June 29, 2022 21:34
Setting DISPLAY environmental variable for VcXsrv Windows X Server to work
#!/usr/bin/env bash
# Export DISPLAY to VcXsrv Windows X Server
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0
echo "Updated Display: ${DISPLAY}"
exit 0
#SHELL
@abenezeradane
abenezeradane / external.sh
Last active June 29, 2022 21:34
UNIX external storage mount for Windows Subsystem for Linux (WSL)
#!/usr/bin/env bash
# Determine if it's a network storage or external hard drive
read -p "(N)etwork or (D)rive? " -n1 external
echo ""
# Blank input check
if [ -z "$external" ]; then
echo 'Inputs cannot be blank!'
exit 0
@binji
binji / LICENSE
Last active October 27, 2025 05:51
pokegb.cc w/o macros
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 portions of the Software.