Skip to content

Instantly share code, notes, and snippets.

View darkleaf's full-sized avatar

Mikhail Kuzmin darkleaf

View GitHub Profile
(eval-after-load 'clojure-mode
'(setq clojure--prettify-symbols-alist
'(("\\\"" . ?״))))
(use-package clojure-mode
:init
(add-hook 'clojure-mode-hook #'prettify-symbols-mode))
package gmonit;
import com.newrelic.api.agent.NewRelic;
import com.newrelic.api.agent.Trace;
import clojure.lang.IFn;
import clojure.lang.ISeq;
public final class TracedFn implements IFn {
IFn fn;
@darkleaf
darkleaf / plan
Last active October 13, 2021 07:41
projectile
magit
parinfer
cider
числа
строки
кейворды
символы
@darkleaf
darkleaf / madbrains
Last active September 17, 2021 16:10
Вводная про монады, монадическое значение, монадическая функция, композер
примеры монад - Promice, Optional, Completable Future, async/await
Do notation
Вводная про континуации, через исключения.
Вводная про генераторы, без стека, со стеком, показать стейт-машину
project loom
Next, return, throw
Цветные функции.
@darkleaf
darkleaf / batch.js
Last active September 4, 2021 17:11
function* getFullPost(id) {
const post = yield ['getPost', id]
const [author, comments] = yield* all([
getFullUser(post.authorId),
all(post.commentIds.map(id => getFullComment(id))),
])
return {
...post,
author,
comments,
@darkleaf
darkleaf / merge-with-key.clj
Created January 9, 2021 07:13 — forked from mlimotte/merge-with-key.clj
Clojure merge-with-key
(ns mlimotte.util)
; A variation on clojure.core/merge-with
(defn merge-with-key
"Returns a map that consists of the rest of the maps conj-ed onto
the first. If a key occurs in more than one map, the mapping(s)
from the latter (left-to-right) will be combined with the mapping in
the result by calling (f key val-in-result val-in-latter)."
[f & maps]
@darkleaf
darkleaf / question.md
Last active April 15, 2023 08:34
Algebraic effects для Clojure.

Привет!

Ключевые слова: coroutine, continuation, generators, async/await, project loom, free monad, algebraic effects.

Я хочу сделать алгебраические эффекты для Clojure(Script). Я уже сделал библиотеку https://github.com/darkleaf/effect/blob/doc-2/README.md Но есть моменты, которые вызывают у меня вопросы.

Если очень кратко, то лично мне эффекты нужны, чтобы:

  1. удобно тестировать бизнес логику
(ns example.core
(:require
[goog.dom :as dom]
[applied-science.js-interop :as j]
[example.react :as react]
[goog.object :as gobj]
[clojure.walk :as w]))
(def e (gobj/get js/React "createElement"))
@darkleaf
darkleaf / example.core.clj
Created April 21, 2020 12:04
react interop example
(ns example.core
(:require
[hicada.compiler :as h]))
(defmacro html [body]
(h/compile body {} {} &env))
create table keys (
  id       integer      primary key,
  name     varchar(255) not null
);

create table data (
  point     timestamptz not null,
  key_id    integer not null,
  value     real not null