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
<scheme name="12-bit rainbow" version="142" parent_scheme="Default"> | |
<option name="FONT_SCALE" value="1.0" /> | |
<metaInfo> | |
<property name="created">2022-11-22T17:07:03</property> | |
<property name="ide">GoLand</property> | |
<property name="ideVersion">2022.2.5.0.0</property> | |
<property name="modified">2022-11-22T17:07:15</property> | |
<property name="originalScheme">12-bit rainbow</property> | |
</metaInfo> | |
<option name="CONSOLE_FONT_NAME" value="Berkeley Mono" /> |
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 humanize | |
import ( | |
"fmt" | |
"strings" | |
) | |
// Comma formats a number with commas separating each block of 3 numbers. | |
// Inspiration: https://pkg.go.dev/github.com/dustin/go-humanize#Comma | |
func Comma(n int) string { |
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 index[K comparable, V any](list []V, key func(V) K) map[K]V { | |
result := make(map[K]V) | |
for _, value := range list { | |
result[key(value)] = value | |
} | |
return result | |
} |
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 GetOrSetDefault[K comparable, V any](m map[K]V, key K, new_ func() V) V { | |
value, found := m[key] | |
if !found { | |
value = new_() | |
m[key] = value | |
} | |
return value | |
} | |
/* |
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 should | |
import ( | |
"fmt" | |
"log" | |
"reflect" | |
"runtime" | |
) | |
type assertion func(actual any, expected ...any) error |
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 should info: github.com/mdwhatcott/[email protected] (a little copy-paste is better than a little dependency) | |
// AUTO-GENERATED: 2022-12-27 23:56:46.913568 -0700 MST m=+0.004900728 | |
package should | |
import ( | |
"errors" | |
"fmt" | |
"log" | |
"math" | |
"reflect" |
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 assert | |
import ( | |
"reflect" | |
"testing" | |
) | |
// That allows assertions as in: assert.That(t, actual).Equals(expected) | |
func That(t *testing.T, actual interface{}) *assertion { |
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
#lang racket | |
(require rackunit) | |
(require "bowling.rkt") | |
(define (roll-many times roll) | |
(for/list ([i times]) roll)) | |
(test-equal? "Gutter Game" 0 (score (roll-many 20 0))) | |
(test-equal? "All Ones" 20 (score (roll-many 20 1))) |
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
(ns kata.life) | |
(defn neighbors-of [[x y]] | |
(for [Y (range (dec y) (+ 2 y)) | |
X (range (dec x) (+ 2 x)) | |
:when (not= [x y] [X Y])] [X Y])) | |
(defn count-active-neighbors [cell grid] | |
(->> cell neighbors-of set (filter grid) count)) |
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
(ns hello-quil.grid | |
(:require [quil.core :as q] | |
[quil.middleware :as m])) | |
(defn hovering? [{:keys [x y width mark] :as cell}] | |
(let [x2 (+ x width) | |
y2 (+ y width) | |
mx (q/mouse-x) | |
my (q/mouse-y)] | |
(and (nil? mark) |