Skip to content

Instantly share code, notes, and snippets.

View zicklag's full-sized avatar
🛰️
Making awesome stuff!

Zicklag zicklag

🛰️
Making awesome stuff!
View GitHub Profile
{
"client_id": "openidconnect.net",
"redirect_uris": ["https://openidconnect.net/callback"],
"grant_types": ["authorization_code"]
}
@zicklag
zicklag / configureGlobalFetch.ts
Created January 13, 2024 19:35
Configuring a Global Proxy for Undici That Kind of Supports the `no_proxy` Environment Variable.
/**
* Importing this modules will configure the global undici agent, which is used to provide
* global `fetch()` support, to use an http proxy if present during development. Unfortunately
* undici doesn't come with this functionality so we implement a solution that is not fully
* correct as to the way that proxy environment variables are supposed to be parsed.
*
* This only goes into effect during development, though, and it's functional enough for that
* purpose.
*/
@zicklag
zicklag / singleton.rs
Last active November 8, 2023 16:42
Piccolo Singleton Manager
pub struct LuaSingletons {
singletons: Rc<AtomicCell<HashMap<usize, Box<dyn Any>>>>,
}
impl Default for LuaSingletons {
fn default() -> Self {
Self {
singletons: Rc::new(AtomicCell::new(HashMap::default())),
}
}
}
@zicklag
zicklag / arclock.rs
Created October 20, 2023 16:18
Arc<AtomicCell<T>> Static Lock
use std::ptr::NonNull;
use bones_framework::prelude::borrow::{AtomicBorrow, AtomicBorrowMut};
use crate::prelude::*;
/// Extension trait over [`Arc<AtomicCell>`] to allow obtaining a `'static` borrow guard.
pub trait ArcAtomicCellExt<T> {
fn lock_static(self) -> ArcRef<T>;
fn lock_static_mut(self) -> ArcRefMut<T>;
@zicklag
zicklag / freeze.rs
Last active October 19, 2023 16:42
**Probalby Not Sound:** An attempt at simplifying https://gist.github.com/kyren/9b461b880ce37a36320e77e02cdf4134
use paste::paste;
use std::{cell::RefCell, marker::PhantomData, rc::Rc};
/// Trait that allows you to determine what the type of something would be if you changed its
/// lifetime.
///
/// It is not recommended to implement this trait yourself, if not necessary.
///
/// You may use the [`impl_WithLifetime`] macro to safely implement this for types with
/// a single lifetime parameter, and it is automatically implemented for [`&T`] and [`&mut T`].
@zicklag
zicklag / readme.md
Last active April 30, 2024 17:16
Common Open Source License Obligations - NOT LEGAL ADVICE

NOT LEGAL ADVIVCE, THIS INTERPRETATION MAY BE INCORRECT


Common License Obligations

Observations of common license obligations in regards to what is necessary to account for when distributing an application built on /open-source software with various licenses.

/apache-2.0

Must give give a copy of the license.

  • This "license" is defined as "the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document."
@zicklag
zicklag / theme.css
Last active August 3, 2023 20:05
My Trilium notes theme.
:root {
--theme-style: dark;
--main-font-family: "Fira Sans";
--main-font-size: normal;
--tree-font-family: "Fira Sans";
--tree-font-size: 0.9em;
--detail-font-family: "Fira Sans";
@zicklag
zicklag / test.rs
Created March 24, 2023 15:06
HVM runtime constructor generation.
use hvm::{get_loc, load_ptr, readback, runtime, Core};
fn main() {
let script = std::env::args().nth(1).unwrap();
let script = std::fs::read_to_string(script).unwrap();
let script = hvm::language::syntax::read_file(&script).unwrap();
let mut runtime = {
let heap_size = 5 * hvm::CELLS_PER_MB;
let threads = 3;
@zicklag
zicklag / README.md
Last active May 17, 2024 19:01
Self-hosted Revolt Chat Server With Traefik Reverse Proxy.

Self-hosting Revolt

This is my ultra-quick, rundown of how I self hosted revolt. It may not be 100% accurate, I might mess something up, and it might not work, but it might help out.

I've also got some personal server-setup preferences in here, so you'll get a couple bonuses, like a Portainer web UI for managing your Docker stacks, and a backup system. Feel free to ignore those/leave them out.

Step 1: Get a Server

There are lots of different places to get servers, so I'm going to gloss over this step, other than an important piece:

@zicklag
zicklag / dense_player_input.rs
Created November 7, 2022 15:16
Example of creating a dense representation of player inputs for sending over the network.
use numquant::{Quantized, IntRange};
bitfield::bitfield! {
/// A player's controller inputs densely packed into a single u16
pub struct DensePlayerControl(u16);
impl Debug;
jump_pressed, set_jump_pressed: 0;
shoot_pressed, set_shoot_pressed: 1;
grab_pressed, set_grab_pressed: 2;
slide_pressed, set_slide_pressed: 3;