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 bootcamp.factorial) | |
(defn fast-factorial [number] | |
(loop [n number factorial 1] | |
(if (zero? n) | |
factorial | |
(recur (- n 1) (* factorial n))))) | |
(defn fast-no-loop-factorial | |
([number] (fast-no-loop-factorial number 1)) |
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
worker_processes 1; | |
error_log logs/error.log; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
init_worker_by_lua_block { | |
redis = require("resty.redis") | |
} | |
server { |
separate namespace for routes:
(ns hubble.routes
(:require [reitit..]))
(defn make-routes [config]
[["/api/hubble" {:swagger {:tags ["ops"]}}
;; ....
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
public class Calculator { | |
public interface Operation { | |
public Long perform( Long a, Long b ); | |
} | |
// example of anonymous class(es) | |
public static Operation add = new Operation() { public Long perform( Long a, Long b ) { return a + b; } }; | |
public static Operation subtract = new Operation() { public Long perform( Long a, Long b ) { return a - b; } }; | |
public static Operation divide = new Operation() { public Long perform( Long a, Long b ) { return a / b; } }; |
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
import redis | |
r = redis.StrictRedis(host='localhost', port=6379, db=0) | |
r.zadd('votes:east', **{'riak': 1, 'couchdb': 1, 'cassandra': 1}) | |
r.zadd('votes:north', **{'redis': 1, 'onetick': 1, 'couchdb': 1}) | |
r.zadd('votes:west', **{'redis': 1, 'riak': 1, 'couchdb': 1}) | |
r.zadd('votes:south', **{'voltdb': 1, 'mongodb': 1, 'hazelcast': 1}) | |
r.zadd('votes:north:east', **{'hazelcast': 1, 'riak': 1, 'redis': 1}) | |
r.zadd('votes:north:west', **{'redis': 1, 'cassandra': 1, 'onetick': 1}) |
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
;; inspired by suggestion in THE doc: http://java.ociweb.com/mark/clojure/article.html | |
(ns bootcamp.multi-method) | |
(defn measure-it [size] | |
(cond | |
(< size 3) :small | |
(< size 6) :medium | |
(< size 12) :large | |
:else :hard-to-measure )) |
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
(require '[jsonista.core :as json] | |
'[org.httpkit.client :as http] | |
'[buddy.core.keys :as keys] | |
'[buddy.sign.jwt :as jwt]) | |
(def mapper (json/object-mapper {:decode-key-fn keyword})) | |
;; if done fo real => check for http/get error | |
(defn jwks->pubkey [jwks-url] | |
(-> @(http/get jwks-url) |
NewerOlder