Skip to content

Instantly share code, notes, and snippets.

Avatar
💓
Loving Clojure

Jakub Holy holyjak

💓
Loving Clojure
View GitHub Profile
@holyjak
holyjak / deps.edn
Last active Oct 30, 2020
cryogen deps
View deps.edn
;; 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 Oct 22, 2020
WIP - troubleshooting 404 in Spring MVC 4
View troubleshooting 404 in Spring MVC.md

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 Jul 10, 2020
catching-transduce and a mysterious freeze
View catching-transduce.clj
;; 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."
View Error handling in Fulcro: 3 approaches.adoc

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 Oct 14, 2020
Want more from your frontend framework!
View Fulcr-x-Redux-talk.md

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 Oct 10, 2020
Assorted notes from learning and experimenting with Fulcro [WIP]
View Fulcro_Field_Notes.adoc

Fulcro Field Notes

Assorted notes from learning and experimenting with Fulcro.

General

From Tony Kay:

[..] a guiding principle that always helps me: Rendering in Fulcro is a pure function of state. Get the state right, and rendering will follow.

@holyjak
holyjak / fulcro-rad-report-needs.md
Last active Mar 24, 2020
Fulcro-RAD report needs
View fulcro-rad-report-needs.md

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 Feb 10, 2020
Fulcro mystery 2 - why isn't the initial state normalized in the DB?
View X Fulcro mystery 2.md

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 Feb 10, 2020
Fulcro mystery - why is initial state not normalized in the DB?
View X Fulcro Mystery 1.md

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 Aug 13, 2020 — forked from teasherm/s3_multipart_upload.py
boto3 S3 Multipart Upload with the ability to resume the upload after a failure
View s3_multipart_upload.py
#!/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
You can’t perform that action at this time.