Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
const grid = [
['P', 'X', 'P', 'X', 'X', 'M', 'X', 'X', 'M', 'X'],
['M', 'X', 'M', 'X', 'X', 'P', 'X', 'X', 'P', 'X'],
['X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X'],
['X', 'P', 'X', 'P', 'M', 'X', 'P', 'M', 'X', 'M'],
['X', 'M', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'P'],
['X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X'],
['X', 'P', 'X', 'M', 'P', 'X', 'M', 'P', 'X', 'M'],
['X', 'M', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X'],
open class EnumMap<E : Enum<E>, V : Any>(
meta: Class<E>
) : MutableMap<E, V> {
private val universe = meta.enumConstants
private val storage = Array.newInstance(java.lang.Object::class.java, universe.size) as kotlin.Array<V?>
override fun get(key: E): V? {
return storage[key.ordinal]
@lineargraph
lineargraph / BlackgroundRemover.kt
Created February 14, 2024 15:57
Replaces black backgrounds with transparent ones. Essentially scales the transparency with the respective brightness of the each pixel.
import java.awt.Color
import java.awt.image.BufferedImage
import java.io.File
import javax.imageio.ImageIO
import kotlin.system.exitProcess
fun main(args: Array<String>) {
var inf: File? = null
var outf: File? = null
import com.google.gson.*
import com.google.gson.annotations.SerializedName
import com.google.gson.reflect.TypeToken
import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonToken
import com.google.gson.stream.JsonWriter
import kotlin.reflect.*
import kotlin.reflect.full.isSubtypeOf
import kotlin.reflect.full.memberProperties
@lineargraph
lineargraph / LoreRenderer.kt
Created March 31, 2023 01:26
reimplementation of the minecraft 1.8.9 font renderer
import java.awt.Graphics2D
import java.awt.image.BufferedImage
import java.io.File
import java.util.*
import javax.imageio.ImageIO
/**
* Copyright 2022 Linnea Gräf
*

How to use

Copy the other file in this gist into your $GRADLE_USER_HOME/init.d (usually this is: ~/.gradle/init.d/installMinecraft.init.gradle.kts) and replace the installation path with the correct path. From now on, every mod project that uses forgegradle or loom (and a roughly standard project layout) should have the task ./gradlew installToMinecraft available (also available in your IDE), which will install that jar. in projects with multiple subprojects, you might want to use a fully qualified task path: Either ./gradlew :installToMinecraft for installing the root project, or ./gradlew :forge-1.8.9:installToMinecraft to install a subproject (for example for multi-version projects).

// ==UserScript==
// @name Replace imgur links in the Abishirt vote with images
// @version 1
// @grant none
// @run-at document-end
// @include https://civs.cs.cornell.edu/cgi-bin/*
// ==/UserScript==
console.log("Replacing imgur links with embeded images");
function mutate(el){
el.innerHTML = el.innerHTML.replace(/https:\/\/imgur\.com\/([a-z0-9]+)/i, "<img src=\"https://i.imgur.com/$1.png\" height=200/>https://imgur.com/$1")
import java.io.Closeable
import java.util.*
class ResourceContext {
private val toClose = mutableListOf<Closeable>()
fun <A : Closeable> open(thing: A): A {
toClose.add(thing)
return thing
}
@lineargraph
lineargraph / Futter.java
Created October 23, 2018 12:47
Komposition created by romangraef - https://repl.it/@romangraef/Komposition
class Futter {
String name;
float mass;
public Futter(String name) {
this.name = name;
this.mass = 100f;
}
public String toString(){