Skip to content

Instantly share code, notes, and snippets.

View assyrianic's full-sized avatar
💻
CompEng courses

Kevin Yonan assyrianic

💻
CompEng courses
View GitHub Profile
stock void RunScript(const char[] sCode, any ...) {
/**
* Run a VScript (Credit to Timocop)
*
* @param sCode Magic
* @return void
*/
static int iScriptLogic = INVALID_ENT_REFERENCE;
if( iScriptLogic==INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic) ) {
@assyrianic
assyrianic / FDR.ino
Last active March 21, 2024 03:49
Flight Data Recorder arduino code for the Glendale Community College [Arizona] course ECE294 aka NASA ASCEND Project.
#include <Fdr.h>//was Fdr.h
Fdr fdr; //I am defining fdr as type Fdr.
#include <Wire.h>
/**************************************
Modems
***************************************
The near modem is the one in the payload. The far modem is who we are talking with via satellite.
***************************************
@assyrianic
assyrianic / simpsons.inc
Last active December 9, 2023 17:48
simpsons rule for SourcePawn
stock float simpsons_func(float x) {
return 0.0; /// replace with math operations desired.
}
/**
* Composite Simpson's Rule: approximates the area of a function.
* 'a' represents the lower bounds
* 'b' represents the upper bounds
* 'num_intervals' is for how many iterations needed (this is for increasing accuracy)
*/
@assyrianic
assyrianic / simpsons.c
Last active December 9, 2023 17:24
simpson's rule in C
long double adaptive_simpsons(long double (*f)(long double), long double a, long double b, long double epsilon) {
long double c = (a + b) / 2.0L;
long double h = b - a;
long double fa = f(a);
long double fb = f(b);
long double fc = f(c);
long double integral = (h / 6.0L) * (fa + 4.0L * fc + fb);
long double d = (a + c) / 2.0L;
long double e = (c + b) / 2.0L;
@assyrianic
assyrianic / reciprocaldiv.c
Last active December 8, 2023 05:27
fixed point integer division
/// for int32.
/// a * (1/b) == (a * [(2^16 / b) + 1]) >> 16
#include <stdio.h>
int make_recip(int b) {
return ((1 << 16) / b) + 1;
}
int fast_div(int a, int recip) {
@assyrianic
assyrianic / ipow.c
Last active December 6, 2023 01:11
integer-based power function
#include <stdio.h>
#include <limits.h>
#include <time.h>
#include <math.h>
ssize_t ipow(ssize_t const x, size_t n) {
ssize_t r = 1;
while( n > 0 ) {
if( n & 1 ) {
r *= x;
@assyrianic
assyrianic / int_log2_16bit.h
Last active September 23, 2023 18:17
16-bit integer logarithm
#include <inttypes.h>
#include <stdio.h>
static inline uint8_t bitwise_ceil8(uint8_t x) {
x |= x >> 1;
x |= x >> 2;
x |= x >> 4;
return x;
}
@assyrianic
assyrianic / int_to_aii_numeral.py
Created August 29, 2023 17:36 — forked from ledzeppelin/int_to_aii_numeral.py
integer to assyrian numeral
def int_to_aii_numeral(num):
# greedy approach similar to https://leetcode.com/problems/integer-to-roman/description/
# time O(1)
# space O(1)
# based on the numerals here: https://en.wiktionary.org/wiki/Module:number_list/data/aii
numerals = [
(1000, 'ܐ݇'),
(900, 'ܨ̈'), (800, 'ܦ̈'), (700, 'ܥ̈'), (600, 'ܣ̈'), (500, 'ܢ̈'), (400, 'ܬ'),
(300, 'ܫ'), (200, 'ܪ'), (100, 'ܩ'), (90, 'ܨ'), (80, 'ܦ'), (70, 'ܥ'), (60, 'ܣ'),
#if defined _utf8_included
#endinput
#endif
#define _utf8_included
#include <sourcemod>
stock int GetUTF8Len(int c) {
for( int i=7; i < 8; i-- ) {
enum{ TREE_DATA = 3 };
enum{ TREE_SIZE = 2 << TREE_DATA };
/// 0 is root node
/// odd numbers above 0 are left nodes.
/// even numbers above 0 are right nodes.
enum struct ArrayTree {
int data[TREE_SIZE];
/// -1 0 1
int IndexType(int i) {