Skip to content

Instantly share code, notes, and snippets.

View codebrainz's full-sized avatar

Matthew Brush codebrainz

View GitHub Profile
@codebrainz
codebrainz / c99.l
Created June 14, 2012 23:49
C99 Lex/Flex & YACC/Bison Grammars
D [0-9]
L [a-zA-Z_]
H [a-fA-F0-9]
E ([Ee][+-]?{D}+)
P ([Pp][+-]?{D}+)
FS (f|F|l|L)
IS ((u|U)|(u|U)?(l|L|ll|LL)|(l|L|ll|LL)(u|U))
%{
#include <stdio.h>
@codebrainz
codebrainz / main.c
Created October 13, 2012 07:20
ASCII Characters
------------------------------------------------------------------------------
| Dec | Oct | Hex | Binary | Asc | Description |
------------------------------------------------------------------------------
| 0 | 0000 | 00 | 00000000 | NUL | Null char |
| 1 | 0001 | 01 | 00000001 | SOH | Start of Heading |
| 2 | 0002 | 02 | 00000010 | STX | Start of Text |
| 3 | 0003 | 03 | 00000011 | ETX | End of Text |
| 4 | 0004 | 04 | 00000100 | EOT | End of Transmission |
| 5 | 0005 | 05 | 00000101 | ENQ | Enquiry |
| 6 | 0006 | 06 | 00000110 | ACK | Acknowledgment |
$ cloc --exclude-dir=.git --exclude-dir=.misc --exclude-ext=d .
351 text files.
248 unique files.
211 files ignored.
github.com/AlDanial/cloc v 1.98 T=0.56 s (439.4 files/s, 35020.5 lines/s)
--------------------------------------------------------------------------------
Language files blank comment code
--------------------------------------------------------------------------------
C 60 1264 58 6614
@codebrainz
codebrainz / async.c
Created August 8, 2025 21:55
Redacted delay
diff --git a/kernel/async.c b/kernel/async.c
index 8b37a2b..b113ab0 100644
--- a/kernel/async.c
+++ b/kernel/async.c
@@ -17,7 +17,7 @@ void delay(uint32_t ms) {
}
}
-#define WAIT_COND (*reg & expected_value) == expected_value
+#define WAIT_COND (((*reg) & (expected_value))) == (expected_value)
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to QEMU GDB Server",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/kernel.elf",
"cwd": "${workspaceFolder}",
"MIMode": "gdb",
#!/bin/bash
MODE="raspi"
ARGS=()
for arg in "$@"; do
case $arg in
MODE=*) MODE="${arg#MODE=}" ;;
*) ARGS+=("$arg") ;;
esac
@codebrainz
codebrainz / license.txt
Last active May 16, 2025 16:46
MJPEG Player in JavaScript
Copyright 2015 Matthew Brush
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:
@codebrainz
codebrainz / .clang-format
Last active May 16, 2025 04:22
WIP Clang Format style file for c3lang
# Treat C3 like C++ for clang-format
Language: Cpp
BasedOnStyle: LLVM
# Indentation & Tabs
UseTab: ForIndentation
TabWidth: 4
IndentWidth: 4
ContinuationIndentWidth: 8
@codebrainz
codebrainz / .fonts.conf
Created April 4, 2011 23:37
Font configuration file to override "emboldening" of fonts without a bold version.
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!--
This overrides what's in /etc/fonts/conf.d/90-synthetic.conf for
"faking" bold fonts, but only for monospace fonts.
-->
<fontconfig>
<match target="font">
<test name="spacing" compare="eq">
@codebrainz
codebrainz / gist:1562301
Created January 4, 2012 21:39
Simple bounded queue
/*
* A very basic (and fast) fixed-sized queue data structure.
*
* Author: Matthew Brush <mbrush@codebrainz.ca>
* License: GNU Lesser General Public License, version 2.1
* Edit Date: January 4th, 2011
*/
#include <stdlib.h>
#include "fixedqueue.h"