Skip to content

Instantly share code, notes, and snippets.

(ns switch
(:require [clojure.pprint :as pprint]))
(defn project-clj-map [filename]
(->> (slurp filename)
(read-string)
(drop 1)
(partition 2)
(map vec)
(into {})))
@borkdude
borkdude / specfn.clj
Last active January 7, 2022 13:34
Use a spec for defining function arguments and get validation automatically
(ns specfn.core
(:require [clojure.spec :as s]
[clojure.spec.test :as t]))
(defn- spec-symbols [s]
(->> s
(drop 1)
(partition-all 2)
(map first)
(map name)
@vvvvalvalval
vvvvalvalval / mock-connection.clj
Last active September 19, 2018 06:09
Mocking datomic.Connection for fast in-memory testing
(ns bs.utils.mock-connection
"Utilities for using Datomic"
(:require [datomic.api :as d])
(:use clojure.repl clojure.pprint)
(:import (java.util.concurrent BlockingQueue LinkedBlockingDeque)
(datomic Connection)))
(defrecord MockConnection
[dbAtom, ^BlockingQueue txQueue]
@rauhs
rauhs / Makefile
Last active July 7, 2020 19:44
Compiling clojurescript + figwheel without boot nor leiningen. Using leiningen to manage dependencies. Print file size stats (raw, gzip, brotli) for production builds
CLJ_NREPL_PORT:=22340
FIGWHEEL_PORT:=22345
CLJS_JAR_VERSION:=1.7.48
CLJS_JAR_URL:=https://github.com/clojure/clojurescript/releases/download/r$(CLJS_JAR_VERSION)/cljs.jar
.PHONY: def_target
def_target : null
(defrecord Server [service-map]
component/Lifecycle
(start [component]
(info :msg "Starting server.")
(let [server (bootstrap/create-server (:service-map service-map))]
(bootstrap/start server)
(assoc component :server server)))
(stop [component]
(info :msg "Stopping server.")
(update-in component [:server] bootstrap/stop)))
@jbruni
jbruni / app-code-structure.md
Created May 24, 2014 19:59
About large app code structure

When I decided to move on with RequireJS + AngularJS, it was September 2013, and at that time my Google search brought many results claiming it could be not a good idea. So, I was a bit uncertain about the decision. Each day it passes since that time I am more and more pleased with the results. After refactorings and tweakings, I am very satisfied, even proud, of the resulting scheme.

My front-end code base has a bower.json specifying its third-parties dependencies - RequireJs, AngularJS, jQuery, Twitter Bootstrap (I use only the CSS from it, since I use Angular UI Bootstrap directives for the components), ZeroClipboard, every "vendor" library is specified at this very simple bower.json file.

My app code is divided into front-end "apps" and "modules"... there are two main "front-end apps" - one for logged-in subscribers, and other for logged-in administrators. Each "app" has its "modules" - in fact, view + controllers + assets. It may be hard to describe, but when you see the folder structure you do not eve