Skip to content

Instantly share code, notes, and snippets.

View chaotic3quilibrium's full-sized avatar

Jim O'Flaherty chaotic3quilibrium

View GitHub Profile
chaotic3quilibrium /
Last active November 25, 2023 21:27
A Java utility class that caches the resulting value of (expensively?) computing a function taking a single argument
import java.util.*;
import java.util.Map.Entry;
import java.util.function.Function;
import java.util.function.Supplier;
* File:
* <p>
chaotic3quilibrium / Overview.txt
Last active October 26, 2023 15:34
Solution to Java Enum Generics Problem Posted on StackOverflow
View Overview.txt
//StackOverflow Question:
//Updated/fixed the 5 code files to incorporate the answer by Turing85:
chaotic3quilibrium /
Last active November 23, 2023 20:21
A Java class representing a value of one of two possible types
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
chaotic3quilibrium / Effective Scala Case Class
Last active October 2, 2023 22:37
Article: Effective Scala Case Class Patterns - The guide I wished I had read years ago when starting my Scala journey
View Effective Scala Case Class

Effective Scala Case Class Patterns

Version: 2022.03.02

Available As

chaotic3quilibrium / org.public_domain.PurelyFunctionalHangman.scala
Last active January 27, 2021 13:58
An update of John deGoes original PurelyFunctionalHangman to ZIO 1.0
View org.public_domain.PurelyFunctionalHangman.scala
package org.public_domain
import zio.console._
import zio.{ExitCode, UIO, URIO, ZIO}
object PurelyFunctionalHangman extends zio.App {
def run(args: List[String]) : URIO[Console, ExitCode] =
chaotic3quilibrium / Stage01.scala
Created May 5, 2020 20:31
ScalaBoi: Posting a Twitter Thread of Tweets - Stage 1 - Create the Webpage App Backbone
View Stage01.scala
import scalatags.JsDom.all._
val textAreaInput =
val buttonExecuteTransform =
button("Execute Transform").render
val textAreaOutput =
chaotic3quilibrium / TheTenDivisibilities.scala
Created April 24, 2020 15:52
ScalaBoi: A John Conway Puzzler - Part 1 of 2 - Oops, That Didn't Work! Why?!
View TheTenDivisibilities.scala
//C1 - Initial Scala solution attempt
val lettersToDigitsPrefixSize = 3
val letterToDigits =
'a' -> List(1, 3, 7, 9),
'b' -> List(2, 4, 6, 8),
'c' -> List(1, 3, 7, 9),
'd' -> List(2, 4, 6, 8),
chaotic3quilibrium / org.public_domain.scrabble.Bag.scala
Last active June 28, 2016 14:26
Java Code Challenge: Scrabble Sets - Scala Solution
View org.public_domain.scrabble.Bag.scala
package org.public_domain.scrabble
import scala.util.{Success, Failure, Random, Try}
object Bag {
//copy and paste directly from provided URL at "Tile count and value ordered by count"
// with "Blank" replaced with "_":
private val countByTileFull =
"""E 12 1
chaotic3quilibrium / DIY Scala Enumeration - README.txt
Last active September 13, 2020 22:20
DIY Scala Enumeration (closest possible Java Enum equivalent with guaranteed pattern matching exhaustiveness checking)
View DIY Scala Enumeration - README.txt
README.txt - DIY Scala Enumeration
Copyright (C) 2014-2016 Jim O'Flaherty
Provide in Scala the closest equivalent to Java Enum
- includes decorating each declared Enum member with extended information
- guarantees pattern matching exhaustiveness checking
- this is not available with scala.Enumeration
ScalaOlio library (GPLv3) which contains more up-to-date versions of both `org.scalaolio.util.Enumeration` and `org.scalaolio.util.EnumerationDecorated`: