Skip to content

Instantly share code, notes, and snippets.

@wilkerlucio
wilkerlucio / pathom-persistent-cache.clj
Last active March 3, 2020 13:42
Pathom cache extension example
(defn cache-resolver [resolver]
(update resolver ::pc/resolve
(fn [resolve]
(fn [{::keys [persistent-cache*] :as env} input]
(let [cache-key [(::pc/sym resolver) input (p/params env)]]
(if-let [[_ v] (find @persistent-cache* cache-key)]
v
(let [response (resolve env input)]
(swap! persistent-cache* assoc cache-key response)
response)))))))
(ns ucv.models.user
(:require #?@(:clj [[datomic.api :as d]
[ucv.util :as util :refer [spy when-clj]]]
:cljs [[ucv.auth :as auth]
[ucv.util :as util :refer-macros [spy when-clj]]])
[clojure.spec.alpha :as s]
[taoensso.timbre :as log]
[fulcro.client.primitives :as prim :refer [defsc]]
[ucv.util :as util]
@jamesnyika
jamesnyika / React Navigation V3+ in Clojurescript.md
Last active November 16, 2020 14:10
React Navigation V3+ in Clojurescript

React Navigation is a great component for building mobile applications. It is versatile and supports both dominant platforms beautifully. However, despite the 2 libraries that exist out there to support this component in the Clojure ecosystem, there is sadly very little documentation on what and how you can set up and use this component. I could not get them to work for me (my failing) so I decided to try and make it work without the existing libraries just to that I can understand what is going on. Below is a laying out of my experience. Let me know if you have corrections so that we mortals who are not that sharp can learn.

React Navigation requires an exact set of steps to make it successfully work

Step 1: Installation of React Navigation

Use yarn to add the library to the project

@conan
conan / url-spec.clj
Last active December 30, 2019 16:32
(require
'[cemerick.url :as url]
'[clojure.spec.alpha :as s]
'[clojure.spec.gen.alpha :as sgen])
(defn non-empty-string-alphanumeric
[]
(sgen/such-that #(not= "" %)
(sgen/string-alphanumeric)))
@swannodette
swannodette / inference.md
Last active August 7, 2023 16:13
Externs Inference

Externs Inference

Integrating third party JavaScript libraries not written with Google Closure Compiler in mind continues to both be a source of error for users when going to production, and significant vigilance and effort for the the broader community (CLJSJS libraries must provide up-to-date and accurate externs).

In truth writing externs is far simpler than most users imagine. You only need externs for the parts of the library you actually intend to use from ClojureScript. However this isn't so easy to determine from Closure's own documentation. Still in the process of writing your code it's easy to miss a case. In production you will see the much dreaded error that some mangled name does not exist. Fortunately it's possible to enable some compiler flags :pretty-print true :pseudo-names true to generate an advanced build with human readable names. However debugging missing externs means compiling your production build for each missed case. So much time wasted for such simple mistakes damages our sen

@selfsame
selfsame / style.md
Last active February 1, 2016 16:00

finalpage dev gist blog

@kovasb
kovasb / gist:9b625b8e82b0aa08c1c9
Last active January 13, 2016 16:59
Assessing Spark & Flink from Clojure POV
**Concerns
- Interactivity
-- Incremental extension or modification of running system
- Modularity
-- Pluggable serialization, storage, conveyance, scheduling, lifecycle hooks etc etc
**Spark Summary
- RDDs: represent a lazily-computed distributed dataset
-- each dataset is broken up into 'partitions' that individually sit at different machines
-- just a DAG with edges annotated to describe relationship between partitions of parent and partitions of child
@anmonteiro
anmonteiro / composite.cljs
Last active November 5, 2018 16:59
Code for the series of posts "An exploration of object recursion design patterns in Om Next recursive queries"
;; =============================================================================
;; Composite
(def composite-data
{:composite/item {:id 0
:width 400
:height 400
:color "#428BCA"
:children [{:id 1
:width 200

Writing Generic Components

The React community has gone through several patterns for how to compose React components, but it generally has settled on a few techniques. Which one you use depends on the type of component you are building.

Using props.children

The simplest way to make a component more generic is to allow

@bhauman
bhauman / README.md
Last active December 3, 2019 16:43
ClojureScript minimal dev and prod setup.

Recent improvements to the ClojureScript compiler have greatly simplified setting up development versus production outputs.

This example uses Figwheel as something that you want to exclude for production, but the pattern is general.

With this simple setup you only need one html file/view and it will work for developement and production.