Skip to content

Instantly share code, notes, and snippets.

View arichiardi's full-sized avatar

Andrea Richiardi arichiardi

View GitHub Profile
@adham-omran
adham-omran / prompt.md
Created January 23, 2025 06:28
Clojure Documentation LLM Prompt

You are an expert Clojure developer with 15 years of experience, write a rich docstring for the provided function form using the following guidelines

  • Let the first line in the docstring be a complete, capitalized sentence which concisely describes the var in question. This makes it easy for tooling (Clojure editors and IDEs) to display a short a summary of the docstring at various places.
  • Document all positional arguments, and wrap them them with backticks () so that editors and IDEs can identify them and potentially provide extra functionality for them.
  • Wrap any var references in the docstring with so that tooling can identify them. Wrap them with [[..]] if you want to link to them
  • Docstrings should be composed of well-formed English sentences. Every sentence should start with a capitalized word, be grammatically coherent, and end with appropriate punctuation. Sentences should be separated with a single space.
  • Indent multi-line docstrings by two spaces.
  • Neither start nor end your docstrings
@chase-lambert
chase-lambert / onefile.clj
Created January 16, 2025 01:56
Concatenates all your git repo's clojure files into one file
#!/usr/bin/env bb
;; A Babashka script to concatenate all Clojure files in a repository into a single file.
;; Respects .gitignore patterns and includes clear file separation markers.
;;
;; Usage:
;; ./onefile.clj ; uses current git repo and default output
;; ./onefile.clj /path/to/repo ; uses custom repo path
;; ./onefile.clj /path/to/repo out.clj ; specifies output filename
;;
@Artefact2
Artefact2 / README.md
Last active March 14, 2025 11:57
GGUF quantizations overview
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; BACK UP YOUR LOGSEQ DIR BEFORE RUNNING THIS!
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Copyright (C) Aug 4 2022, William R. Burdick Jr.
;;
;; LICENSE
;; This code is dual-licensed with MIT and GPL licenses.
@borkdude
borkdude / 01-README.md
Last active May 4, 2023 03:42
Shadow CLJS require ES Module in script

This shows how to require ES modules in a node script which is itself compiled as an ES module by shadow. I made this to verify if nbb's way of requiring ES modules aligns with other tools that accomplish the same using the CLJS compiler.

Build with npx shadow-cljs compile script. Run with node out/script.js. It will print something like:

#js {:columns 202, :rows 45}
[Function: Spinner]
(defonce ^Logger logger (doto (Logger/getLogger "clojure")
(.setUseParentHandlers false)
(.addHandler
(doto (ConsoleHandler.)
(.setLevel Level/ALL)
(.setFormatter
(proxy [SimpleFormatter] []
(format [^LogRecord record]
(let [sb (StringBuilder.)]
(.append sb "#:log{")
@baskeboler
baskeboler / clipboard.clj
Last active April 11, 2021 01:21 — forked from brake/clipboard.clj
Write pretty printed Clojure data structures to the clipboard
(ns clipboard.core
(:require [fipp.edn :as fipp])
(:import (java.awt.datatransfer DataFlavor Transferable StringSelection)
(java.awt Toolkit)
(java.io StringWriter))
(defn get-clipboard
"get system clipboard"
[]
(-> (Toolkit/getDefaultToolkit)
@Dangercoder
Dangercoder / auth.clj
Created November 21, 2020 18:42
Pedestal JWT authentication interceptor
(ns interceptors.auth
(:require [cheshire.core :as json]
[clojure.spec.alpha :as s]
[clojure.walk :refer [postwalk]]
[clojure.core.async :as a])
(:import (java.net URL)
(com.auth0.jwk GuavaCachedJwkProvider UrlJwkProvider)
(com.auth0.jwt.interfaces RSAKeyProvider ECDSAKeyProvider)
(com.auth0.jwt.algorithms Algorithm)
(com.auth0.jwt JWT)
@dvingo
dvingo / crux-pull.clj
Created May 5, 2020 16:22
pull api support for crux
(ns datascript-crux.pull-api
(:require
[crux.api :as crux]
[datascript.pull-parser :as dpp]
[my-app.crux-node :refer [crux-node]])
(:import [datascript.pull_parser PullSpec]))
;; lightly adapted from:
;; https://github.com/tonsky/datascript/blob/master/src/datascript/pull_api.cljc
;; https://github.com/tonsky/datascript/blob/master/src/datascript/pull_parser.cljc
@pesterhazy
pesterhazy / indexeddb-multiple-tabs.md
Created February 26, 2019 08:37
Offline-first browser apps and multiple tabs

Offline-first browser apps and multiple tabs

For offline-first operation, browser apps cache data in an IndexedDb database. When the user makes a change while offline, they persist the change optimistically. When connectivity is restored, changes are synced to the server.

This pattern is well established today. However, given the possibility of opening the app in multiple tabs at the same time, we seem to be faced with a dilemma:

  • We allow users to use the app and to make changes in multiple tabs at the same time. But then two "threads" are writing to the same shared resource at the same time. Co-ordinating writes seems to be difficult.

    To make things worse, while the localStorage API allows you to register a callback that fires whenever an item is changed outside the current tab, the IndexedDb API doesn't, at least not in a widely-available way.