Skip to content

Instantly share code, notes, and snippets.

View ahmed1hsn's full-sized avatar

Ahmed Hassan ahmed1hsn

View GitHub Profile

Advance the support of Scala.js in Dotty, a tutorial

Dotty contains preliminary support for Scala.js under the flag -scalajs. Or rather, it contains the infrastructure for preliminary support. It is far from being actually usable, but this is where you can help!

This small tutorial walks you through a few steps that you can do to further the support of Scala.js in Dotty. Even if you do not typically contribute to a compiler, this can be your chance. It is not very difficult, given that there already exists an extensive test suite, as well as a working implementation for scalac.

@jamesanto
jamesanto / Filter2FilterTest.scala
Created July 23, 2019 13:07
Generic Services & Filters based on Finagle, using ZIO
import org.scalatest.{FreeSpec, Matchers}
class Filter2FilterTest extends FreeSpec with Matchers with ZioTestSupport {
case class JsonErr()
case class JsonReq()
case class JsonRes()
@zed-dz
zed-dz / offline_mdn_docs.md
Created March 12, 2019 14:01
Offline MDN Docs
(ns deployer
(:require [clojure.tools.deps.alpha :as deps]
[clojure.tools.deps.alpha.reader :as reader]
[clojure.java.io :as io]
[clojure.string :as string])
(:import (java.security MessageDigest)
(com.jcraft.jsch JSch)
(java.net URI)))
(def hex-alphabet (vec "0123456789ABCDEF"))
{:deps
{org.clojure/clojure {:mvn/version "1.9.0"}
com.datomic/datomic-free {:mvn/version "0.9.5697"}}}
@gvolpe
gvolpe / di-in-fp.md
Last active September 16, 2024 07:18
Dependency Injection in Functional Programming

Dependency Injection in Functional Programming

There exist several DI frameworks / libraries in the Scala ecosystem. But the more functional code you write the more you'll realize there's no need to use any of them.

A few of the most claimed benefits are the following:

  • Dependency Injection.
  • Life cycle management.
  • Dependency graph rewriting.
(defn relate [& pairs]
(assert (even? (count pairs)) "relate requires an even number of arguments")
(->> pairs
(partition 2)
(map (fn [[k vs]] (map #(hash-map k %) vs)))
(apply map merge)))
(defn matches-specmap? [specmap m]
(reduce-kv
@borkdude
borkdude / specter.clj
Last active October 16, 2024 20:01
Vanilla Clojure vs. Specter vs. transducers
(ns specter-idea
(:require [com.rpl.specter :as specter :refer [setval ALL
NONE multi-path
selected?
pred
]]))
(def data ;; only x and y are allowed
[{:name "x" :rels ["x" "y"]} ;=> fine, keep as is
{:name "y" :rels ["x" "y" "z"]} ;=> keep only allowed rels: {:name "y" :rels ["x" "y"]}
@favila
favila / datomic-counter.clj
Created September 29, 2017 16:23
Demonstrate the creation and use of an auto-increment counter (with nonce) in datomic
(require '[datomic.api :as d])
(d/create-database "datomic:mem://counter-example")
;=> true
(def c (d/connect "datomic:mem://counter-example"))
;=> #'user/c
;; The essential features of creating and using an auto-increment counter in datomic:
;;
;; 1. A counter entity must store the current value and a nonce.

Thread Pools

Thread pools on the JVM should usually be divided into the following three categories:

  1. CPU-bound
  2. Blocking IO
  3. Non-blocking IO polling

Each of these categories has a different optimal configuration and usage pattern.