Skip to content

Instantly share code, notes, and snippets.

@realgenekim
realgenekim / compact-report-control.cljc
Last active January 14, 2023 20:43
Custom compact report layout that puts pagination control into the first row, between the report title and control buttons
View compact-report-control.cljc
(ns com.example.ui.custom-report-control
(:require
#?@(:cljs
[[com.fulcrologic.fulcro.dom :as dom :refer [div]]
[com.fulcrologic.semantic-ui.addons.pagination.ui-pagination :as sui-pagination]]
:clj
[[com.fulcrologic.fulcro.dom-server :as dom :refer [div]]])
[clojure.string :as str]
[com.fulcrologic.fulcro.components :as comp]
[com.fulcrologic.fulcro-i18n.i18n :refer [tr trc]]
@realgenekim
realgenekim / does-titles.titles.clj
Last active October 6, 2022 03:09
These are selected portions of the code to do the analysis presented here: Analysis Of DevOps Enterprise Summit Speaker Titles (2014-2022): http://itrevolution.com/speaker-titles
View does-titles.titles.clj
; I'll post entire repo of how to use this analysis code, but I wanted to get something
; up right away
;
(ns does-titles.titles
(:require
[better-cond.core :as b]
[clojure.string :as str]
[clojure.test :refer :all]
[com.fulcrologic.guardrails.core :refer [>defn >defn- >def | ? =>]]))
View incrementally-loaded-report-gk.cljc
(ns com.example.state-machines.incrementally-loaded-report-gk
;(ns com.fulcrologic.rad.state-machines.incrementally-loaded-report
"Gene modifications to incrementally-loaded-report --
This has the same interface as the 'incrementally-loaded-report' UISM included in RAD.
https://github.com/fulcrologic/fulcro-rad/blob/develop/src/main/com/fulcrologic/rad/state_machines/incrementally_loaded_report.cljc
However, instead of rendering only after the resolver resturns the entire data set,
it renders immediately after the first load completes, and use df/load! to asynchronously load
View fulcro-rad-custom-state-machine.cljc
; @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")
View README.md

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.
View db.clj
(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 December 30, 2022 12:13
Here's a basic skeleton of how to create a Vega arc diagram
View README-vega-arc-diagram.md

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

View trello_interfaces.cljs
(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
View oz-demos.clj
(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
View firebase.clj
(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))