Skip to content

Instantly share code, notes, and snippets.

View cnlohr's full-sized avatar

CNLohr cnlohr

View GitHub Profile
@cnlohr
cnlohr / forgot_to_check_out_with_recurse_submodules.md
Last active April 22, 2024 12:13
Git forgot to clone recursively (forgot to check out with recurse submodules)
@cnlohr
cnlohr / raw_packet_read_write.c
Last active March 19, 2024 20:35
Read/write raw packets in C in Linux
//Based on https://github.com/cnlohr/lamenet/blob/master/librawp.c
#include <stdio.h>
#include <arpa/inet.h>
#include <string.h>
#include <linux/if_packet.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/ether.h>
@cnlohr
cnlohr / battery_monitor_overlay.c
Last active November 19, 2023 00:10
How to make a monitor overlay in OpenVR in C
// Battery Watcher for OpenVR (make an overlay with the battery left for all connected devices on your left hand)
//
// Compile with:
// tcc battery_monitor_overlay.c -o bmo.exe -luser32 -lgdi32 -lkernel32 -lopengl32 C:\windows\system32\msvcrt.dll openvr_api.dll
// System headers for any extra stuff we need.
#include <stdbool.h>
// Include CNFG (rawdraw) for generating a window and/or OpenGL context.
#define CNFG_IMPLEMENTATION
@cnlohr
cnlohr / esp32_aes_example.c
Created November 7, 2018 19:50
Example of using hardware AES 256 Crypto in CBC mode on the ESP32 using ESP-IDF
#include <string.h>
#include <stdio.h>
#include <hwcrypto/aes.h>
/*
For Encryption time: 1802.40us (9.09 MB/s) at 16kB blocks.
*/
static inline int32_t _getCycleCount(void) {
int32_t ccount;
@cnlohr
cnlohr / test.json
Last active August 19, 2023 19:31
test
{"schemaVersion":1,"label":"Exe Size","message":"21672\nminiosctest","color":"orange"}
@cnlohr
cnlohr / i2s_stream.c
Last active July 1, 2023 21:58
ESP32 I2S C Code Example/Snippet
//Almost entirelly lifted directly from https://github.com/igrr/esp32-cam-demo
//Just clocked a little differently and has chained buffers.
//This totes works with the I2S bus on the ESP32 for READING 16 wires simultaneously.
//Can be clocked off of I2S's internal controller or an external clock.
#define I2S_D0 4
#define I2S_D1 5
#define I2S_D2 18
#define I2S_D3 19
#define I2S_D4 36
@cnlohr
cnlohr / example_generate_texture.c
Last active April 12, 2023 10:09
How to write 2D and 3D Unity Texture files from C
// Execute this with `tcc testgen.c -run`
#include <stdio.h>
#include "unityassettexture.h"
#include <math.h>
int main()
{
float asset3d[50][50][50][4] = {0};
int x, y, z;
@cnlohr
cnlohr / goertzels_dft_comparison.c
Created January 14, 2023 19:29
Comparison of Goertzel's and DFT algorithms.
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define CNFG_IMPLEMENTATION
#include "rawdraw_sf.h"
void HandleKey( int keycode, int bDown ) { }
void HandleButton( int x, int y, int button, int bDown ) { }
@cnlohr
cnlohr / nreal notes.txt
Last active December 13, 2022 14:20
Nreal:AIR custom EDIDs (96 Hz,etc.) EDID custom mode timings
sudo xrandr --output DP-2 --newmode BB44 44 1920 1952 1968 2000 280 289 294 350 +hsync -vsync
It's wacky, but does work. Repeats screens
You can de/increase Y safely.
sudo xrandr --output DP-2 --newmode CC44 44 1920 1952 1968 2000 1080 1089 1094 1110 +hsync -vsync
Rate works at 44 and 66+