Skip to content

Instantly share code, notes, and snippets.

View holyjak's full-sized avatar
💓
Loving Clojure

Jakub Holý holyjak

💓
Loving Clojure
View GitHub Profile
@holyjak
holyjak / deps.edn
Last active October 30, 2020 10:55
cryogen deps
;; Put this inside your blog and use the clojure CLI instead of leiningen to run `clojure -X:serve`
{:deps {org.clojure/clojure {:mvn/version "1.10.1"}
ring-server/ring-server {:mvn/version "0.5.0"}
ring/ring-devel {:mvn/version "1.7.1"}
compojure/compojure {:mvn/version "1.6.1"}
#_#_cryogen-core/cryogen-core {:mvn/version "0.3.2"}
cryogen-asciidoc/cryogen-asciidoc {:mvn/version "0.3.2"}
cryogen-flexmark/cryogen-flexmark {:mvn/version "0.1.4"}
cryogen-core/cryogen-core {:git/url "https://github.com/cryogen-project/cryogen-core" :sha "17cdf3837f17b9b921dce09e4638495984e65a2a"}
}
@holyjak
holyjak / troubleshooting 404 in Spring MVC.md
Created October 22, 2020 22:13
WIP - troubleshooting 404 in Spring MVC 4

Spring 4 - 404 troubleshooting

See https://www.baeldung.com/spring-handler-mappings - explains BeanNameUrlHandlerMapping, SimpleUrlHandlerMapping

Debug DispatcherServlet - DispatcherServlet.getHandler

@holyjak
holyjak / catching-transduce.clj
Created July 10, 2020 17:57
catching-transduce and a mysterious freeze
;; catching-transduce - works most of the time but blocks forever in some case(s)
;; If I interrupt it, it is at line 26, i.e. inside `(a/<!! errors-ch)`
;; inside core.async ... CountDownLatch.await
(with-test
(defn catching-transduce
"Similar to `core.async/transduce` but returns the reduced value and
captures 'anomalies' (i.e. exceptions sent as data) in the `chan` data and
captures exceptions in `xf` and `f`, stopping at the first one.
Returns the result or throws if there was any anomaly / exception."

Update: This has now been published at https://blog.jakubholy.net/2020/error-handling-in-fulcro/

I present three ways of detecting, handling, and showing server-side errors: globally and at the component level.

By default, Fulcro considers only non-200 HTTP status as an error. It is up to you to tell it what is an error and how to handle it.

This is somewhat controversial - as Programming with Pure Optimism in the Fulcro Developers Guide explains:

A server should not throw an exception and trigger a need for error handling unless there is a real, non-recoverable situation.

@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.

@holyjak
holyjak / Fulcro_Field_Notes.adoc
Last active July 26, 2023 17:55
Assorted notes from learning and experimenting with Fulcro [WIP]
@holyjak
holyjak / fulcro-rad-report-needs.md
Last active March 24, 2020 16:07
Fulcro-RAD report needs

I am making a PoC of an app with a number of linked "reports" (mostly master-detail). Some of the features I will need:

  • Ability to sort the tables by one or multiple columns
  • Ability to filter the tables (e.g. "only show people from Norway")
  • Pagination
  • Eventually allow the user to hide some columns (and remember this for the user, e.g. in a cookie / localStorage / server)

As far as I know, fulcro-rad does not support that yet so here are some thoughts about how this could be configured.

@holyjak
holyjak / X Fulcro mystery 2.md
Last active February 10, 2020 09:48
Fulcro mystery 2 - why isn't the initial state normalized in the DB?

Solution

L14 is wrong, it should have been wrapped in {..} and thus a join: :query [{:people [(comp/get-query Person)]}]

@holyjak
holyjak / X Fulcro Mystery 1.md
Last active February 10, 2020 09:47
Fulcro mystery - why is initial state not normalized in the DB?

Solution

There are 2 problems:

  1. L14 should have been {:query [:people (comp/get-query Person)]
  2. L15 mixes the template and lambda forms; it should have been either
:initial-state (fn [_] {:people [(comp/get-initial-state Person {:id 0 :name "Sally" :city "Nowhere" :state "GA"})
 (comp/get-initial-state Person {:id 1 :name "Tom" :city "There" :state "OH"})]}
@holyjak
holyjak / s3_multipart_upload.py
Last active October 24, 2023 21:32 — forked from teasherm/s3_multipart_upload.py
boto3 S3 Multipart Upload with the ability to resume the upload after a failure
#!/usr/bin/env python3
# See https://gist.github.com/teasherm/bb73f21ed2f3b46bc1c2ca48ec2c1cf5
import argparse
import os
import boto3
class S3MultipartUpload(object):
# AWS throws EntityTooSmall error for parts smaller than 5 MB