This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![allow(non_snake_case)] | |
use std::io::{Cursor, Error, Result, Write}; | |
macro_rules! write_val { | |
($writer:expr, $val:expr, $bigEndian:expr) => {{ | |
let bytes = if $bigEndian { | |
$val.to_be_bytes() | |
} else { | |
$val.to_le_bytes() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
edition = "2021" | |
binop_separator = "Back" | |
condense_wildcard_suffixes = true | |
format_strings = true | |
group_imports = "StdExternalCrate" | |
hard_tabs = true | |
hex_literal_case = "Upper" | |
imports_granularity = "Module" | |
imports_layout = "HorizontalVertical" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from urllib import request | |
import io | |
import json | |
import os | |
import sys | |
import time | |
import urllib | |
import zipfile | |
def main(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(return_position_impl_trait_in_trait)] | |
trait ComposableOnce<From, To>: FnOnce(From) -> To { | |
fn compose_once<Final>(self, rhs: impl FnOnce(To) -> Final) -> impl FnOnce(From) -> Final; | |
} | |
impl<From, To, Func: FnOnce(From) -> To> ComposableOnce<From, To> for Func { | |
fn compose_once<Final>(self, rhs: impl FnOnce(To) -> Final) -> impl FnOnce(From) -> Final { | |
move |v| rhs(self(v)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] | |
pub struct VarInt(u128); | |
macro_rules! conversions { | |
($($ty:ty => $unsigned:ty, $signed:expr);*;) => {$( | |
impl From<$ty> for VarInt { | |
fn from(v: $ty) -> Self { | |
let raw = if $signed { | |
// rotate sign bit to front, and flip value bits if negative | |
// this encodes small absolute values in the fewest bytes possible |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Clone, Debug)] | |
pub struct SurrogateString(String); | |
impl SurrogateString { | |
unsafe fn inner(&self) -> &String { | |
&self.0 | |
} | |
unsafe fn inner_mut(&mut self) -> &mut String { | |
&mut self.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auto builder(T)(T inst = T.init) | |
{ | |
enum isClass = is(T == class); | |
static assert(is(T == struct) || isClass, "builder!T can only build structs and classes"); | |
static if(isClass) | |
if(inst is null) inst = new T; | |
static struct Builder | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct RingBuffer(T, size_t _capacity) | |
{ | |
import core.lifetime: move; | |
private | |
{ | |
T[capacity] buffer; | |
size_t read; | |
size_t write; | |
size_t len; // keep it simple :^) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::sync::atomic::{AtomicUsize, Ordering}; | |
use std::alloc; | |
#[global_allocator] | |
static COUNTING_ALLOC: CountingAlloc = CountingAlloc::new(); | |
struct CountingAlloc { | |
used: AtomicUsize, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void PluginInit() | |
{ | |
g_Module.ScriptInfo.SetAuthor("Yoplitein"); | |
g_Module.ScriptInfo.SetContactInfo("[email protected]"); | |
} | |
void dbgDrawLine(const Vector&in pt1, const Vector&in pt2, uint16 lifetimeDs = 25, uint8 r = 255, uint8 g = 127, uint8 b = 0) | |
{ | |
NetworkMessage msg(MSG_BROADCAST, NetworkMessages::SVC_TEMPENTITY, null); | |
msg.WriteByte(TE_LINE); |
NewerOlder