Skip to content

Instantly share code, notes, and snippets.

; @tony.kay Good talking yesterday — and you’ve turned me into a believer on UI State Machines.
; You had suggested that instead of replacing each state, one by one, to just copy the entirety into my
; namespace, to make it easier.
;
; Got all the needed changes to lazily load all the Trello card comments very quickly. Eventually, I’ll post the diffs vs. the default RAD report state machine, which will make it more obvious what my changes were. But, just in case, to anyone who might find it helpful, here’s what I did.
;
; change any :: to ::report
; wrote a my-load-report! my-goto-page* and a load-comments-for-page
;
; Surprisingly straightforward to do, as @holyjak and @tony.kay predicted!
@realgenekim
realgenekim / README.md
Last active July 21, 2023 14:29
How to download all Clojure dependencies using clj (equivalent to "lein deps")

I recently had to figure out for a Clojure application how to download all dependency JAR files, for use in a Docker container.

When creating an uberjar, depstar re-downloaded all the external dependencies from Maven central, even though in an earlier Docker build step, I ran clj -Spath to pre-download them (presumably cached into the .m2 directory). In the past, I've used lein deps to do something similiar.

I'm grateful for Sean Corfield helping out (again!!): In short, use clj -P (short for "prepare") to download dependencies. Note the "A:depstar" option, which ensures that the depstar dependencies are downloaded, too.

Here's what it looks like in a Dockerfile:

# to pre-download dependencies, only done if deps.edn changes
@realgenekim
realgenekim / db.clj
Last active February 16, 2021 17:58
Example of getting UTF-8 working with next.jdbc with MySQL, to enable Unicode and emojis, along with using using "REPLACE" instead of "INSERT" to enable upserts.
(ns db.db2
(:require
[next.jdbc :as j]
[next.jdbc.sql :as jsql]
[next.jdbc.sql.builder :as jb]
[clojure.spec.alpha :as s]))
(def mysql-db {:dbtype "mysql"
:dbname "twitter"
:host "127.0.0.1"
@realgenekim
realgenekim / README-vega-arc-diagram.md
Last active November 9, 2023 12:21
Here's a basic skeleton of how to create a Vega arc diagram

Vega-lite is awesome and graphs are easy to create.

Vega is... wow... you've got to write a lot more JSON to generate a graph.

Here is a skeleton Vega Arc diagram that you can use to create your own -- I couldn't find one on the internet, and it took me nearly six hours to figure out how to create one.

Enjoy! Gene

(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
(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]
@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))
@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"]
-- 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