This file contains hidden or 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
#!/usr/bin/env bash | |
# Get the Git branch | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
# Custom bash prompt | |
# | |
# Includes custom character for the prompt, path, and Git branch name. |
This file contains hidden or 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
(defn split [sep s] | |
(clojure.string/split s sep)) |
This file contains hidden or 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
(defn lines [sep contents] | |
(->> contents | |
(split #"\n") | |
(map (partial split sep)))) |
This file contains hidden or 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
(defn maps [sep contents] | |
(let [lines (lines sep contents) | |
cols (first lines) | |
rows (rest lines)] | |
(map (partial zipmap cols) rows))) |
This file contains hidden or 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
(defn read-csv [filepath] | |
(let [contents (slurp filepath)] | |
(maps #"," contents))) |
This file contains hidden or 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 proj.records-test | |
(:require [proj.records :refer :all] | |
[clojure.test :refer :all])) | |
(deftest create-record-test | |
(with-redefs [db/insert-record<! (fn [arg] (assoc arg :id 1))] | |
(testing "with valid record data" | |
(let [arg {:content "hello world"}] | |
(is (= {:id 1 :content "hello world"} (create! arg))))))) |
This file contains hidden or 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 proj.records | |
(:require [yesql.core :refer [defqueries]])) | |
(defqueries "records.sql") | |
(defn create! [body] | |
(-> body | |
validate | |
db/insert-record<!)) |
This file contains hidden or 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
#!/bin/bash | |
lein new majestic monolith | |
cd monolith | |
git init | |
echo .idea >> .gitignore | |
git commit -am "Initial commit" # good practice to commit early and often | |
idea . # or use your favorite editor here |
This file contains hidden or 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 monolith.core | |
(:require [monolith.server :as server] | |
[monolith.env :as env] | |
[monolith.utils :as utils]) | |
(:gen-class)) | |
(def start server/start) | |
(def stop server/stop) | |
(def restart server/restart) |
This file contains hidden or 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 monolith.server | |
(:require [org.httpkit.server :as http] | |
[clojure.tools.namespace.repl :as tn] | |
[ring.middleware.json :refer [wrap-json-body wrap-json-response]] | |
[ring.middleware.defaults :refer [wrap-defaults api-defaults]] | |
[monolith.env :as env] | |
[monolith.routes :refer [routes]] | |
[monolith.http :refer [response]] | |
[monolith.utils :refer [throw+]] | |
[monolith.logic.tokens :as tokens])) |
OlderNewer