Skip to content

Instantly share code, notes, and snippets.

Avatar
🏖️
I may be slow to respond.

Kyle Lemons kylelemons

🏖️
I may be slow to respond.
View GitHub Profile
@kylelemons
kylelemons / k_from_p.go
Last active Apr 3, 2022
Maximum value of K coins taken from P piles in Go, using Dynamic Programming
View k_from_p.go
// Leetcode:
// https://leetcode.com/problems/maximum-value-of-k-coins-from-piles/
func maxValueOfCoins(piles [][]int, k int) int {
// Record the points cumulatively for taking N coins from each pile
for p := range piles {
for c := range piles[p] {
if c+1 >= len(piles[p]) {
continue
}
@kylelemons
kylelemons / io_fs_write_sketch.go
Last active May 9, 2021
Sketch of writable filesystem interfaces for io/fs
View io_fs_write_sketch.go
package fs
import (
"fmt"
"io"
"os"
. "io/fs"
)
@kylelemons
kylelemons / linked_hash_map.go
Created Feb 25, 2021
Linked Hash Map in Generic Go (go2go)
View linked_hash_map.go
// https://go2goplay.golang.org/p/MGkmOhAcV79
package main
import (
"fmt"
)
type Pair[K, V any] struct {
Key K
@kylelemons
kylelemons / perfect.go
Last active Aug 27, 2020
Perfect numbers in parallel
View perfect.go
package main
import (
"flag"
"fmt"
"runtime"
"sync"
"time"
)
View analysis.go.patch
diff --git a/internal/lsp/source/analysis.go b/internal/lsp/source/analysis.go
index e9c9ecc1..cea1e548 100644
--- a/internal/lsp/source/analysis.go
+++ b/internal/lsp/source/analysis.go
@@ -16,6 +16,7 @@ import (
"strings"
"sync"
"time"
+ "runtime/debug"
@kylelemons
kylelemons / gba_asm_interrupt_handler.s
Last active Aug 4, 2019
GameBoyAdvance Interrupt Handler (hardware only)
View gba_asm_interrupt_handler.s
.section .data._gba_asm_interrupt_handler
.global _gba_asm_interrupt_handler
.type _gba_asm_interrupt_handler, %function
.align
.arm
_gba_asm_interrupt_handler:
// Registers:
// r0 = IOREG
// NOTE:
@kylelemons
kylelemons / flags.txt
Created Jul 9, 2019
Minecraft JVM Flags
View flags.txt
Original:
-Xmx2G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M
New:
-XX:+UseG1GC -Xmx3G -Xms1G -Dsun.rmi.dgc.server.gcInterval=2147483646 -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M
@kylelemons
kylelemons / migrate_local_repos_to_github.sh
Last active Jul 5, 2019
A simple shell script to migrate a bunch of local git repositories to GitHub private repos
View migrate_local_repos_to_github.sh
#!/bin/bash
set -e
TOKEN="YOUR_GITHUB_AUTH_TOKEN_HERE"
USERNAME="YOUR_USERNAME"
mkdir -p repos published
for DIR in *.git; do
@kylelemons
kylelemons / numeric_sort.go
Last active May 15, 2019
Sort a slice of strings, treating numbers by value instead of by ASCII.
View numeric_sort.go
package main
import (
"fmt"
"sort"
"strings"
"unicode"
)
func main() {
@kylelemons
kylelemons / race_test.go
Last active Apr 11, 2019
Creating a channel asynchronously - race detector testing
View race_test.go
package gorace // run with go test -race
import (
"sync"
"testing"
"time"
)
var (
every = 100 * time.Millisecond