Skip to content

Instantly share code, notes, and snippets.

/* Copyright 2016-2017 random832@fastmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
@Random832
Random832 / dither.py
Created April 23, 2021 20:38
bayer dithering experiment
import numpy as np
from PIL import Image
import sys
im = Image.open('chart.png')
im2 = np.array(im)
factor = 127 # 84
@Random832
Random832 / twitter-emoji-alt-fix.user.js
Last active May 23, 2021 23:48
Twitter Emoji Alt Fix
// ==UserScript==
// @name Twitter Emoji Alt Fix
// @description Set the alt text of Twitter Emoji images so that they can be copied correctly
// @version 1
// @grant none
// @include https://twitter.com/*
// ==/UserScript==
const SELECTOR = 'img[src*="twimg.com/emoji/"]'
@Random832
Random832 / MiniLogBlock.java
Created July 21, 2021 04:07
six-way connecting log block
package random832.content.block.wood;
import mcp.MethodsReturnNonnullByDefault;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.IWaterLoggable;
import net.minecraft.block.SixWayBlock;
import net.minecraft.block.material.Material;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// comically small buffer to prove the recursion concept
#define BUF 16
static ssize_t innerget(char **lineptr, size_t *n, int delim, FILE *stream, size_t offset) {
char buf[BUF];
@Random832
Random832 / ServerSideChest.java
Created September 14, 2022 19:15
fake chest menu base class
package random832.gui.menu;
import com.mojang.authlib.GameProfile;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.Util;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.Container;
import net.minecraft.world.SimpleContainer;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
{
"textures": {
"frame": "generatorgalore:item/upgrade_frame",
"base": "block/copper_block"
},
"elements": [
{
"from": [2, 2, 7.5],
"to": [14, 14, 8.5],
"faces": {