Skip to content

Instantly share code, notes, and snippets.

; I mostly use Clojure running on the JVM, and ClojureScript that compiles into
; JavaScript that runs in browser
;
; But there are two great ClojureScripts that feel more like scripting.
; - Lumo runs on top of Node.js and can therefore use npm libraries
; https://github.com/anmonteiro/lumo
; - Planck runs on JavaScriptCore which powers Safari (I think)
; https://github.com/planck-repl/planck
;
; I chose lumo because the first Google result "clojurescript parse json"
#!/bin/bash
#
# Posting this as an example of a bash script I never should have written:
#
# it runs inside of a CI pipeline, waits for a kubernetes job to complete, looping
# until kubectl reports the job finishing, either success or fail.
#
# The problem: parsing the output frm kubectl is something I've used in a bunch of scripts,
# including exec'ing a shell, killing a pod, listing pods...
-- Build this with "ghc ibid.hs"
-- Test it with "./ibid"
-- Import some list functions
import Data.List
-- Some refs to test on
refs = ["book1","book2","ibid","ibid","paper1","ibid","paper2","book3"]
-- Code close to what John wrote that will work in ghci
(def in ["a" "ibid" "ibid" "b"])
(defn ibid
([in]
(ibid (vec (first in)) (rest in))
([left right]
(println left right)
(if (empty? right)
; done
left
@realgenekim
realgenekim / project.clj
Created September 5, 2018 18:17
attempt to get multiple entry points running using figwheel.main
(defproject trello-workflow "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.9.0"]
[org.clojure/clojurescript "1.10.339"]
;[org.clojure/clojurescript "1.9.946"]
[org.clojure/core.async "LATEST"]
[org.clojure/test.check "0.10.0-alpha2"]
[reagent "0.7.0"]
[re-frame "0.10.5"]
[day8.re-frame/http-fx "0.1.6"]
[secretary "1.2.3"]
@realgenekim
realgenekim / ghostwheel-config.cljc
Last active October 9, 2018 23:52
My starting point for ghostwheel type checking
(ns bookserver.io
#:ghostwheel.core{:trace true
:check false
:num-tests 0
; oustrument to check types at run-time for all functions
; in this namespace
:outstrument true}
(:require [clojure.spec.alpha :as s]
[ghostwheel.core :as g
(ns analyze.oz
(:require [oz.core :as oz]
[clojure.data.json :as json]))
#_ (oz/start-plot-server!)
(defn group-data [& names]
(apply concat (for [n names]
(map-indexed (fn [i x]
(ns trello-workflow.trello-interfaces
(:require [re-frame.core :as re-frame]
[ajax.core :as ajax]
[trello-workflow.io :as io]
[goog.string :as gstring]
[goog.string.format]))
(defprotocol TrelloInterface
" interface to loading boards, lists, cards
{:command :load-board
@realgenekim
realgenekim / split-and-count.cljs
Last active June 9, 2020 15:06
Create sorted word frequencies for word clouds, using Lumo and ClojureScript
;; using lumo for ClojureScript: https://github.com/anmonteiro/lumo
;;
;; https://www.wordclouds.com/
;; - size: 1920x1080
;; - size is typically around -45
;; - shape: rectangle
;; - theme: black on white
;; - font: Ariel
;;
;; PS: Over the last 30 years, I've probably written this program over
@realgenekim
realgenekim / firebase.clj
Last active August 28, 2020 16:43
attempt to get Google Cloud Firestore working in Clojure
(ns firebase1.core
(:require [clojure.java.io :as io]
[clojure.core.async :as async]
[clojure.reflect :as r])
(:import (com.google.auth.oauth2 GoogleCredentials)
(com.google.firebase FirebaseOptions$Builder)
(com.google.firebase FirebaseApp)
(com.google.cloud.firestore.v1beta1 FirestoreClient))
(:gen-class))