Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

How to make a pedestal + ss component w/ lein

this loosely follows pedestal component tutorial

http://pedestal.io/guides/pedestal-with-component

create base project

lein new pedestal-service tnbsst

add ss component to project.clj

all pedestal deps already scaffoled, using jetty for this demo

$ time echo '{:foo :bar}' |./bin/clack :foo
:bar
echo '{:foo :bar}' 0.00s user 0.00s system 0% cpu 0.002 total
./bin/clack :foo 2.54s user 0.19s system 104% cpu 2.619 total
@hhutch
hhutch / fib.clj
Last active September 15, 2015 22:13 — forked from nasser/fib.clj
Fibonacci sequence in Clojure/LLVM
;; https://pauladamsmith.com/blog/2015/01/how-to-get-started-with-llvm-c-api.html
(import LLVM
LLVMModuleRef
LLVMTypeRef
Wrap
LLVMBool
LLVMLinkage)
(def genstr (comp str gensym))
@hhutch
hhutch / gist:ea2496e23add73deb12e
Created August 6, 2015 13:27
great cross-language explanation of a tuple
bhuga_is_too_long_to_ [8:26 PM]
there is no limit to the number of things in a tuple. they are indeed the same as an array
bhuga_is_too_long_to_ [8:27 PM]
tuple is just a word that expresses that the array is expected to have a given length (2-tuple, 3-tuple, 4-tuple, etc), and that each element of the array is of an expected type in an expected location
bhuga_is_too_long_to_ [8:27 PM]
you can make a tuple type out of this concept, wrapping the array. nothing wrong with that either
bhuga_is_too_long_to_ [8:28 PM]
;; Datomic sample code
;; schema query for attribute types in specified namespaces
(q '[:find ?attr
:in $ [?include-ns ...] ;; bind ?include-ns once for each item in collection
:where
[?e :db/valueType] ;; all schema types (must have a valueType)
[?e :db/ident ?attr] ;; schema type name
[(datomic.Util/namespace ?attr) ?ns] ;; namespace of name
[(= ?ns ?include-ns)]] ;; must match one of the ?include-ns
(ns maze.core)
(def *size* 20)
(defn walk [start]
(iterate (fn [[x y]]
(first (shuffle (filter (fn [lst]
(every? (fn [k]
(< -1 k *size*))
lst))
@hhutch
hhutch / maze.clj
Last active August 29, 2015 14:22 — forked from cgrand/maze.clj
; http://groups.google.com/group/clojure/browse_thread/thread/974e2c7f89e27231/5f4bff3e58dfa36f
; output images http://i.imgur.com/gSASS.png (square maze)
; http://i.imgur.com/uEqaq.png (hex maze)
;; generic Wilson's algorithm implementation
(defn maze
"Returns a random maze carved out of walls; walls is a set of
2-item sets #{a b} where a and b are locations.
The returned maze is a set of the remaining walls."
[walls]
ÿØÿàJFIFHHÿÛC

   ÿÛC   ÿÂ@kÿÄÿÄÿÚ þ© À š8Í