Skip to content

Instantly share code, notes, and snippets.

View avocade's full-sized avatar
💭
Designing domains and coding clojure for Fluent.to

Oskar Boëthius Lissheim avocade

💭
Designing domains and coding clojure for Fluent.to
View GitHub Profile
@eneroth
eneroth / rama_electric.clj
Last active September 8, 2023 15:39
Rama + Electric
;; ## General helpers
(ns app.helpers.rama
(:require
[missionary.core :as m]
[taoensso.timbre :as timbre])
(:import
[com.rpl.rama Depot PState Path ProxyState$Callback RamaModule]
[com.rpl.rama.test InProcessCluster LaunchConfig]
[hyperfiddle.electric Failure Pending]))
@dustingetz
dustingetz / electric-presence.md
Last active November 12, 2023 15:46
Multiplayer chat with presence – Electric Clojure
@dustingetz
dustingetz / sql_basic_demo_electric.md
Last active January 30, 2024 17:37
SQL basic demo – Electric Clojure

PostgreSQL hello world — Electric Clojure

How do I integrate a SQL database backend?

Easy:

  • make an ordinary Clojure function query-pokemon-list for the query
  • The query is blocking, and Electric Clojure is async, so use e/offload to move it to a thread pool.
    • (Don't block the event loop!)
  • e/offload throws Pending until the query finishes, and then the exception "goes away"
(ns app.mappy
#?(:cljs (:require-macros app.mappy))
(:require #?(:clj [datascript.core :as d]) ; database on server
#?(:clj [clojure.data.csv :as csv])
[hyperfiddle.electric :as e]
[hyperfiddle.electric-dom2 :as dom]
[hyperfiddle.electric-ui4 :as ui]
#?(:cljs ["@openlayers-elements/core/ol-map" :as ol-map])
#?(:cljs ["@openlayers-elements/maps/ol-layer-openstreetmap" :as ol-layer-openstreetmap])
#?(:cljs ["@openlayers-elements/core/ol-layer-vector" :as ol-layer-vector])
@dustingetz
dustingetz / a.md
Last active February 25, 2023 23:42
Photon demo: Datomic web explorer in one file

Datomic web explorer

  • Client API, tested on Datomic Cloud
  • database entity browser
  • server paginated infinite scroll
  • streaming information model - displays incremental resultsets as they become available (useful for slow queries)
  • automatic backpressure and cancellation of abandoned queries
  • custom web renderers with dynamic queries

Code is not optimized yet – we are still learning the idioms.

@dustingetz
dustingetz / electric-virtual-scroll-v2.md
Last active February 25, 2023 23:41
Electric virtual scroll over node_modules v2

virtual scroll over node_modules v2 — Electric Clojure

  • Direct filesystem reads from the view
  • Direct function composition in the style of PHP, despite network
  • No API, no client side database, no frontend state at all (except DOM), no frontend/backend.
  • Literally all accidental complexity GONE
  • 100% of server data sync is managed by Electric
  • Rows have arbitrary server local data access, here querying file metadata #clojure
  • Optimized and no scroll jank – DOM elements are fixed in place and reused

TodoMVC Composed (it's just a for loop!!!) — Electric Clojure

  • An early demonstration "Compiler Managed Network" and the extreme dynamic composition it makes possible
  • TodoMVC Composed merely calls the previous TodoMVC function inside a for loop.
20220822.Todomvc.Composed.mp4
@dustingetz
dustingetz / electric-todomvc.md
Last active August 6, 2023 03:30
Photon TodoMVC, with a twist!

TodoMVC, with a twist! — Electric Clojure

  1. it's multiplayer! 0 LOC cost
  2. state is durable! (server side database) 0 LOC cost
  3. See those pending spinners? We've added a server delay to demonstrate managed load states.
20220817.todomvc.mp4

Electric is a "multi tier" Clojure/Script dialect for full-stack web application development. It uses macros to let you interweave client and server code in a single .CLJC file, so you can define a full-stack frontend/backend webapp all in one place. Electric is designed for rich dynamic applications with reactive user interfaces and complex frontend/backend data sync requirements.

@boberito
boberito / progressbar-osacompile.sh
Created April 12, 2021 19:04
Applescript Progress bar from Curl output redirect
#!/bin/bash
osacompile -x -o test.app<<EOF
set progress description to "Download progress indicator"
set progress additional description to "Preparing…"
set progress total steps to -1
delay 5
set i to 0
set progress total steps to 100
@gws
gws / cognitect_aws_api_web_identity.clj
Created December 31, 2020 18:33
Cognitect AWS API with web identity
;; Copyright 2020 Gordon Stratton
;;
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;; http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,