Skip to content

Instantly share code, notes, and snippets.

View kevyonan's full-sized avatar
💻
CompEng courses

Kevin Yonan kevyonan

💻
CompEng courses
View GitHub Profile
@kevyonan
kevyonan / SourcemodPluginAnalyzer.cs
Created June 9, 2025 23:31 — forked from Alienmario/SourcemodPluginAnalyzer.cs
Dumps information from SMX files
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Security.Cryptography;
using System.Text;
/// <summary>Utility for analyzing compiled Sourcemod plugins.</summary>
/// <remarks>
/// Adapted from nosoop's read_sm_plugin.py gist, thanks for making a robust utility that still works after all the years!
@kevyonan
kevyonan / int64.inc
Last active June 13, 2025 18:00
int64 implementation for SourcePawn using an array of int32's.
#if defined _int64_included
#endinput
#endif
#define _int64_included
/// x < y
stock bool UInt32LT(int x, int y) {
/// why this works:
/// 0x80000000 < 0 -> has to be false::
/// (0x80000000^0x80000000) < (0^0x80000000)
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <inttypes.h>
struct Rational {
ssize_t numerator;
size_t denominator;
};
@kevyonan
kevyonan / gaussian.c
Created November 13, 2024 21:18
testing gaussian elimination to solve system of equations.
#include <stdio.h>
#include <math.h>
void gaussian(size_t const n, double A[n][n], double v[const restrict]) {
for( size_t k = 0; k < n-1; k++ ) {
/// Partial pivot
double cur_max = fabs(A[k][k]);
size_t m = k;
for( size_t i = k+1; i < n; i++ ) {
double const potential_max = fabs(A[i][k]);
@kevyonan
kevyonan / logic_value.c
Last active March 7, 2025 06:58
truth table printer for binary logic functions
#include <stdio.h>
/// a*b = min(a,b)
int min(int const a, int const b) {
return a < b? a : b;
}
void print_and(size_t const n, int const set[const static n]) {
for( size_t a=0; a < n; a++ ) {
for( size_t b=0; b < n; b++ ) {
@kevyonan
kevyonan / eps.go
Last active September 9, 2024 21:43
calculates epsilon for any device
func epsilon() float64 {
eps := 1.0
for eps+1 > 1 {
eps /= 2
}
eps *= 2
return eps
}
@kevyonan
kevyonan / boolcas.c
Last active November 26, 2024 21:13
boolean CAS in C
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdbool.h>
#include <string.h>
#include <stdarg.h>
#define FOR(counter, limit) for( size_t counter = 0; counter < (limit); counter++ )
@kevyonan
kevyonan / llist.c
Last active August 6, 2024 02:32
a dumb linked list
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <time.h>
struct Node {
struct Node *prev, *next;
int data;
};
#include <stdio.h>
#include <inttypes.h>
#include <time.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
static size_t bits_popcount(uint64_t const x) {
size_t count = 0;
@kevyonan
kevyonan / derivative_estimator.py
Last active August 27, 2024 07:02
a python script for estimating derivatives from a table of inputs and outputs.
# derivative estimator.
cont = True
while cont:
xs, ys = [], []
while True:
a = input('enter X: ')
if len(a) < 1:
break
xs.append(float(a))