:query-repos := <<
(graphql-query
((viewer
(repositories
:arguments
((first . 3)
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
(deftype Employee [name id] | |
Object | |
(equals [a b] (= (.id a) (.id b))) | |
(hashCode [this] (.hashCode (.id this))) | |
(toString [this] (.name this))) | |
(def vince (Employee. "Vince" 42)) | |
(def vincent (Employee. "Vincent" 42)) |
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
(defmacro assert-all | |
[& pairs] | |
`(do (when-not ~(first pairs) | |
(throw (IllegalArgumentException. | |
(str (first ~'&form) " requires " ~(second pairs) " in " ~'*ns* ":" (:line (meta ~'&form)))))) | |
~(let [more (nnext pairs)] | |
(when more | |
(list* `assert-all more))))) | |
(defmacro when-let* |
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 sagaz-back.validation) | |
; Helper functions | |
(defn validate* [field value regexp] | |
(if-not (re-matches regexp value) | |
(keyword (str "invalid-" (name field))))) | |
(defn validate [data criteria] | |
(-> (reduce-kv (fn [acc k re] (conj acc (validate* k (k data) re))) |
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 '[org.opencv.core Mat Size CvType] '[org.opencv.highgui Highgui] '[org.opencv.imgproc Imgproc]) | |
(clojure.lang.RT/loadLibrary org.opencv.core.Core/NATIVE_LIBRARY_NAME) | |
(def angelina (Highgui/imread "resources/angelina.jpg")) | |
(def blurred (Mat. 960 1280 CvType/CV_8UC3)) | |
(Imgproc/GaussianBlur angelina blurred (Size. 5 5) 3 3) | |
(Highgui/imwrite "resources/images/blurred.png" blurred) |
I hereby claim:
- I am mbuczko on github.
- I am mbuczko (https://keybase.io/mbuczko) on keybase.
- I have a public key whose fingerprint is 0639 2B57 8F68 B2F8 7CE9 861E EA1C F2EE 7389 EE0E
To claim this, I am signing this object:
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
(defmacro with-mock [vr & body] | |
`(with-redefs [~vr (with-meta | |
(fn [& ~'args] (swap! (-> ~vr meta :args) conj ~'args)) | |
{:args (atom [])})] | |
(do ~@body))) | |
(defmacro make-mock | |
([m] `(make-mock ~m nil)) | |
([m stub] |
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
(pc/defresolver res-with-timeout [_ _] | |
{::pc/output [:foo]} | |
(async/go | |
(let [timeout-ch (async/timeout 3000) | |
[ch res] (async/alts!! [(async/go | |
(do-my-operation-here)) | |
timeout-ch] :priority true)] | |
(if (= ch timeout-ch) | |
(throw (ex-info "Resolver timeout" {:timeout 3000})) | |
res)))) |
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
;; requires git-link package | |
(defun github--goto-issue-or-pr (id type) | |
"Opens a browser with issue or PR (denoted by TYPE) of given ID." | |
(let* ((origin-url (car (git-link--exec "config" "--get" "remote.origin.url"))) | |
(repo-match (string-match "^git@github.com:\\([^\\.]+\\)" origin-url)) | |
(repo-url (concat "https://github.com/" (match-string 1 origin-url))) | |
(sub-path (cond ((eq 'issue type) "/issues") | |
((eq 'pr type) "/pull")))) |
OlderNewer