Skip to content

Instantly share code, notes, and snippets.

@jeroenvandijk
jeroenvandijk / malli_inline_output.clj
Created November 3, 2022 14:25
Malli inline validation printing
(ns malli.inline-output
(:require
[edamame.core :refer [parse-string]]
[malli.core :as m]
[malli.error :as me]))
;; -- helper code to find location data in an edn file
(defprotocol IUnwrap
(unwrap [_]))
@ssrihari
ssrihari / clojure-learning-list.md
Last active June 22, 2024 09:37
An opinionated list of excellent Clojure learning materials

An opinionated list of excellent Clojure learning materials

These resources (articles, books, and videos) are useful when you're starting to learn the language, or when you're learning a specific part of the language. This an opinionated list, no doubt. I've compiled this list from writing and teaching Clojure over the last 10 years.

  • 🔴 Mandatory (for both beginners and intermediates)
  • 🟩 For beginners
  • 🟨 For intermediates

Table of contents

  1. Getting into the language
@borkdude
borkdude / cli_app.clj
Last active August 3, 2022 10:16
babashka.cli args->opts
(ns cli-app
(:require [babashka.cli :as cli]))
(def spec {:hello {:desc "something"}
:foo {:desc "foo"}
:bar {:desc "bar"
:coerce []}})
(def cli-opts {:spec spec
:args->opts (cons :foo (repeat :bar))})
@slimsag
slimsag / ramblings.md
Last active December 13, 2023 08:02
Because cross-compiling binaries for Windows is easier than building natively

Because cross-compiling binaries for Windows is easier than building natively

I want Microsoft to do better, want Windows to be a decent development platform-and yet, I constantly see Microsoft playing the open source game: advertising how open-source and developer friendly they are - only to crush developers under the heel of the corporate behemoth's boot.

The people who work at Microsoft are amazing, kind, talented individuals. This is aimed at the company's leadership, who I feel has on many occassions crushed myself and other developers under. It's a plea for help.

The source of truth for the 'open source' C#, C++, Rust, and other Windows SDKs is proprietary

You probably haven't heard of it before, but if you've ever used win32 API bindings in C#, C++, Rust, or other languages, odds are they were generated from a repository called microsoft/win32metadata.

flf2a$ 6 4 6 -1 4
3x5 font by Richard Kirk (rak@crosfield.co.uk).
Ported to figlet, and slightly changed (without permission :-})
by Daniel Cabeza Gras (bardo@dia.fi.upm.es)
@
@
@
@
@
@johanmynhardt
johanmynhardt / user.clj
Created April 9, 2022 22:34
Simple Zipper-based Syndication XML Extractor to navigate the "What's New?" AWS Feed.
(ns user
"Simple Syndication XML Extractor to navigate the available AWS Feed."
(:require [clojure.data.xml :as xml]
[clojure.java.io :as io]
[clojure.pprint :refer [pprint]]
[clojure.string :as str]
[clojure.zip :as z]))
(def aws-feed-url "https://aws.amazon.com/about-aws/whats-new/recent/feed/")
@cgrand
cgrand / doto.clj
Last active November 3, 2021 22:31
A usage of `doto` that I overlooked for years
;; let's say you want to perform an action only when a state is true and returns true/false depending on the action success
;; typically I would write
(if @open ; check state
(do
(.put q bytes) ; action
true)
false)
;; or
@bhauman
bhauman / core.cljs
Last active June 14, 2021 23:34
Generating a random ceramic tile layout for my shower in CLJS
(ns ^:figwheel-hooks tilelayout.core
(:require
[goog.dom :as gdom]
[goog.crypt.base64 :as base64]
[goog.events :as gevent]
[clojure.string :as string]
[cljs.reader :refer [read-string]])
(:import [goog History]))
;; TILE LAYOUT GENERATION
@stelcodes
stelcodes / bb-postgresql-backup-restore.edn
Last active July 1, 2022 05:20
Babashka Tasks for PostgreSQL Backups
; run `bb backup` to backup database
; run `bb restore` to restore latest backup
{:min-bb-version "0.4.0",
:tasks {; CONSTANTS
db-name "dev_blog",
backup-dir "backups",
now (str (java.time.LocalDateTime/now)),
; TASKS
create-backup-dir {:depends [backup-dir], :task (babashka.fs/create-dirs backup-dir)},
@realgenekim
realgenekim / README.md
Last active July 21, 2023 14:29
How to download all Clojure dependencies using clj (equivalent to "lein deps")

I recently had to figure out for a Clojure application how to download all dependency JAR files, for use in a Docker container.

When creating an uberjar, depstar re-downloaded all the external dependencies from Maven central, even though in an earlier Docker build step, I ran clj -Spath to pre-download them (presumably cached into the .m2 directory). In the past, I've used lein deps to do something similiar.

I'm grateful for Sean Corfield helping out (again!!): In short, use clj -P (short for "prepare") to download dependencies. Note the "A:depstar" option, which ensures that the depstar dependencies are downloaded, too.

Here's what it looks like in a Dockerfile:

# to pre-download dependencies, only done if deps.edn changes