(defprofile lagénorhynque
:id @lagenorhynque
:reading "/laʒenɔʁɛ̃k/"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns lousy-calculator | |
(:require [clojure.spec.alpha :as s])) | |
(s/def ::number-with-remark (s/tuple number? string?)) | |
(s/fdef add | |
:args (s/cat :x number? | |
:y number?) | |
:ret ::number-with-remark) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns generic-size) | |
(defprotocol Size | |
(size' [data] "Calculates the size (and not the length!) of a data structure")) | |
(extend-protocol Size | |
String | |
(size' [s] (count s)) | |
clojure.lang.IPersistentMap | |
(size' [m] (count m)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns worker) | |
(defn random [] | |
(inc (rand-int 100))) | |
(defn sleep [n] | |
(println (str "sleep(" n ") started.")) | |
(Thread/sleep n) | |
(println (str "sleep(" n ") ended.")) | |
(str "result-sleep(" n ")")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<configuration scan="true" scanPeriod="1 seconds"> | |
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |
<encoder> | |
<pattern>%d{yyyyMMdd HH:mm:ss} %-5level %logger - %msg%n</pattern> | |
</encoder> | |
</appender> | |
<root level="DEBUG"> | |
<appender-ref ref="STDOUT"/> | |
</root> |
(defprofile lagénorhynque
:id @lagenorhynque
:reading "/laʒenɔʁɛ̃k/"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user> (require '[clojure.spec.alpha :as s] | |
'[clojure.spec.test.alpha :as stest]) | |
nil | |
user> (s/def :contact/name string?) | |
:contact/name | |
user> (s/def :contact-info/type keyword?) | |
:contact-info/type | |
user> (s/def :contact-info/email-contact-info string?) | |
:contact-info/email-contact-info | |
user> (s/def :contact-info/postal-contact-info string?) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dev> (let [count (volatile! 0) | |
t1 (Thread. #(dotimes [_ 1000] (vswap! count inc))) | |
t2 (Thread. #(dotimes [_ 1000] (vswap! count inc)))] | |
(.start t1) | |
(.start t2) | |
(.join t1) | |
(.join t2) | |
@count) | |
1577 | |
dev> (let [count (atom 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE NamedFieldPuns #-} | |
module Model where | |
data User = User { firstName :: !String | |
, lastName :: !String | |
} | |
deriving Show | |
fullName :: User -> String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dev> (q #:venia{:operation #:operation{:type :query | |
:name "MemberById"} | |
:variables [#:variable{:type :ID! | |
:name "id"}] | |
:queries [[:member_by_id {:id :$id} | |
[:member_name | |
[:ratings [[:game [:name | |
[:rating_summary [:count | |
:average]] | |
[:designers [:name |