This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func toFontRune(fs embed.FS, fontName string, name string) FontRune { | |
txt, err := fs.ReadFile(fontName + "/" + name) | |
if err != nil { | |
panic(err) | |
} | |
var lines = genfuncs.Slice[string](strings.Split(string(txt), "\n")). | |
Filter(hasData) | |
return [][]bool(genfuncs.Map(genfuncs.Map(lines, toRuneSlice), toPixelSlice)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func toFontRune(fs embed.FS, fontName string, name string) (FontRune, error) { | |
txt, err := fs.ReadFile(fontName + "/" + name) | |
if err != nil { | |
return nil, err | |
} | |
lines := strings.Split(string(txt), "\n") | |
var fr [][]bool | |
for _, line := range lines { | |
if len(line) < 3 { | |
continue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package util | |
import ( | |
"time" | |
) | |
type StopChannel chan bool | |
// RepeatUntilStopped creates a goroutine that loops, waiting the delay provided and | |
// then calling the function provided. The loop can be stopped by sending a value to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
"os" | |
"time" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.nwillc.datastructures | |
class Heap private constructor( | |
size: Int, | |
seed: Int, | |
val compare: (Int, Int) -> Boolean | |
) { | |
private var heapSize = 0 | |
private val array = IntArray(size + 1).also { it[0] = seed } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.slf4j.Logger | |
import org.slf4j.LoggerFactory | |
inline fun <reified T> getLogger(): Logger = LoggerFactory.getLogger(T::class.java.name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
FileReader("input.txt").use { reader -> | |
FileWriter("output.txt").use { writer -> | |
// Use the input and output | |
} | |
} | |
} catch (e: FileNotFoundException) { | |
// Handle possible exception | |
} catch (e2: IOException) { | |
// Handle another exception |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try (Reader reader = new FileReader("input.txt"); | |
Writer writer = new FileWriter("output.txt")) { | |
// Use the input and output | |
} catch (FileNotFoundException e) { | |
// Handle possible exception | |
} catch (IOException e2) { | |
// Handle another exception | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
FileReader("input.txt").use { | |
// Use the input | |
} | |
} catch (e: FileNotFoundException) { | |
// Handle possible exception | |
} catch (e2: IOException) { | |
// Handle another exception | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FileReader("input.txt").use { | |
// Use the input | |
} |