Skip to content

Instantly share code, notes, and snippets.

View mkrcah's full-sized avatar

Marcel Krcah mkrcah

View GitHub Profile
(defn execute-operation! [operation]
(println "Executing " operation)
(case (:kind operation)
:call-fakturoid
(call-fakturoid! (:request operation))
:save-xml-to-file
(save-xml-to-file! (:xml operation) (:file operation))))
(defn generate-souhrnne-hlaseni [{:as bag :input/keys [year-month]}
@mkrcah
mkrcah / json-rest-client.clj
Last active December 19, 2023 15:49
exploring APIs with REPL
(ns client.json-rest-client
(:require [clojure.data.json :as json]
[hato.client :as http]
[medley.core :as medley]))
(defn full-req [req server-conf]
(-> req
(dissoc :rel-path :body)
(medley/assoc-some :url (str (:server-url server-conf) (:rel-path req))
:accept :json
@mkrcah
mkrcah / find-exchange-rate.clj
Created November 18, 2023 21:16
find-exchange-rates (v2)
(ns exchange-rates.find-exchange-rate
(:require [clj-http.client :as client]
[tick.core :as t]
[clojure.tools.logging :as log]
[clojure.spec.alpha :as s]
[exchange-rates.rates-repo :as repo]
[exchange-rates.value-objects :as vo])
(:use [clojure.tools.trace]))
@mkrcah
mkrcah / find-exchange-rate.clj
Last active November 18, 2023 21:15
find exchange rates (v1)
(ns find-exchange-rate
"Design objectives:
- need deterministic exchange rates
- need only eur->czk for now, don't see use-cases for other pairs right now
- don't need any performance or persistence, in-memory is fine for now"
(:require [clj-http.client :as client]
[tick.core :as t]
[clojure.tools.logging :as log]
[medley.core :as m]
[clojure.test :refer [deftest is]]))
@mkrcah
mkrcah / gist:ffc05e0cfa59fe206d13
Created November 20, 2015 18:21
Install google fonts on Ubuntu, usable by PhantomJS
# Install google fonts
git clone https://github.com/google/fonts.git
sudo mkdir -p /usr/share/fonts/truetype/google-fonts/
find fonts/ -name "*.ttf" -exec sudo install -m644 {} /usr/share/fonts/truetype/google-fonts/ \;
sudo apt-get install fontconfig -y
sudo fc-cache -fv
@mkrcah
mkrcah / zkDelAll.py
Last active November 8, 2020 03:25
Remove all ZooKeeper nodes according to a given path template, see http://stackoverflow.com/questions/25052245/zookeeper-cli-wildcard-support
import sys
from kazoo.client import KazooClient
if len(sys.argv) not in (2,3):
print('Usage: zkDelAll.py [path] [host:port=localhost:2181]')
exit(1)
host = sys.argv[2] if len(sys.argv) == 3 else 'localhost:2181'
path = sys.argv[1]
@mkrcah
mkrcah / gist:d1af804e03d20133a16d
Created December 3, 2014 09:33
Spray routing - Notes from Scala meet up

Spray routing (@agemooij)

  • Spray should be run standalone in spray-can, since you don't want to encapsulate high-performant actor inside a low-performant container
  • Spray natively supports Futures:
def getEmployees: Future[List[Employees]] = ???
route = get { complete(OK, getEmployees)}
@mkrcah
mkrcah / gist:512dd7a8228833bb44ba
Last active August 29, 2015 14:09
Intro into Scalaz disjunction
import net.liftweb.http.JsonResponse
import scalaz._
import net.liftweb.json.JsonDSL._
// Fabricated errors that we might encounter
trait ParseError
case class ExtractError(s:String) extends ParseError
case class ConversionError(s: String) extends ParseError
case class SqrtError(n: Int) extends ParseError