Skip to content

Instantly share code, notes, and snippets.

@4mitch
4mitch / .block
Created March 1, 2021 09:15 — forked from vasturiano/.block
Timelines Chart
View .block
height: 700
scrolling: yes
@4mitch
4mitch / fibers.clj
Created December 25, 2019 21:38
JDK 14 - Project Loom virtual threads (ex-fibers) test - CAS vs LongAdder performance comparison
View fibers.clj
(ns me.core
(:import [java.util.concurrent.atomic LongAdder]
[java.util.concurrent CountDownLatch]))
(defmacro fiber [& body]
`(.. (Thread/builder)
(virtual)
(task (fn [] ~@body))
; (build)
@4mitch
4mitch / lein-different-jvm.sh
Created December 25, 2019 09:43 — forked from camsaul/lein-different-jvm.sh
Run lein with different JVM
View lein-different-jvm.sh
#!/bin/bash
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home lein run
@4mitch
4mitch / day3part1.clj
Created December 15, 2019 22:13
Advent of Code '19 day 3 part 1
View day3part1.clj
(defn step [s]
[(keyword (subs s 0 1)) (Integer/parseInt (subs s 1))])
(defn get-dots [dots action]
(let [[op len] action
dots dots
from (last dots)
[from_x from_y] from
f+x (partial + from_x 1)
f-x (partial - from_x 1)
View gist:91a8ffa19f24366649fa59f26bde6765
;; Gaussian sum!
user=> (crit/with-progress-reporting (crit/quick-bench (/ (* (+ 1 99999) 99999) 2)))
Warming up for JIT optimisations 5000000000 ...
compilation occured before 333366 iterations
Estimating execution count ...
Sampling ...
Final GC...
Checking GC...
WARNING: Final GC required 8.548926352381509 % of runtime
Finding outliers ...
@4mitch
4mitch / shot-and-roll.clj
Created May 13, 2019 22:29
1 shot to 10 values target and then roll the dice as many as shot
View shot-and-roll.clj
(let [q 6
n 10]
(/ (* q
(- 1
(js/Math.pow q n)))
(- 1 q)
)
)
@4mitch
4mitch / readme.md
Created May 12, 2019 19:43
Gist Markdown Cheatsheet
View readme.md

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5
Heading 6

Paragraph

@4mitch
4mitch / setup_docker-machine.md
Last active May 12, 2019 20:29
Установка Docker и MS SQL 2017 в несколько строк
View setup_docker-machine.md
  1. Установить VirtualBox

  2. Скачать docker machine, прописать в path

  3. Выполнить docker-machine create -d virtualbox --virtualbox-boot2docker-url https://releases.rancher.com/os/latest/rancheros.iso --virtualbox-memory "2048" VM4DOCKERNAME (VM4DOCKERNAME as you wish)

  4. Проверить докер-vm docker-machine ls

  5. Работа с docker
    5.1. Заходим в докер-vm

@4mitch
4mitch / tabl.clj
Created April 28, 2019 17:29
Treat a sequence as a table in Clojure
View tabl.clj
(->>
'(1 2 3 4)
(map #(Math/pow % 2))
(partition 2)
(map println)
dorun
)
@4mitch
4mitch / promise_test.cljs
Last active April 26, 2019 20:39
CLJS uses js promises
View promise_test.cljs
(defn subtask+ []
(js/Promise. (fn [resolve]
(js/setTimeout #(resolve :success) 5000)))
)
(defn main []
(-> (subtask+)
(.then (fn [result] (println "Got " result) ))
(.catch (fn [e] (println "Shit happend! " e )) )
))