Skip to content

Instantly share code, notes, and snippets.

View carocad's full-sized avatar

Camilo Roca carocad

  • Frankfurt am Main, Germany
View GitHub Profile
@ericnormand
ericnormand / 00_script.clj
Last active January 6, 2024 07:13
Boilerplate for running Clojure as a shebang script
#!/bin/sh
#_(
#_DEPS is same format as deps.edn. Multiline is okay.
DEPS='
{:deps {clj-time {:mvn/version "0.14.2"}}}
'
#_You can put other options here
OPTS='
@rauhs
rauhs / humanize-schema-errors.clj
Last active May 27, 2023 05:29
Translate prismatic's schema.core errors to a human readable form. Use this for presenting validation errors to users. Don't use this for programming errors like a missing map key etc.
(ns x.y
(:use [plumbing.core]) ;; Just for the map-vals
(:require [clojure.walk :refer [postwalk prewalk prewalk-demo postwalk-demo]]
[clojure.core.match :refer [match]]
[schema.utils :refer [named-error-explain validation-error-explain]]
[schema.core :as s])
(:import (schema.utils NamedError ValidationError)))
;; Partially FROM:
;; https://github.com/puppetlabs/clj-schema-tools
@kidpollo
kidpollo / app-server.clj
Created March 29, 2014 06:37
Example compojure app using stuartsierra/component
(ns app.api-server
(:require [compojure.core :as compojure]
[com.stuartsierra.component :as component]
[app.app :as app]
[ring.adapter.jetty :as jetty]))
(compojure/defroutes app
app/handler)
(defrecord AppServer [port server]
@vishnuvyas
vishnuvyas / levenshtein.clj
Created May 6, 2011 05:29
A purely functional implementation of levenshtein distance in clojure
(ns levenshtein
^{:doc "A purely functional implementation of the levenshtien distance in clojure"})
(defn- compute-next-row
"computes the next row using the prev-row current-element and the other seq"
[prev-row current-element other-seq pred]
(reduce
(fn [row [diagonal above other-element]]
(let [update-val
(if (pred other-element current-element)