Skip to content

Instantly share code, notes, and snippets.

View eerohele's full-sized avatar

Eero Helenius eerohele

View GitHub Profile
@eerohele
eerohele / core.clj
Last active February 12, 2020 12:58
(require '[clojure.main :as m])
(m/repl
:init #(apply require m/repl-requires)
:eval (fn [form]
(do
(require '[clojure.pprint :refer [pp pprint]])
(require '[hashp.core])
(eval form))))
@eerohele
eerohele / learnxinyminutes-clojure.markdown
Last active November 21, 2019 08:30
A Markdown version of the Clojure variant of learnxinyminutes https://learnxinyminutes.com/docs/clojure

This is a version of learnxinyminutes for Clojure adapted for use with Useless.

All I've done is lifted most of the comments out of the code blocks, removed the ; => bits, and some minor copy editing.


Clojure is a Lisp family language developed for the Java Virtual Machine. It has a much stronger emphasis on pure functional programming than Common Lisp, but includes several STM utilities to handle state as it comes up.

This combination allows it to handle concurrent processing very simply, and often automatically.

core.async walkthrough

This is a Markdown version of the core.async walkthrough.clj.


This walkthrough introduces the core concepts of core.async.

The clojure.core.async namespace contains the public API.

@eerohele
eerohele / README.md
Last active November 6, 2021 19:10
A minimal, annotated example of using Clojure prepl with core.async
  1. Acknowledge that you might actually want to use Propel instead of relying on this Gist.

  2. Clone this Gist:

    git clone https://gist.github.com/eerohele/e06551b115c6a31d1280a115c4c2abb2 prepl
  3. Open the project in your favorite editor/IDE.

  4. Start evaluating the forms in prepl.clj one by one.

@eerohele
eerohele / nothing.txt
Last active November 21, 2019 09:52
Useless
Hello, world!
@eerohele
eerohele / sudoku_compact.markdown
Created September 6, 2019 19:52 — forked from swannodette/gist:3217582
sudoku_compact.clj

Sudoku

(ns sudoku
  (:refer-clojure :exclude [==])
  (:use clojure.core.logic))

(defn get-square [rows x y]
  (for [x (range x (+ x 3))
        y (range y (+ y 3))]
@eerohele
eerohele / possible-solutions.markdown
Last active September 4, 2019 10:12
shadow-cljs: shadow-cljs server shuts down with `RejectedExecutionException` when running `npx shadow-cljs watch app` (macOS)
  1. In your project.clj, try setting your maximum JVM heap size:

    :jvm-opts ["-Xmx2G"]
@eerohele
eerohele / cert.md
Last active January 11, 2019 07:38
shadow-cljs & mkcert

Using mkcert to generate a trusted certificate for ClojureScript development with shadow-cljs

NOTE: These instructions are a work in progress. Don't trust them yet.

Prerequisites

;; evaluating the hello-world namespace yields:
CompilerException clojure.lang.ExceptionInfo: Call to #'clojure.set/map-invert did not conform to spec:
db.clj:2708
-- Spec failed --------------------
Function arguments
({})
(def app-db
{:nurses {"Nurse ID A" "Name A"
"Nurse ID B" "Name B"}
:patients [{:patient-id "Patient ID A"}
{:patient-id "Patient ID B"}]
;; A map that shows which nurse is assigned to which patient.
:assignments {"Patient ID A" "Nurse ID A"
"Patient ID B" "Nurse ID B"}})