This file contains 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
class EDNParser { | |
constructor(ednString) { | |
this.edn = ednString; | |
this.index = 0; | |
} | |
parse() { | |
this.skipWhitespace(); | |
const element = this.readElement(); | |
this.skipWhitespace(); |
This file contains 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 y2024.d5 | |
(:require [clojure.test :as t :refer [deftest]] | |
[clojure.string :as string])) | |
(def sample-data-1 | |
"47|53 | |
97|13 | |
97|61 | |
97|47 | |
75|29 |
This file contains 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 { readdir, stat } from 'fs/promises'; | |
import { basename, join, parse, dirname } from 'path'; | |
import assert from 'assert'; | |
export const fmtFileName = (fileName: string) => parse(fileName).name; | |
export const getfilename = (path: string) => fmtFileName(basename(path)); |
This file contains 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
(defn lev [a b] | |
(let [[hda & rsta] a cta (count a) | |
[hdb & rstb] b ctb (count b)] | |
(cond (zero? ctb) cta | |
(zero? cta) ctb | |
(= hda hdb) (lev rsta rstb) | |
:else (inc (min (lev rsta b) (lev a rstb) (lev rsta rstb)))))) |
This file contains 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
(defn alpha? [ch] (Character/isLetter ch)) | |
(defn >>alpha [in] (apply str (take-while alpha? in))) | |
(defn >>line [in] (apply str (take-while #(not= % \newline) in))) | |
(defn str->jsdoc [string] | |
(when (str/starts-with? string "/**") | |
(loop [[fst & rest] (subs string 3) sol true;start-of-line | |
res []] | |
(when (some? fst) |
This file contains 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
; deps.edn | |
;{:paths ["src"] | |
;:deps {io.pedestal/pedestal.service {:mvn/version "0.5.9"} | |
; io.pedestal/pedestal.route {:mvn/version "0.5.9"} | |
; io.pedestal/pedestal.immutant {:mvn/version "0.5.9"} | |
; org.slf4j/slf4j-simple {:mvn/version "1.7.32"} | |
; environ/environ {:mvn/version "1.2.0"} | |
; org.xerial/sqlite-jdbc {:mvn/version "3.7.2" } | |
; com.github.seancorfield/next.jdbc {:mvn/version "1.3.909"} | |
; com.github.seancorfield/honeysql {:mvn/version "2.5.1103"} |
This file contains 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
function publishedCommandModule(publishOptions: PublishOptions) { | |
return ( | |
execute : (ctx: Context, args: ['slash', SlashOptions]) => unknown | |
) => commandModule({ | |
type: CommandType.Slash, | |
plugins: [ | |
publish(publishOptions) | |
], | |
execute | |
}) |
This file contains 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
export function Paginate() { | |
const __embeds = [] as EmbedBuilder[]; | |
let cur = 0; | |
let traverser: [ButtonBuilder, ButtonBuilder]; | |
let message : Message; | |
return { | |
add(...embeds : EmbedBuilder[]) { | |
__embeds.push(...embeds) | |
return this; | |
}, |
This file contains 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
class Channel<T> { | |
private subscribers : Subscriber<T>[] = []; | |
private values : T[] = []; | |
public emit(value : T) | |
{ | |
this.values.push(value); | |
} | |
public notify() | |
{ | |
for(const sub of this.subscribers) |
This file contains 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
//an example txt fiie | |
const text = | |
`uuid=00000000-0000-0000-0009-01f2082a2089 | |
lastOnline=1649034318641 | |
registered=1648920816719 | |
joinedTownAt=0 | |
isNPC=false | |
title= | |
surname= | |
friends= |
NewerOlder