Skip to content

Instantly share code, notes, and snippets.

@ssrihari
ssrihari / clojure-learning-list.md
Last active April 24, 2024 03:06
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
@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)},
@coltenkrauter
coltenkrauter / fix-wsl2-dns-resolution
Last active April 26, 2024 06:32
Fix DNS resolution in WSL2
More recent resolution:
1. cd ~/../../etc (go to etc folder in WSL).
2. echo "[network]" | sudo tee wsl.conf (Create wsl.conf file and add the first line).
3. echo "generateResolvConf = false" | sudo tee -a wsl.conf (Append wsl.conf the next line).
4. wsl --terminate Debian (Terminate WSL in Windows cmd, in case is Ubuntu not Debian).
5. cd ~/../../etc (go to etc folder in WSL).
6. sudo rm -Rf resolv.conf (Delete the resolv.conf file).
7. In windows cmd, ps or terminal with the vpn connected do: Get-NetIPInterface or ipconfig /all for get the dns primary and
secondary.
@evancz
evancz / data-interchange.md
Last active April 12, 2024 08:39
Why do I have to write JSON decoders in Elm?

A vision for data interchange in Elm

How do you send information between clients and servers? What format should that information be in? What happens when the server changes the format, but the client has not been updated yet? What happens when the server changes the format, but the database cannot be updated?

These are difficult questions. It is not just about picking a format, but rather picking a format that can evolve as your application evolves.

Literature Review

By now there are many approaches to communicating between client and server. These approaches tend to be known within specific companies and language communities, but the techniques do not cross borders. I will outline JSON, ProtoBuf, and GraphQL here so we can learn from them all.

@stuarthalloway
stuarthalloway / missing_keys_specs.clj
Created October 14, 2017 11:44
I think it would be a mistake to introduce temporal coupling to prevent typos.
;; I think it would be a mistake to introduce temporal coupling to prevent typos.
;; The example program below lets you identify "missing" keys specs at
;; the time and place of your choosing, and then handle them as you
;; deem appropriate, without imposing those decisions on other
;; users of spec.
(require '[clojure.spec.alpha :as s]
'[clojure.set :as set])
@SKempin
SKempin / Git Subtree basics.md
Last active April 17, 2024 03:47
Git Subtree basics

Git Subtree Basics

If you hate git submodule, then you may want to give git subtree a try.

Background

When you want to use a subtree, you add the subtree to an existing repository where the subtree is a reference to another repository url and branch/tag. This add command adds all the code and files into the main repository locally; it's not just a reference to a remote repo.

When you stage and commit files for the main repo, it will add all of the remote files in the same operation. The subtree checkout will pull all the files in one pass, so there is no need to try and connect to another repo to get the portion of subtree files, because they were already included in the main repo.

Adding a subtree

Let's say you already have a git repository with at least one commit. You can add another repository into this respository like this:

@stuarthalloway
stuarthalloway / errors_as_data.clj
Created March 16, 2017 17:27
Errors as data compose, error messages not so much
;; spec errors are data, and as such are composable with all the rest
;; of Clojure. The forms below show getting to an interesting part
;; of an error in a larger data structure, taking advantage of
;; edn-reading, pretty-printing, *print-length* and threading macro.
;; It is difficult to maintain the compositionality shown here
;; once you convert error data into e.g. ASCII art.
(require
'[clojure.edn :as edn]
@fab1an
fab1an / GeoJsonMapLayer.js
Last active January 10, 2022 03:50
React / Leaflet combination
export default class GeoJsonMapLayer extends React.Component {
render() {
return (
<div>
</div>
);
}
componentWillUnmount() {
if (this.layer) {
@gfredericks
gfredericks / defn+spec.clj
Created June 9, 2016 19:02
A defn-like macro powered by clojure.spec
(ns user.defn+spec
(:require [clojure.spec :as s]))
(defn non-&-sym? [x] (and (symbol? x) (not= '& x)))
(s/def ::arglist
(s/cat :normal-args (s/* (s/cat :name non-&-sym?
:spec-form (s/? (s/cat :- #{:-}
:spec ::s/any))))
:varargs (s/? (s/cat :& #{'&}
@aphyr
aphyr / with-retry.clj
Created January 20, 2016 03:14
Recur from within catch block
(defrecord Retry [bindings])
(defmacro with-retry
"It's really fucking inconvenient not being able to recur from within (catch)
expressions. This macro wraps its body in a (loop [bindings] (try ...)).
Provides a (retry & new bindings) form which is usable within (catch) blocks:
when this form is returned by the body, the body will be retried with the new
bindings."
[initial-bindings & body]
(assert (vector? initial-bindings))