Skip to content

Instantly share code, notes, and snippets.

View realmayus's full-sized avatar

Marius realmayus

View GitHub Profile
@realmayus
realmayus / egui.rs
Last active April 5, 2024 23:10
Basic vulkan egui integration using bindless textures and direct buffer addressing
use crate::pipeline::PipelineBuilder;
use crate::resources::{AllocUsage, AllocatedBuffer, Allocator, Texture, TextureId, TextureManager};
use crate::util::{load_shader_module, DeletionQueue};
use crate::{SubmitContext, FRAME_OVERLAP};
use ash::{vk, Device};
use bytemuck::{Pod, Zeroable};
use egui::ahash::{HashMap, HashMapExt};
use egui::epaint::{ImageDelta, Primitive};
use egui::{Context, FullOutput, ImageData, TexturesDelta};
use glam::{Vec3};
@realmayus
realmayus / inputValidator.ts
Created May 18, 2023 12:43
A handy function that allows you to easily validate user input and generate a response with minimal code in the actual endpoints.
export const checkInput = (input: any, requiredKeys: string[], validator: {[key: string]: (arg0: any) => boolean | string | Response}): Response | true => {
for (const key of requiredKeys) {
if (!(key in input) || input[key] == null ) {
return new Response(JSON.stringify({error: `${key}-not-specified`}), {status: 400});
}
if (key in validator) {
const res = validator[key](input[key]);
if (typeof res === "string") {
return new Response(JSON.stringify({error: `${key}-${res}`}), {status: 400});
} else if (typeof res === "boolean" && !res) {
@realmayus
realmayus / README.md
Last active April 10, 2023 18:22
.ics date offset program

Invoke with:

python main.py calendar.ics 2 0 0

`python

@realmayus
realmayus / ardu.ino
Created April 8, 2023 10:34
ESP8266 + DHT22 temp + humid sensor with web GUI
// Load Wi-Fi library
#include <ESP8266WiFi.h>
#include <Adafruit_Sensor.h>
#include "DHT.h"
#include <stdio.h>
// Replace with your network credentials
const char* ssid = "SSID";
const char* password = "PASSWORD";
@realmayus
realmayus / kanji.json
Last active November 20, 2021 13:09
WaniKani Kanji and Vocabulary data - There are two files, one for kanji and one for vocab words.
{
"1": [
"\u4e00",
"\u4e03",
"\u4e09",
"\u4e0a",
"\u4e0b",
"\u4e5d",
"\u4e8c",
"\u4eba",
@import "../../assets/main"
$menubarHeight: 60px
.bar
z-index: 10
width: 100%
height: $menubarHeight
background-color: #000000
position: sticky
@realmayus
realmayus / pi_approx.py
Created August 31, 2020 17:12
Approximation of Pi using the Leibniz and the Nilkantha series, implemented in Python.
from decimal import *
getcontext().prec = 1000
# simple and beautiful but diverges slowly.
def leibniz():
prefactor = -1
pre_result = 1
current_index = 3
@realmayus
realmayus / prepare_webapp_environment.sh
Created August 8, 2020 11:20
Set up web environment & install chime-web and chime-backend
GREEN='\033[0;32m'
NC='\033[0m'
echo -e "${GREEN}> Adding Ubuntu Universe to repositories & Updating package lists${NC}"
sudo apt-get update
sudo apt-get install -y software-properties-common
sudo add-apt-repository universe
sudo apt-get update
echo -e "${GREEN}> Installing nodejs & npm${NC}"
@realmayus
realmayus / chime.service
Last active August 7, 2020 13:18
A service file for the chime music bot.
[Unit]
Description=Chime
After=multi-user.target
[Service]
WorkingDirectory=%h/chime
ExecStart=%h/chime/venv/bin/chime
Type=idle
User=root
Group=root
Restart=always
@realmayus
realmayus / DataBuffer.js
Created June 30, 2020 10:59
A DataBuffer that's compatible with Java.
class DataBuffer {
constructor() {
this.bytearr = []
}
write(byte) {
this.bytearr.push(byte)
}
writeByteArray(byteArray) {