Skip to content

Instantly share code, notes, and snippets.

View mishok13's full-sized avatar

Andrii Mishkovskyi mishok13

View GitHub Profile
@kachayev
kachayev / sleeping-barber-problem.clj
Last active August 21, 2017 23:10
Resolve "Sleeping barber problem" with Clojure
(def open-for-business? (atom true))
(def haircut-count (agent 0))
(def waiting-room (ref []))
(def waiting-room-size 3)
(defn open-shop [duration]
(do (Thread/sleep duration) (swap! open-for-business? not)))
(defn add-customers []
(future
(require 'ido)
(ido-mode t)
(setq ido-enable-prefix nil
ido-enable-flex-matching nil
ido-create-new-buffer 'never
ido-max-prospects 10
ido-default-buffer-method 'selected-window
ido-default-file-method 'selected-window)
;; List of N most recent files, persisent between emacs session.
(defun use-theme (theme &optional no-confirm no-enable)
(interactive
(list
(intern (completing-read "Load custom theme: "
(mapcar 'symbol-name
(custom-available-themes))))
nil nil))
(progn
(dolist (curtheme (custom-available-themes))
(disable-theme curtheme))
@ecmendenhall
ecmendenhall / quiet-queries.clj
Created June 20, 2013 00:21
Quiet cascalog queries
(require '[cascalog.io :refer [with-log-level])
(defmacro ?<-- [& forms] `(with-log-level :fatal (?<- ~@forms)))
@evancz
evancz / Architecture.md
Last active December 21, 2022 14:28
Ideas and guidelines for architecting larger applications in Elm to be modular and extensible

Architecture in Elm

This document is a collection of concepts and strategies to make large Elm projects modular and extensible.

We will start by thinking about the structure of signals in our program. Broadly speaking, your application state should live in one big foldp. You will probably merge a bunch of input signals into a single stream of updates. This sounds a bit crazy at first, but it is in the same ballpark as Om or Facebook's Flux. There are a couple major benefits to having a centralized home for your application state:

  1. There is a single source of truth. Traditional approaches force you to write a decent amount of custom and error prone code to synchronize state between many different stateful components. (The state of this widget needs to be synced with the application state, which needs to be synced with some other widget, etc.) By placing all of your state in one location, you eliminate an entire class of bugs in which two components get into inconsistent states. We also think yo
@mkwatson
mkwatson / while-macro.clj
Last active July 6, 2019 20:27
while->
(defmacro while->
"Takes a predicate, expression, and forms. Threads expr
through each form for which applying pred to the returned
value is true. Threading short circuits after the first
false expression."
[pred expr & forms]
`(if (~pred ~expr)
~(if (not-empty forms)
(let [next-expr `(-> ~expr ~(first forms))]
`(if (~pred ~next-expr)
@thaJeztah
thaJeztah / a-do-a-run-run-a-do-a-run.md
Last active March 5, 2024 14:32
Silly experiments with `RUN --mount`

Silly experiments with RUN --mount

relates to moby/moby#32507, moby/buildkit#442

Doing some silly experimenting with RUN --mount:

# syntax=docker/dockerfile:1

FROM alpine AS stage1