Skip to content

Instantly share code, notes, and snippets.

@saikyun
saikyun / why-freja.md
Last active September 13, 2021 08:33

FAQ for Freja

Why Freja?

Freja is a code, pixel and music editor. It is also a GUI library, which means you can create native graphical applications.

Compared to a browser, you get:

  • Easy interop with C
  • Easier access to the underlying system, including:
  • File system
(def chan (ev/thread-chan))
(defn run-process
[args]
(ev/spawn-thread
(def p (os/spawn args :p {:in :pipe :out :pipe}))
(ev/give chan (:read (p :out) :all))
(:wait p)))
(run-process ["ls"])
@saikyun
saikyun / eoau
Created September 13, 2021 10:00
(use freja-jaylib)
(import freja/frp)
(import freja/state)
(comment
(do
(var cp 0)
(frp/subscribe! (get-in state/editor-state [:left-state :editor])
(fn [state]
(import freja/new_gap_buffer :as gb)
(import freja/state)
# will contain the parsers for each line
(def cache @[])
(def gap-buffer (get-in state/editor-state [:left-state :editor :gb]))
(var buf "")
(+ 1 (* 2 3 4
#
))
(import freja/new_gap_buffer :as gb)
(import freja/state)
# will contain the parsers for each line
(def cache @[])
(def code
``
(+ 1 2
(+ 3 4))
``)
(def token-peg
~{:tuple-start (/ (* ($) "(" ($)) ,(fn [start stop] [:tuple-start "(" start stop]))
:tuple-stop (/ (* ($) ")" ($)) ,(fn [start stop] [:tuple-stop ")" start stop]))
:symbol (/ (* ($) '(some (if-not :d (if-not :s 1))) ($))
(defn import-c*
[module-name src]
(def so-name (string module-name "-" (hash src) ".so"))
(unless (os/stat so-name)
(spit (string module-name ".c") src)
(os/execute ["cc"
"-I" "/usr/local/include/janet"
"-shared"
# doesn't work
(setdyn :dynamic-defs true)
(defn main
[& args]
(print "hello"))
# doesn't work
(setdyn :dynamic-defs true)
@saikyun
saikyun / steps.md
Created February 19, 2022 11:48
running jpm build from powershell
  1. install needed stuff
  2. in powershell:
notepad $PROFILE

Copy paste the below, change the path to match your own vcvars64.bat location:

function jpm-build {
 & cmd /c '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" & jpm build'
@saikyun
saikyun / angles.janet
Created April 7, 2022 07:45
Sector overlap / collision in freja with visualization.
(use freja/flow)
(defn tau->deg
[t]
(math/round (* 180 t)))
(defn rad->tau
[r]
(/ r math/pi))