This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-27
Channels
- # announcements (2)
- # aws (31)
- # babashka (81)
- # beginners (82)
- # calva (38)
- # clj-kondo (41)
- # cljdoc (4)
- # cljs-dev (6)
- # clojure (101)
- # clojure-belgium (1)
- # clojure-europe (30)
- # clojure-germany (1)
- # clojure-italy (7)
- # clojure-nl (4)
- # clojure-norway (1)
- # clojure-spec (1)
- # clojure-uk (19)
- # clojurescript (16)
- # clojutre (1)
- # community-development (26)
- # core-logic (2)
- # data-science (26)
- # datomic (71)
- # events (3)
- # fulcro (55)
- # graalvm (2)
- # graphql (3)
- # joker (2)
- # kaocha (19)
- # luminus (2)
- # malli (6)
- # meander (3)
- # off-topic (6)
- # pathom (34)
- # random (1)
- # re-frame (2)
- # robots (1)
- # shadow-cljs (37)
- # sql (30)
- # tools-deps (21)
- # xtdb (4)
- # yada (25)
hmm... anyone know how to go from a BufferedImage to a byte[]? I'm having brain fail (I found some examples, but my head isn't screwed together enough to go from Java to clojure)
https://mkyong.com/java/how-to-convert-bufferedimage-to-byte-in-java/ You’ll need the ImageIO libs though
hmm... this give me most of what I want, but I'll have to round trip it from the file system https://github.com/Clojure2D/clojure2d/blob/master/src/clojure2d/core.clj#L2182
a bit blutak, baling wire, and bubble gum, but this works:
(defn ->workbook [comparison-defs]
(let [wb-data (into []
(mapcat (fn [cd]
[(:title cd)
(:table cd)]))
comparison-defs)
wb-charts (into []
(map (fn [cd]
[(:title cd)
(-> cd :chart :chart-image :buffer ->byte-array)]))
comparison-defs)
wb (apply xl/create-workbook wb-data)]
(run! (fn [[sheet-name img]]
(let [;; int pictureIdx = wb.addPicture(bytes, Workbook.PICTURE_TYPE_JPEG);
pic-idx (.addPicture wb img Workbook/PICTURE_TYPE_PNG)
sheet (xl/select-sheet sheet-name wb)
helper (.getCreationHelper wb)
drawing (.createDrawingPatriarch sheet)
anchor (.createClientAnchor helper)
_ (.setCol1 anchor 14)
_ (.setRow1 anchor 2)
;; Picture pict = drawing.createPicture(anchor, pictureIdx);
;; pict.resize();
pict (.createPicture drawing anchor pic-idx)]
(.resize pict)))
wb-charts)
wb))
(defn ->byte-array [^BufferedImage image]
(with-open [out (.ByteArrayOutputStream.)]
(ImageIO/write image "png" out)
(.toByteArray out)))
and there is always this: https://www.youtube.com/watch?v=Mh85R-S-dh8
Quite a noticeable jump in Covid19 figures yesterday in the UK, from the governments own data https://www.arcgis.com/apps/opsdashboard/index.html#/f94c3c90da5b4e9f9a0b19484dd4bb14
Scotland is doubling every 3 days now https://github.com/watty62/Scot_covid19/blob/master/data/processed/regional_deaths.csv
The data point of how many tests are done is important to understand the number of cases. It’s missing from most sets I’ve seen.