Inspired by this blog covering a stable diffusion -> pixel art process:
I'm generating some concept art with #StableDiffusion for a leaf-catching runner game this morning via lexica.art:
https://lexica.art/prompt/f972bb05-409f-4c3f-9c0b-c94a8e1d3577
this is cray! At the very least, it's inspiration, layouts, and tree/leaf shapes to borrow from.
I normally go straight into a bb.edn or tasks.clj to write some clojure (b/c it's all about that repl ), but today I wanted to convert a bunch of `.webp`s from a quick stable diffusion session into .pngs.
Traditionally this is where the linux sys admin will
bust out some piping, probably something with
ls
,
awk
, and a few
other bits of whatever bash expects a computer user to
know.
Instead, I reached for babashka:
bb -e '(->> (babashka.fs/list-dir ".") (filter #(clojure.string/includes? (str %) ".webp")) (map (fn [f] (-> ^{:out :string} (babashka.process/$ convert ~(str f) ~(clojure.string/replace f ".webp" ".png")) babashka.process/check :out))))' # convert images in this dir with imagemagick
> Note the trailing comment above, it's one of my favorite tricks for making searching history easier (because you can then search for your comment, not just the command itself).
The clojure in there, broken out a bit better:
(->> ;; thread-last
(babashka.fs/list-dir ".") ;; ls
(filter #(clojure.string/includes? (str %) ".webp")) ;; only this extension (there's a bb.fs way to do this as well)
(map (fn [f] ;; for each file
(->
;; run a process - metadata to specify we want string output
^{:out :string}
(babashka.process/$ ;; this is a macro that lets your write like you're in a shell
;; here we use imagemagick's convert helper
convert ~(str f) ~(clojure.string/replace f ".webp" ".png"))
babashka.process/check ;; check awaits the process and throws if there's an error
:out)))) ;; we only care for the process's output here
This is probably common enough to write some sort of helper function or a wrapper. I also admit I couldn't have smashed this out on the command line without being intimate with clojure's threading macros, babashka.fs and babashka.process.
But... imagine a world... in which you are familiar with those things, because they can be used in any of clojure's targetted runtimes! Bada bow! Now your life is easier, and you didn't spend 30 minutes dealing with bash trivia! Hooray!
https://github.com/bitbrain/braingdx
java aka clojure game dev
and a great, quick tutorial for them: https://www.youtube.com/watch?v=f8z4x6R7OSM
basically we're writing ->hiccup for various api endpoints
https://mastodon.gamedev.place/api/v1/timelines/public when i found this i thought, am I about to accidentally ddos them?
I feel like i am probably stealing this from somewhere
{:if-it-was-so-easy "I'd write the whole blog in here"
:post [
"Org Source blocks aren't too bad."
"And I think i'd be able to interact with this in a browser."
"Could be keyboard controlled anyway."
"At which point, we might as well be in Emacs."]}
These would make for really nice difftastic views tho.
keep the patreon usage minimal, include all the same content on the blog post and just link to it.
then, at publish time, just wing it and keep it to some fixed 100 word limit.
in fact, if they could all be hundos, that'd be just grand
i'll do the interactions during the stream, and make it more of a read-along
then the edited versions can speed up the in-betweens
basically wrapping the tags page's component and passing in the items