Skip to content

Instantly share code, notes, and snippets.

View SerhiiKozachenko's full-sized avatar

Serhii Kozachenko SerhiiKozachenko

View GitHub Profile
@coolaj86
coolaj86 / how-to-publish-to-npm.md
Last active June 9, 2024 23:19
How to publish packages to NPM

Getting Started with NPM (as a developer)

As easy as 1, 2, 3!

Updated:

  • Aug, 08, 2022 update config docs for npm 8+
  • Jul 27, 2021 add private scopes
  • Jul 22, 2021 add dist tags
  • Jun 20, 2021 update for --access=public
  • Sep 07, 2020 update docs for npm version
@lnostdal
lnostdal / cachebuilder.clj
Last active July 14, 2024 14:21
Guava: CacheBuilder / CacheLoader for compute cache type thing and similar
;; This stuff is pretty useful in many contexts.
...
(:import (com.google.common.cache CacheBuilder CacheLoader))
...
quantataraxia.core> (with (-> (CacheBuilder/newBuilder)
(.weakKeys)
(let [f (future
(try
(Thread/sleep 10000)
(catch Throwable e
(println e)
(println "isInterrupted:" (.isInterrupted (Thread/currentThread)))
(println "isAlive:" (.isAlive (Thread/currentThread)))
(println "interrupted:" (Thread/interrupted)))))]
(Thread/sleep 500)
(future-cancel f)
@lnostdal
lnostdal / async_&_transducers.clj
Created May 18, 2018 07:50
how to use transducer with clojure.core.async
;; I keep forgetting how to do this stuff for some reason, so here goes:
(let [c (async/chan 1 (map #(* % 2)))]
(async/go
(loop []
(when-let [e (async/<! c)]
(println "async/go, e:" e)
(recur))))
(async/>!! c 1)
(async/>!! c 2))
@lnostdal
lnostdal / fast_local_mutation.clj
Last active July 13, 2024 16:58
Clojure: Performance of with-local-vars vs. atom vs. volatile vs. unsynchronized-mutable field
;; Performance of with-local-vars vs. atom vs. volatile vs. unsynchronized-mutable field.
(definterface IOObject
(setVal [new-val])
(getVal [])
(oswap [f])
(oswap [f x])
(oswap [f x y])
(oswap [f x y z]))
@lnostdal
lnostdal / upmap.clj
Last active July 13, 2024 16:58
Clojure unordered concurrency test: MAP vs. PMAP vs. UPMAP
;; www.Quanto.ga
;;
;; cp/upmap is from https://github.com/TheClimateCorporation/claypoole
quantataraxia.core> (do
(println "MAP:")
(println (time (doall (map (fn [x] (Thread/sleep x) x)
(range 500 50 -9)))))
(println "PMAP:")