Skip to content

Instantly share code, notes, and snippets.

use std::collections::{HashMap, HashSet};
use crate::util::Grid;
// just pretend you know what Grid does
pub fn part_1(input: &str) -> u32 {
let grid = Grid::create(input);
let mut sum = 0;
for y in 0..grid.height() {
@Trivaxy
Trivaxy / inline.md
Last active August 3, 2021 21:46
Looking into the .NET inliner's brain

I've dug through the .NET 5 JIT in an attempt to understand how it determines whether a method should be inlined or not (so I know whether to spam method inlining attributes)

There's a lot of info. I'll strip out most of it so I can leave in the important parts (keep in mind this is my own understanding so some parts may be incorrect. If you have a correction, let me know)

The JIT has different "policies" for inlining that decide in different ways whether or not a method should be inlined. This gist attempts to break down the default policy, which is the one you should be concerned with most of the time

(Keep in mind that at this stage, all methods are still in IL form)

The JIT takes the following precautions before it even thinks about inlining a call to a method regardless of any attributes it has:

  • If the method is virtual, do not inline
@Trivaxy
Trivaxy / brain-screw.rs
Created June 30, 2020 22:07
brain-screw
use std::collections::HashMap;
use std::env;
use std::fs;
use std::io::{self, BufRead};
use std::time::{Duration, SystemTime, UNIX_EPOCH};
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
@Trivaxy
Trivaxy / description.txt
Last active June 18, 2020 03:43
Morbus
The Morbus is a dimension that lurks next to your Terraria world. A separate, miniscule plane of existence that deviates from the standard convention of thriving.
It is not the perfect place of living. The sky is dark, and the atmosphere is tinted green. The land here is humid, yet arid at the same time. The stone is nigh thick, and weak tools won't be able to break through. All you can see is hills, and a few deep chasms here and there. Perhaps there are things lurking in the distance, waiting for you?
-- TECHNICAL DETAILS & GAMEPLAY --
The Morbus consists of smooth, hilly terrain - unlike the overworld, which is rough and has much more varying heights. The dimension itself is only half the size of a small word, being only 2036 blocks in width and 600 tiles in height.
The cavern layer of the Morbus is also quite different from the overworld's. Each cave has well-defined edges and tends to assume a more rounded shape than the overworld's, while also often connecting to other caves - forming lots of tunnel
@Trivaxy
Trivaxy / documentation.md
Last active December 23, 2021 18:29
.tmod file format

tModLoader saves mod files in a custom format denoted with a .tmod extension. This file is produced once tModLoader compiles a mod, and it includes the mod assemblies, resources (such as images or sounds), libraries and any other miscellaneous data the modder chose to include within their mod.

The file format is relatively simple, and its layout has been described below. Note: Each data element has been written with its corresponding BinaryReader.ReadX method. If you are writing a .tmod file parser in a language not in .NET, remember that the strings are saved like so:

Value Data Description
Length 4 bytes This is a 7-bit encoded integer describing the length of the string. Search up 7-bit encoded ints if you are unfamiliar with them
String [Length] bytes The actual UTF-8 string, consisting of [Length] bytes

From here on out, any mention of string will refer to the layout above.

[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
class RunAttribute : Attribute
{
public Type Type
{
get;
private set;
}
public RunOption RunOption
@Trivaxy
Trivaxy / Changelog.md
Last active January 6, 2020 13:43
Choute server changelog

This changelog is constantly updating. Come to this link every now and then.

Keep in mind Choute is designed to be more difficult than your usual modpack.

Update 0.0.1 Alpha: Initial release

  1. Modified vanilla ore generation:
    • Iron, coal, gold, quartz are now less common with smaller sizes and greater variation in their vein size
    • Emerald is now slightly more common and generates in ALL biomes, not just Extreme Hills
  • Diamond vein size slightly decreased
@Trivaxy
Trivaxy / changelog
Last active June 8, 2019 12:37
Cooldude minecraft server changelog
COOLDUDE MINECRAFT SERVER CHANGELOG - This changelog is constantly changing! New changelogs are added to the bottom of the list
so check back from time to time
If you would like to install the modpack and play on the server, check the pins in the #cooldude_games channel
So, here are the updates:
---- RELIQUARY UPDATE AND BALANCING ----
44. Alkahestry Tome max charge buffed from 1000 to 1500
45. Angelheart Vial nerfed from 25% HP resurrection to 15% HP resurrection
46. Angelheart Vials no longer remove negative status effects on resurrection
package com.trivaxy.offlinemodgen
import javafx.geometry.Pos
import javafx.scene.control.Button
import javafx.scene.control.Label
import javafx.scene.control.TextField
import javafx.scene.layout.VBox
import javafx.scene.paint.Color
import javafx.stage.DirectoryChooser
import tornadofx.*
internal class UIHoverImageButton : UIImageButton
{
internal string hoverText;
public UIHoverImageButton(Texture2D texture, string hoverText) : base(texture)
{
this.hoverText = hoverText;
}
protected override void DrawSelf(SpriteBatch spriteBatch)