Skip to content

Instantly share code, notes, and snippets.

@timmattison
timmattison / get-repo-base.go
Last active March 5, 2024 14:22
Find the base directory of a git repo in Golang
package lib
// GetRepoBase get the directory that contains the .git directory for this repository. This DOES NOT give you the path
// you are running from or the path of the executable if you're running a binary from "go build". If your repo looks
// like this:
//
// - repo
// - .git
// - main.go
// - lib
@timmattison
timmattison / fromPartial.ts
Created March 3, 2023 16:59
fromPartial implementation, attempt #1
import {PartialDeep} from "type-fest";
function fromPartial<T extends {}>(mock: PartialDeep<T>) {
const proxy = new Proxy(mock, {
get(target, p, receiver) {
// If the receiver (the original type) doesn't have it then we ignore it
if (!(p in receiver)) return undefined
if (!(p in target)) {
throw new Error(`${String(p)} not found in mocked object`);
}
@timmattison
timmattison / build.gradle.kts
Created March 24, 2022 14:57
(Partial) Gradle Kotlin DSL code to copy AWS CRT JNI libs into the resources directory so they can be picked up by native image's resource-config.json
tasks.register("copyJniLibs") {
// This filter is used to find the binaries in the CRT JAR. Add additional extensions or conditions as needed.
val binaryFilter: (File) -> Boolean =
{ it.name.endsWith(".so") || it.name.endsWith(".dylib") || it.name.endsWith(".dll") }
// Find the JAR file for aws-crt and get a File object that represents it
val awsCrtJar = configurations.getByName("default")
.resolvedConfiguration
.resolvedArtifacts
.filter { it.moduleVersion.id.toString().contains("software.amazon.awssdk.crt") }

Keybase proof

I hereby claim:

  • I am timmattison on github.
  • I am timmattison (https://keybase.io/timmattison) on keybase.
  • I have a public key ASAQvDUj8VRldRhDCiOII4jXYwOYq9yjd-L6nMio2UKgDwo

To claim this, I am signing this object:

I tried a different approach. I figured that any jumbled word could be converted into an array of characters and sorted. All jumbled words would sort to the same value. For example, "cat" and "tac" both sort to "act".

I used the dictionary you provided and built a map that contains the sorted version of a word as the key. The value associated with each key is the list of all of the words in the dictionary that sort to the key.

Here is the code:

    import java.util.*;
    
    /**

Keybase proof

I hereby claim:

  • I am timmattison on github.
  • I am timmattison (https://keybase.io/timmattison) on keybase.
  • I have a public key whose fingerprint is 9514 129E 6A42 D63A 3982 3C03 9885 FF85 8D72 DD9D

To claim this, I am signing this object: