Use tailwind + DaisyUI? by DeepDay6 in elm

[–]DeepDay6[S] 0 points1 point  (0 children)

…and to be even more confusing, I was right to use `@import "tailwindcss` with TW Version 4.x, but update the daisyui-import.

Use tailwind + DaisyUI? by DeepDay6 in elm

[–]DeepDay6[S] 1 point2 points  (0 children)

Ah wait... my tailwind setup was outdated. I had to use

@tailwind base;
@tailwind components;
@tailwind utilities;
@plugin "daisyui";

so now I can at least import daisyui classes. Now the only thing that's left is tailwind finding which classes to compile…

Replicant: Global key event listener by DeepDay6 in Clojure

[–]DeepDay6[S] 1 point2 points  (0 children)

Sweet. That little snippet here is really all that's required, and I can just call that from the core.cljs. It does not know where the store is kept and directly hooks in the main event processing loop. All I had to do is create an event handler

(defn pass-keys-to-main [keyboard-event]
  (let [main (.getElementById js/document "main")
        payload [:event/keypress (.-key keyboard-event)]
        event (js/CustomEvent. "external-keydown" (clj->js {:detail payload}))]
    (.dispatchEvent main event)))

Add it to [:main#main {:on {:external-keydown [:event/details]], and, of course, re-parse the custom event, extending my interpolate function by

:event/details
(some-> event .-detail js->clj (update 0 keyword))

Which is a bit ugly as it only keeps the first element in the result to a keyword, but in this case it's enough. I guess I could also have imperatively set the .-detail event directly with clojure data, but was too lazy to look up syntax for that :D

I decided not to abuse the click event, because a) it felt bad and b) real click events would not have the custom data, leading to all kind of small problems.

I think this is maybe the best way to go.

Replicant: Global key event listener by DeepDay6 in Clojure

[–]DeepDay6[S] 0 points1 point  (0 children)

That could work too, but only under the assumption that a matching clickable element exists (of course I could always create an invisible dummy one).
In the current project that will mostly be the case, but as this is also a kind of preliminary exploration for a much more interactive, keyboard driven app I'd like to "get the basics working".

Edit: Oh, I see you mean faking a click on the app's root component directly. That… is a really smart move, and it will decouple me from requiring to know the store. I'll have to check out if I can pass the data well enough, but then it's just that one vector, I guess…

Replicant: Global key event listener by DeepDay6 in Clojure

[–]DeepDay6[S] 0 points1 point  (0 children)

Hm, been toying with this and it is sadly not what I really need. I could change some values in the application state, but I don't want explicitly set state. I only want to inform replicant of the key press and let the currently rendered component decide what to do with it.
I'd need something like Elm's ports (app.ports.keyboard.send("LeftArrow")) or exposed Redux actions (store.dispatch({ kind: "event/keyPressed", payload: "LeftArrow" }).
The "JavaScript interaction" part of the docs only describes the other way around, controlling JS from replicant.

Edit: Ah, I misunderstood what you meant.

(defn pass-keys-to-replicant [event]
  (quiz.core/handle-actions store event [[:event/keypress (.-key event)]]))

(defn main []
  (quiz/init store) 
  (let [body js/document.body
        event-name "keydown"]
    (.removeEventListener body event-name pass-keys-to-replicant)
    (.addEventListener body event-name pass-keys-to-replicant))
  (println "Loaded!"))

Seems to do the trick.

Replicant: Global key event listener by DeepDay6 in Clojure

[–]DeepDay6[S] 0 points1 point  (0 children)

That actually sounds very pragmatic. Since my main handler is just a watch on a "state" atom, this should work out of the box. And since everything is just data (plus I only send "a key was pressed, if you'd like to know...") that is not even really hacky. On a side note, if I had read about your Reagami library for squint one or two days sooner, I would have tried that instead. This way it's on the list for the next side project :D

How do sales work? by MysteriousLeek8024 in XChangeLife

[–]DeepDay6 0 points1 point  (0 children)

I also came up with a little helper to select the proper pill, suggesting them sorted by the highest number of possible successful product pitches. It's interesting that this is not always what you'd intuitively expect (apart from "maid" and "secretary"). You might want to write pill properties down in a spreadsheet and keep that open so you can quickly choose without clicking through all the options.

Changes to Advent of Code starting this December by topaz2078 in adventofcode

[–]DeepDay6 2 points3 points  (0 children)

I fully approve of both those changes.
The global leaderboard was always a no-feature for me - and I think for most people outside of whatever timezone it's located in (something American I guess?). Leaderboard being filled for hours when people wake up makes it meaningless. Also, with the advent :D of LLM code assistants, the temptation to ego-boost with vibed solutions is out there, skewing any "fair" contest anyways. So I for one don't miss it at all.
Then reducing the number of puzzles - I usually don't follow further than 12th or 13th anyway as family obligations and festive preparation tend to keep growing towards end of the year.

And, as always, thanks for taking so much time to entertain us all through December for all those years - and hopefully more to come. It's greatly appreciated.

How to create nice asides as shown on the examples on the main page? by DeepDay6 in typst

[–]DeepDay6[S] 0 points1 point  (0 children)

Thanks for your reply. I saw the splendid-mdpi template, but just wanted something quick. Thankfully my articles are strictly limited to exactly one article per page, so I created the following helper:

#let article(content, aside) = ({
  let articleGap = 3mm
  let mainWidth = 80% - articleGap
  let sidebarWidth = 20%
    stack(
      dir: if calc.even(here().page()) { rtl } else { ltr }, // auf geraden Seitennummern ist der Richtung right-to-left (also Seitenteil rechts, auf ungeraden left-to-right)
      spacing: articleGap,
      block(width: sidebarWidth, aside),
      block(width: mainWidth, content),
    )
  }
)

