Skip to content

Instantly share code, notes, and snippets.

View ahmed1hsn's full-sized avatar
🎯
Focusing

Ahmed Hassan ahmed1hsn

🎯
Focusing
View GitHub Profile
@leonoel
leonoel / cloroutine-perf.clj
Created April 16, 2022 19:10
cloroutine performance
(ns ^{:doc "
Performance measurements for various generator implementations, cloroutine v10 https://github.com/leonoel/cloroutine
Based on https://clojureverse.org/t/how-to-transform-nested-map-into-flat-sequence-of-path-value-pairs/8801/22
"} cloroutine-perf
(:require [cloroutine.core :refer [cr]]))
(def ^:dynamic *tail*)
(defn gen-seq-dv [gen]
(lazy-seq (binding [*tail* (gen-seq-dv gen)] (gen))))
@spacegangster
spacegangster / timezones.edn
Last active July 15, 2020 14:52
List of standard timezones, scraped from a popular mailing service
;; UPD hey, I'm not sure now if those zones are correct throughout the year
;; see this https://www.creativedeletion.com/2015/01/28/falsehoods-programmers-date-time-zones.html
;; Sorry for misleading you
[{:option/value "Pacific/Tarawa" :option/label "(GMT +12:00) Tarawa"}
{:option/value "Pacific/Auckland" :option/label "(GMT +12:00) New Zealand Time"}
{:option/value "Pacific/Norfolk" :option/label "(GMT +11:00) Norfolk Island (Austl.)"}
{:option/value "Pacific/Noumea" :option/label "(GMT +11:00) Noumea, New Caledonia"}
{:option/value "Australia/Sydney" :option/label "(GMT +10:00) Australian Eastern Time (Sydney)"}
{:option/value "Australia/Queensland" :option/label "(GMT +10:00) Australian Eastern Time (Queensland)"}
{:option/value "Australia/Adelaide" :option/label "(GMT +9:30) Australian Central Time (Adelaide)"}
@ataggart
ataggart / project.clj
Last active June 16, 2020 14:48
Example log4j2 project setup.
(defproject example "0.1.0"
:description "Example configuration for using log4j2 as the concrete logging
implementation. Libraries that depend on other well-known java
logging abstractions (e.g., SLF4J) will be logged with log4j2.
Also configures tools.logging to choose log4j2."
:dependencies [; Provide the log4j2 logging implementation:
[org.apache.logging.log4j/log4j-api "2.13.0"]
[org.apache.logging.log4j/log4j-core "2.13.0"]
; Provide log4j2 adapters for other java logging abstractions:
@holyjak
holyjak / Fulcr-x-Redux-talk.md
Last active December 2, 2021 10:18
Want more from your frontend framework!

Source code for my Telia Full Stack Feast talk "Want more from your frontend framework!" (slides) (6/2020), comparing Redux with REST and a Fulcro with Pathom (Graph API).

Use case we are implementing: Show “hot deals” in your webshop, loaded on-demand.

PS: For the sake of simplicity I am cheating a little and presenting the Fulcro HotDeals component as a root component. If it was used as a child, we would need to either change the a Link Query or make sure that the :deals are presented as a property on the parent component. Also, I use unqualified keys for brevity. This is not recommended in practice.

@saikyun
saikyun / zig_watch.clj
Last active April 8, 2021 09:40
babashka command to watch a folder for changes to .zig-files
#!/usr/bin/env bb
(if *command-line-args*
(def in (str (first *command-line-args*)))
(do
(println "Which bin to run?")
(def in (str *input*))))
(println "Watching" "*.zig" "->" (str "./" in))

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"))
@leonoel
leonoel / asyncawait.clj
Created December 6, 2018 20:17
cloroutine-based async/await
(ns asyncawait
(:refer-clojure :exclude [await])
(:require [cloroutine.core :refer [cr]]))
(defmacro async [& body]
`(js/Promise. (fn [s# f#]
(spawn (cr {await thunk}
(try (s# (do ~@body))
(catch :default e# (f# e#))))))))