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
@assyrianic
assyrianic / bool_algebra_generator.go
Last active December 9, 2022 18:50
generates boolean algebra expressions.
package main
import (
"fmt"
"math/rand"
"time"
"os"
"strings"
"strconv"
)
Annulment rule: `a + 1 = 1`.
Idempotent rule: `a + a = a`, `aa = a`.
Complement rule: `aa̅ = 0`.
Absorption rule: `a + ab == a`, `a + a̅b == a+b`.
Identity rule: `a + 0 = a`, `a + a̅ = 1`, `a1 = a`.
/**
* arraymap.inc
*
* Copyright 2020 Nergal the Ashurian aka Nergal.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
@assyrianic
assyrianic / cfgmap.inc
Last active August 25, 2024 20:20
map-based config file structure designed for a nicer API and behavior than `KeyValues`
/**
* cfgmap.inc
*
* Copyright [2022] Nergal the Ashurian
*
* 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,
@assyrianic
assyrianic / linkedlist.inc
Created December 9, 2022 19:00
an ArrayList-based linked list for SourcePawn. Intended to be pretty fast compared to a regular linked list. Can be changed so the ArrayLists are arrays.
/**
* linkedlist.inc
*
* Copyright [2021] Nergal the Ashurian aka Kevin Yonan
*
* 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,
/**
* ecs_helper.inc
*
* Copyright [2022] Nergal the Ashurian
*
* 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,
@assyrianic
assyrianic / UCMP.java
Last active August 30, 2024 16:42
some functions that do Unsigned Comparison using Signed Ints for SourcePawn.
public class UCMP {
public static void main(String[] args) {
System.out.println("Hello World " + UInt32LT(1, -1));
}
/// x < y
public static boolean UInt32LT(int x, int y) {
boolean sign_x = (x & 0x80000000) != 0;
boolean sign_y = (y & 0x80000000) != 0;
if( sign_x==sign_y ) {
@assyrianic
assyrianic / cfgscript.inc
Last active July 29, 2023 18:50
a VScript-like scripting language exclusively made for SourcePawn
/**
* cfgscript.inc
*
* Copyright [2023] Assyrianic aka Nergal
*
* 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,
enum { CELL_KEY_SIZE=6 };
stock void PackCellToStr(any key, char buffer[CELL_KEY_SIZE]) {
int k = key;
buffer[0] = ((k >> (7 * 4)) & 0x7F) | 0x80;
buffer[1] = ((k >> (7 * 3)) & 0x7F) | 0x80;
buffer[2] = ((k >> (7 * 2)) & 0x7F) | 0x80;
buffer[3] = ((k >> (7 * 1)) & 0x7F) | 0x80;
buffer[4] = ((k >> (7 * 0)) & 0x7F) | 0x80;
buffer[5] = 0x00;
}
#include <sourcemod>
#pragma semicolon 1
#pragma newdecls required
stock int any_hash(any a, int seed=0) {
int h = seed;
h = ( i & 0xFF) + (h << 6) + (h << 16) - h;
h = ((i >>> 8) & 0xFF) + (h << 6) + (h << 16) - h;
h = ((i >>> 16) & 0xFF) + (h << 6) + (h << 16) - h;