Skip to content

Instantly share code, notes, and snippets.

View Magnogen's full-sized avatar
🔬
Experimenting

Magnogen Magnogen

🔬
Experimenting
View GitHub Profile
@VictorTaelin
VictorTaelin / gpt4_abbreviations.md
Last active April 29, 2025 09:24
Notes on the GPT-4 abbreviations tweet

Notes on this tweet.

  • The screenshots were taken on different sessions.

  • The entire sessions are included on the screenshots.

  • I lost the original prompts, so I had to reconstruct them, and still managed to reproduce.

  • The "compressed" version is actually longer! Emojis and abbreviations use more tokens than common words.

Notes on Modern UI Development: Iterating over the other 80%

Introduction

I have been working on a modern typing training application for the last couple of days. One of the main motivations was to build an app with a modern UI and minimal distractions, enabling to fully focus on the training aspect. You can read more about the original idea and thought process here.

One of the main features is being able to train your typing speed when working with code, which means the typing experience should come close to how you would type when working with an IDE. A feature that you would normally get inside such an environment is the auto closing of parentheses, brackets and braces. Which means you would for example type ( and the IDE would automatically add the closing ) for you.

The first iteration of Typing Cyclist was just a raw implementation which treated text and code examples the same. You would have to type

@kddnewton
kddnewton / json.rb
Last active December 18, 2024 17:34
JSON parser with pattern matching
require "json"
struct = { "a" => 1, "b" => 2, "c" => [1, 2, 3], "d" => [{ "e" => 3 }, nil, false, true, [], {}] }
source = JSON.dump(struct)
tokens = []
index = 0
until source.empty?
tokens <<
@GentlemanRevvnar
GentlemanRevvnar / 1.18.2-custom_structures_with_jigsaws.md
Last active January 30, 2025 17:27
Simple guide for using jigsaws in custom structures in 1.18.2

Custom data pack structures with jigsaws in 1.18.2

(Last updated: 1.18.2)

This is technically a shameless rip/edit of misode's guide that shows the traditional use of newly implemented custom structure system. I myself want to tackle the jigsaw aspect a bit, hence i'm making my own guice based on his. I will show how to create a data pack that adds custom structures to the world that also utilize jigsaw blocks. So treat this as a basic jigsaw guide in world generation. There is also a data pack download of this first example.

Always leave the world and rejoin to apply the new changes! Because traditional /reload or /datapack disable & enable do not refresh changes in worldgen files!

EXAMPLE 1 - Creating a structure that uses jigsaws

Let's make a simple house with a basement and a road that will lead away from the h

@arifbalik
arifbalik / generative1.js
Created January 11, 2022 17:37
my_first_generative
function drawQuad(x, y, size, colorQuad, distortX, distortY){
//randomSeed(x);
let marginX = random(distortX/5);
let marginY = random(distortY/5);
let points = {
x1:random(x, x + marginX),
y1:random(y, y + marginY),
@Ellivers
Ellivers / main.md
Last active December 29, 2024 02:08
Practices and Tricks

Good Data Pack Practices and Common Tricks

Structuring and Consistency

An organized structure to your data pack's folders and file names always helps you understand your code better and leads to less bugs. Place files that have something in common in the same folder, and name them based on what their purpose is.

Consistency in naming stuff like tags, files, and scores can help keep you sane. Always have a clear structure in place, such as prefixing tag and objective names with your namespace (namespace.name) and giving tags different categories (namespace.entity.name, namespace.block.name).

If you are unsure of how a good structure could look, you could take a look at some vanilla assets, such as the lang file or the built-in data pack, as well as get ideas from looking at data packs that other people have made.

@DavidMcLaughlin208
DavidMcLaughlin208 / IterateBetweenTwoPointsOnMatrix.java
Last active March 15, 2025 12:21
Algorithm to move from one point on a 2D matrix to another in the shortest most logical route
public void iterateAndApplyMethodBetweenTwoPoints(Vector2 pos1, Vector2 pos2, Supplier<FunctionInput> function) {
// If the two points are the same no need to iterate. Just run the provided function
if (pos1.epsilonEquals(pos2)) {
function.invoke();
return;
}
int matrixX1 = pos1.x;
int matrixY1 = pos1.y;
int matrixX2 = pos2.x;
@Jack-Works
Jack-Works / 2018.js
Last active March 1, 2024 02:23
cRAzY eSnEXt (*all* proposals mixed in)
#! Aaaaaaaaaaa this is JS!!!
// https://github.com/tc39/proposal-hashbang
// This file is mixing all new syntaxes in the proposal in one file without considering syntax conflict or correct runtime semantics
// Enjoy!!!
// Created at Nov 23, 2018
for await(const x of (new A // https://github.com/tc39/proposal-pipeline-operator
|> do { // https://github.com/tc39/proposal-do-expressions
case(?) { // https://github.com/tc39/proposal-pattern-matching
when {val}: class {
@onnowhere
onnowhere / image_to_particles.py
Last active March 18, 2025 06:20
[Image to Particles] Quick tool that generates a function that displays particles for an input image using local coordinates. Drop images in the `images` folder in the same directory as the script. You'll also need to `pip install opencv-python`. Edit generation options at the bottom of the file.
import cv2
import os
class ImageToParticle:
def __init__(self, image_file, resolution=(40, 40), scale=0.25, max_size=5, replace_transparent=[], animation=0, commands=[], show_display=False):
self.image_file = image_file # Source file
self.resolution = resolution # Shrinks image to fit within x,y dimensions without changing aspect ratio (1 pixel = 1 particle)
self.scale = scale # Scale the size of image displayed in game
self.max_size = max_size # Maximum particle size, alpha scales this if replace_transparent is not defined
self.replace_transparent = replace_transparent # RGB value to replace 0 alpha with

Communicating between the clients and the server

Experiment

Say you wanted to emit an explosion particle whenever your block is destroyed. Emitting particles requires access to the ParticleManager, which only exists on the MinecraftClient instance. Let's try doing that:

public class MyBlock extends Block {
    @Override
    public void onBlockRemoved(BlockState before, World world, BlockPos pos, BlockState after, boolean bool) {