about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorelioat <hi@eli.li>2023-07-13 09:19:47 -0400
committerelioat <hi@eli.li>2023-07-13 09:19:47 -0400
commite8af8b886ac22084d0ff0f53dde392a3c40cd6a6 (patch)
treee331f9a750331e0ba059ea1e6723fda92af9470e
parent8fa9ccfb54e2ac8c86fae53c0e6395fa72fdc330 (diff)
downloadtour-e8af8b886ac22084d0ff0f53dde392a3c40cd6a6.tar.gz
*
-rw-r--r--janet/fedi-playground/play.janet119
-rw-r--r--janet/fedi-playground/project.janet12
-rw-r--r--janet/fedi-playground/src/followers.json (renamed from janet/fedi-playground/followers.json)0
-rw-r--r--janet/fedi-playground/src/play.janet36
-rw-r--r--janet/fedi-playground/test/data-shapes.janet86
5 files changed, 133 insertions, 120 deletions
diff --git a/janet/fedi-playground/play.janet b/janet/fedi-playground/play.janet
deleted file mode 100644
index d9699b0..0000000
--- a/janet/fedi-playground/play.janet
+++ /dev/null
@@ -1,119 +0,0 @@
-# a utility script used to explore my fediverse followers
-(import spork/json) 
-(use judge)
-
-(defn read-from-file [file-path]
-  "read data from a file, not super safe or fault tolerant."
-  (let [f (file/open file-path :r)
-        content (file/read f :all)]
-    (file/close f)
-    content))
-
-(def json-data
-  (read-from-file "followers.json")) # this is just a small sample export, will have to use curl to get the full list beyond the first 80
-
-(def all-followers
-  (json/decode json-data))
-
-# this seems horribly inefficient
-# TODO: is there a clever way to deal with this?
-# maybe a filter?
-# (filter (fn [x] (> x 2)) [1 2 3 4 5])  # @[3 4 5]
-# or maybe keep?
-# https://janetdocs.com/keep
-(defn select-by-key [key arr]
-  "select a value by matched key."
-  (def a @[])
-  (each follower arr
-    (loop [[k v] :pairs follower]
-      (if (= k key)
-        (array/push a v))))
-  a)
-
-(def follower-accounts
-  (select-by-key "acct" all-followers))
-
-(def follower-usernames
-  (select-by-key "username" all-followers))
-
-(test (select-by-key "acct" all-followers)
-  @["brendan@merveilles.town"
-    "balrogboogie@mastodon.art"
-    "mstange@mastodon.social"
-    "mario_afk@merveilles.town"
-    "hanbruder@ecoevo.social"
-    "angelo@social.droppedbits.com"
-    "akkartik@lethallava.land"
-    "kategenevieve@assemblag.es"
-    "kidskylark"
-    "saltimbanque@mamot.fr"
-    "dcreager@dcreager.net"
-    "computersandblues@post.lurk.org"
-    "tamberg@quite.social"
-    "hs0ucy@jasette.facil.services"
-    "prahou@merveilles.town"
-    "nix@merveilles.town"
-    "cidney@social.city-of-glass.net"
-    "alyssa@cloudisland.nz"
-    "hastur@hackers.town"
-    "cian@post.lurk.org"
-    "ben@a11y.info"
-    "jeremy@boles.social"
-    "pkra@bonn.social"
-    "typeable@mastodon.social"
-    "nocko@kolektiva.social"
-    "ioezg@emacs.ch"
-    "jleightcap@treehouse.systems"
-    "arcade@catcatnya.com"
-    "illegaldaydream@kolektiva.social"
-    "maro@merveilles.town"
-    "halfflat@calckey.social"
-    "julienxx@nein.club"
-    "required@zero.parts"
-    "lior@mastodon.social"
-    "Amirography@fosstodon.org"
-    "decentral1se@varia.zone"
-    "mirth@mastodon.sdf.org"
-    "tbsp@merveilles.town"
-    "plexus@toot.cat"
-    "cblgh@merveilles.town"
-    "spiralganglion@mastodon.social"
-    "booters@kolektiva.social"
-    "thegr8whoopdini@bookwyrm.social"
-    "pixx@merveilles.town"
-    "angelo@social.lol"
-    "HarneyB@decept.org"
-    "woozong@post.lurk.org"
-    "sieve@hachyderm.io"
-    "amszmidt@mastodon.social"
-    "karlinfox@mastodon.cloud"
-    "resoluxe@mastodon.art"
-    "idlestate@toot.cat"
-    "fmflake@mastodon.social"
-    "raychill@aus.social"
-    "selmakovich@eldritch.cafe"
-    "bartgo@fosstodon.org"
-    "GoodClover@en.osm.town"
-    "levibeach@merveilles.town"
-    "celebrion@mastodon.online"
-    "benji@fosstodon.org"
-    "nilmethod@pleroma.destroyallmachines.net"
-    "nikken@post.lurk.org"
-    "lobo@merveilles.town"
-    "ophiuchoid@indieweb.social"
-    "mu@merveilles.town"
-    "kieranmcguire@mastodon.online"
-    "yagaruma@mastodon.social"
-    "dook@post.lurk.org"
-    "wilfredh@mastodon.social"
-    "Jetengineweasel@hackers.town"
-    "DrTCombs@transportation.social"
-    "jy4m@matapacos.dog"
-    "ivmirx@mas.to"
-    "vanja@tech.lgbt"
-    "abuseofnotation@mathstodon.xyz"
-    "jes5199@mastodon.social"
-    "ouro@social.snircle.space"
-    "typeswitch@gamedev.lgbt"
-    "Ronkjeffries@mastodon.social"
-    "bogmon@mstdn.social"])
diff --git a/janet/fedi-playground/project.janet b/janet/fedi-playground/project.janet
index a8629ce..a3425e3 100644
--- a/janet/fedi-playground/project.janet
+++ b/janet/fedi-playground/project.janet
@@ -1,6 +1,16 @@
 (declare-project
+  :name "fedi-playground"
+  :description "a place to play with json data from the fediverse."
   :dependencies [
     {:url "https://github.com/ianthehenry/judge.git"
      :tag "v2.6.1"}
     {:url "https://github.com/janet-lang/spork.git"}
-  ])
\ No newline at end of file
+  ])
+
+(declare-source
+  # :source is an array or tuple that can contain
+  # source files and directories that will be installed.
+  # Often will just be a single file or single directory.
+  :source ["/src/play.janet"])
+
+# (task "test" [] (shell "jpm_tree/bin/judge"))
\ No newline at end of file
diff --git a/janet/fedi-playground/followers.json b/janet/fedi-playground/src/followers.json
index 51bf6e8..51bf6e8 100644
--- a/janet/fedi-playground/followers.json
+++ b/janet/fedi-playground/src/followers.json
diff --git a/janet/fedi-playground/src/play.janet b/janet/fedi-playground/src/play.janet
new file mode 100644
index 0000000..4dd9c75
--- /dev/null
+++ b/janet/fedi-playground/src/play.janet
@@ -0,0 +1,36 @@
+# a utility script used to explore my fediverse followers
+(use spork)
+
+(defn read-from-file [file-path]
+  "read data from a file, not super safe or fault tolerant."
+  (let [f (file/open file-path :r)
+        content (file/read f :all)]
+    (file/close f)
+    content))
+
+(def json-data
+  (read-from-file "followers.json")) # this is just a small sample export, will have to use curl to get the full list beyond the first 80
+
+(def all-followers
+  (json/decode json-data))
+
+# this seems horribly inefficient
+# TODO: is there a clever way to deal with this?
+# maybe a filter?
+# (filter (fn [x] (> x 2)) [1 2 3 4 5])  # @[3 4 5]
+# or maybe keep?
+# https://janetdocs.com/keep
+(defn select-by-key [key arr]
+  "select a value by matched key."
+  (def a @[])
+  (each follower arr
+    (loop [[k v] :pairs follower]
+      (if (= k key)
+        (array/push a v))))
+  a)
+
+(def follower-accounts
+  (select-by-key "acct" all-followers))
+
+(def follower-usernames
+  (select-by-key "username" all-followers))
\ No newline at end of file
diff --git a/janet/fedi-playground/test/data-shapes.janet b/janet/fedi-playground/test/data-shapes.janet
new file mode 100644
index 0000000..7586039
--- /dev/null
+++ b/janet/fedi-playground/test/data-shapes.janet
@@ -0,0 +1,86 @@
+(use judge)
+(use /src/play)
+
+(assert (= (+ 2 2) 3))
+
+# (test (select-by-key "acct" all-followers)
+#   @["brendan@merveilles.town"
+#     "balrogboogie@mastodon.art"
+#     "mstange@mastodon.social"
+#     "mario_afk@merveilles.town"
+#     "hanbruder@ecoevo.social"
+#     "angelo@social.droppedbits.com"
+#     "akkartik@lethallava.land"
+#     "kategenevieve@assemblag.es"
+#     "kidskylark"
+#     "saltimbanque@mamot.fr"
+#     "dcreager@dcreager.net"
+#     "computersandblues@post.lurk.org"
+#     "tamberg@quite.social"
+#     "hs0ucy@jasette.facil.services"
+#     "prahou@merveilles.town"
+#     "nix@merveilles.town"
+#     "cidney@social.city-of-glass.net"
+#     "alyssa@cloudisland.nz"
+#     "hastur@hackers.town"
+#     "cian@post.lurk.org"
+#     "ben@a11y.info"
+#     "jeremy@boles.social"
+#     "pkra@bonn.social"
+#     "typeable@mastodon.social"
+#     "nocko@kolektiva.social"
+#     "ioezg@emacs.ch"
+#     "jleightcap@treehouse.systems"
+#     "arcade@catcatnya.com"
+#     "illegaldaydream@kolektiva.social"
+#     "maro@merveilles.town"
+#     "halfflat@calckey.social"
+#     "julienxx@nein.club"
+#     "required@zero.parts"
+#     "lior@mastodon.social"
+#     "Amirography@fosstodon.org"
+#     "decentral1se@varia.zone"
+#     "mirth@mastodon.sdf.org"
+#     "tbsp@merveilles.town"
+#     "plexus@toot.cat"
+#     "cblgh@merveilles.town"
+#     "spiralganglion@mastodon.social"
+#     "booters@kolektiva.social"
+#     "thegr8whoopdini@bookwyrm.social"
+#     "pixx@merveilles.town"
+#     "angelo@social.lol"
+#     "HarneyB@decept.org"
+#     "woozong@post.lurk.org"
+#     "sieve@hachyderm.io"
+#     "amszmidt@mastodon.social"
+#     "karlinfox@mastodon.cloud"
+#     "resoluxe@mastodon.art"
+#     "idlestate@toot.cat"
+#     "fmflake@mastodon.social"
+#     "raychill@aus.social"
+#     "selmakovich@eldritch.cafe"
+#     "bartgo@fosstodon.org"
+#     "GoodClover@en.osm.town"
+#     "levibeach@merveilles.town"
+#     "celebrion@mastodon.online"
+#     "benji@fosstodon.org"
+#     "nilmethod@pleroma.destroyallmachines.net"
+#     "nikken@post.lurk.org"
+#     "lobo@merveilles.town"
+#     "ophiuchoid@indieweb.social"
+#     "mu@merveilles.town"
+#     "kieranmcguire@mastodon.online"
+#     "yagaruma@mastodon.social"
+#     "dook@post.lurk.org"
+#     "wilfredh@mastodon.social"
+#     "Jetengineweasel@hackers.town"
+#     "DrTCombs@transportation.social"
+#     "jy4m@matapacos.dog"
+#     "ivmirx@mas.to"
+#     "vanja@tech.lgbt"
+#     "abuseofnotation@mathstodon.xyz"
+#     "jes5199@mastodon.social"
+#     "ouro@social.snircle.space"
+#     "typeswitch@gamedev.lgbt"
+#     "Ronkjeffries@mastodon.social"
+#     "bogmon@mstdn.social"])
\ No newline at end of file