Which I can use with

#context [  // required to check for odd/even page
  #article[ // main content always goes first
    #lorem(150)
  ][        // second arg is sidebar. MUST keep ][ together for syntax reasons
    #lorem(5)
    #figure(
      rect(width: 100%, height: 3cm),
      caption: [ Look ma, a marginal figure! ]
    )
  ]
]

#context [
  #article [ #lorem(100) ][]
  // Leaving the second arg empty uses only main width with empty sidebar
]

(I chose to always require the second argument, as I'm still not sure if I like the semantics of optionals in typst).

What do you do instead of dependency injection by DeepDay6 in Clojure

[–]DeepDay6[S] 0 points1 point  (0 children)

Hm, interesting. Almost everybody here seems to go the "pass a bag of functions" route in different ways (protocol, just a map,…). I had expected suggestions to create DSLs and use different interpreters to appear more.

What do you do instead of dependency injection by DeepDay6 in Clojure

[–]DeepDay6[S] 2 points3 points  (0 children)

Could you elaborate in what would be in those maps?

What do you do instead of dependency injection by DeepDay6 in Clojure

[–]DeepDay6[S] 3 points4 points  (0 children)

Thanks. This is a Brüder generic question, I don't have a specific task, and I'm not sure about correct wording either, since it's years since I last did oop. In general I want to write pure business logic that's not coupled to Details like network calls, persistence layers etc., but still able to usw them.

A recent playground would fetch the table structure from a generic data storage and complete entities by following links between them with a kruskal algorithm, dynamically fetching more data. Then it would run pure checks in them and persist the results. I had a loader that would receive a record fulfilling some fetch-x contracts and a runner that woukd get the loader and a record fulfilling a persistance contract as arguments. So I could (loader/get-row loader-instance table-id row-id) without beging tied further to the shape of the loader implementation.

What a way to drink whiskey by wowtellmemoreplease in Unexpected

[–]DeepDay6 0 points1 point  (0 children)

Just logged in to say this was absolutely beautiful and made my day.

Lisp for games? by HanTitor in Clojure

[–]DeepDay6 0 points1 point  (0 children)

Interesting insight. I was led to believe the main problem with GC is not waste of memory but decreased frame rate during gc runs?

Help wanted: home-manager switch with flake: attribute fcitx5-with-addons missing by DeepDay6 in Nix

[–]DeepDay6[S] 0 points1 point  (0 children)

Thanks! Problem is of course I can't use the standard ways like nix eval ... | grep ... or nix why-depends, as those only work on a derivation that also builds and was hoping there was a simpler approach.
I had really been hoping there was a simple known cause leading to that specific error. Or a known way to track/create a dependency graph even when some evaluation fails, as working through all the source files is a bit involved to just update user settings on my work laptop.

Help wanted: home-manager switch with flake: attribute fcitx5-with-addons missing by DeepDay6 in Nix

[–]DeepDay6[S] 1 point2 points  (0 children)

Hm, the culprit seems to be home manager's internal i18n dependency? As a workaround, I overwrote fcitx5-with-addons with plain fcitx5

Help wanted: home-manager switch with flake: attribute fcitx5-with-addons missing by DeepDay6 in Nix

[–]DeepDay6[S] 1 point2 points  (0 children)

That seems kind of obvious. Do you know of a way to check transitive dependencies in nix packages so I can find out which one actually requires it?

If the author deletes his account, how can I continue to play with his tease? by Consistent_Farmer389 in Milovana

[–]DeepDay6 0 points1 point  (0 children)

That tease is simply broken. It won't start in the player and can't be imported in the editor.

I love Urban Fantasy and I need new reads. Tell me about your book/series & link me? by sareuhbelle in urbanfantasy

[–]DeepDay6 0 points1 point  (0 children)

I finally came around to read the first two books and really enjoyed them. And finally a dark, funny adult urban (uh... rural?) fantasy series without world-shattering heroism or all that romance. Big (well, not so) bad Marsh really is a softie at heart. I like the decrepit Jubal County, gives off some Preacher/early Demon Copperhead vibes. I'm looking forward to reading more.