Skip to content

Instantly share code, notes, and snippets.

Avatar
💓
Loving Clojure

Jakub Holy holyjak

💓
Loving Clojure
View GitHub Profile
@holyjak
holyjak / fulcro-rad-notes.md
Last active Jan 15, 2021
Fulcro RAD - assorted notes
View fulcro-rad-notes.md

Unsorted notes on Fulcro RAD.

Reports

Displaying to-one :ref attributes

If you have a :ref attribute, you typically do not want to display it directly, i.e. its ident, but a more display-friendly prop of the child entity. This is handled automatically for you by Pathom, you only need to specify the attribute you want.

Let's assume you have a Person entity with the ref attribute person/home-address with the target address/id. You can simply have ro/columns [person/name ... address/city address/country] (assuming these attributes are defined and have :address/id among their ao/identities). Pathom can navigate from person/home-address -> address/id -> address/city etc.

@holyjak
holyjak / Fulcro_Field_Notes.adoc
Last active Jan 6, 2021
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-router-wrong-target-issue.md
Last active Dec 15, 2020
Description of a problem with UI displaying one target, Router beliving it displays another one.
View Fulcro-router-wrong-target-issue.md

I am running into an issue with Fulcro 3.4 and RAD 1.0.8 where the UI shows the (non-default) router target in an uninitialized state while the router believes that it is displaying the default target. I still cannot figure out why.

I have three nested routers (along with some other components): RootRouter > OrgRouter > OrgDashboard for org id=nnn > DetailsDisplayRouter with :targets [LatestBillRunList SubscriberList] and the URL .../org/123/subscribers and I expect to see the SubscriberList RAD report - which I do, but it is empty, even though the DB has the data, because the parent router believes it is displaying the other report . This only happens when I go to the URL in the browser, not when I click myself through the app to the state.

So how is it possible that DetailsDisplayRouter believes it is displaying LatestBillRunList while it should, and the UI does, show SubscriberList?!

I understand why the report is empty despite the presence of its data - Fulcro believes it is not showi

@holyjak
holyjak / blog.scss
Created Dec 10, 2019
Cryogen customization: autolink headings etc.
View blog.scss
#post a.anchor, #custom-page a.anchor {
float: left;
padding-right: 4px;
margin-left: -20px;
}
@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 / 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.

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 / 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
@holyjak
holyjak / plot-usage.gp
Last active Jul 28, 2020
Gnuplot script to plot memory, CPU usage of a process from `top`
View plot-usage.gp
#!/usr/bin/env -S gnuplot --persist -c
# Plot memory and CPU usage over time. Usage:
# usage-plot.gp <input file> [<output .png file>]
# where the input file has the columns `<unix time> <memory, with m/g suffix> <% cpu>`
# To create the input file, see https://gist.github.com/jakubholynet/931a3441982c833f5f8fcdcf54d05c91
# Arguments:
infile=ARG1
outfile=ARG2
set term x11
You can’t perform that action at this time.