Skip to content

Instantly share code, notes, and snippets.

@NightlyNexus
NightlyNexus / TypeNames.java
Created March 13, 2018 09:02
A helper to add @generated to a JavaPoet's TypeSpec
import com.squareup.javapoet.AnnotationSpec;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.CodeBlock;
import com.squareup.javapoet.TypeSpec;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import javax.lang.model.SourceVersion;
@NightlyNexus
NightlyNexus / MarriageProblemSolver.kt
Created August 28, 2021 01:09
A Kotlin implementation of the Gale–Shapley algorithm for the stable marriage problem.
import MarriageProblemSolver.Person
class MarriageProblemSolver {
class Person(val name: String) {
internal lateinit var preferences: List<Person>
internal var proposals = 0
var match: Person? = null
internal set
// Do a lateinit to allow the circular dependency of people with their preferences of people.
@NightlyNexus
NightlyNexus / flashlight.lua
Created September 17, 2021 01:10
A script for the Valve flashlight, meant for VR. This fixes bugs, adds some small features, and cleans up the code from the sample here: https://developer.valvesoftware.com/wiki/SteamVR/Environments/Scripting/flashlight_script_code_full
-- Disable this flag to remove the glow particle around the flashlight's lens.
local enableGlow = true;
local glowParticle;
local lightTable = {
classname = "light_spot",
targetname = "light" .. thisEntity:entindex(),
enabled = 0,
brightness = "1.5",
range = "400",
@NightlyNexus
NightlyNexus / RangeInputFilter.kt
Created November 2, 2022 16:51
An Android InputFilter for a decimal range
import android.text.InputFilter
import android.text.Spanned
class RangeInputFilter(private val min: Int, private val max: Int) : InputFilter {
override fun filter(
source: CharSequence,
start: Int,
end: Int,
dest: Spanned,
dstart: Int,