Skip to content

Instantly share code, notes, and snippets.

@daveray
daveray / seesaw-repl-tutorial.clj
Created December 7, 2011 04:55
Seesaw REPL Tutorial
; A REPL-based, annotated Seesaw tutorial
; Please visit https://github.com/daveray/seesaw for more info
;
; This is a very basic intro to Seesaw, a Clojure UI toolkit. It covers
; Seesaw's basic features and philosophy, but only scratches the surface
; of what's available. It only assumes knowledge of Clojure. No Swing or
; Java experience is needed.
;
; This material was first presented in a talk at @CraftsmanGuild in
; Ann Arbor, MI.
@noprompt
noprompt / slurp.clj
Created February 19, 2014 04:52
How to use slurp from ClojureScript
(ns foo.core
(:refer-clojure :exclude [slurp]))
(defmacro slurp [file]
(clojure.core/slurp file))
;; In CLJS
(ns bar.core
(:require [foo.core :include-macros true :refer [slurp]]))
(ns com.x.aleph-test
(require [aleph.http :as http]
[manifold.deferred :as d]
[manifold.stream :as s]
[compojure.core :only [routes ANY GET PUT POST] :as compojure]
[compojure.handler :as handler]
[clj-http.client :as http-client]
))
(comment
@Deraen
Deraen / 00_notes.md
Last active October 1, 2019 08:40
Compojure-api and Buddy
  • (:identity req) is auth backend independent way to access user data
  • login and logout implementation depends on auth backend
  • :current-user doesn't imply that authentication is required, route should also have :auth-rules if authentication is required
@jkpl
jkpl / article.md
Last active March 21, 2023 21:18
HTML search and replace in Clojure

HTML search and replace in Clojure

In Clojure, data structures are mostly built from a handful of core data structures such as lists, vectors, maps, and sets. This means that most data structures can leverage all of the generic data transformation and querying functions built for the core data structures instead of having to rebuild the same functionality for each data structure. This feature in combination with Clojure's rich standard library makes Clojure very attractive for solving data munching problems from other domains.

In this article, I'm going to demonstrate these capabilities for solving HTML transformations using Clojure. First, I'm going to describe how HTML can be represented in Clojure. With this representation in mind, I'll demonstrate how we can transform HTML documents in Clojure. Finally, I'll tie the transformations together with the HTML parsing and formatting to produce a complete solution.

@vvvvalvalval
vvvvalvalval / keywordize_at_keys.clj
Last active May 18, 2023 18:17
Clojure : keywordize values at specific keys
(ns utils.keywordize-at-keys
(:require [clojure.walk :as walk]))
(defn- coerced-to-keyword
[k]
(when (string? k)
(keyword k)))
(defn keywordize-at-keys