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
(when (get contacts from) | |
(some->> (:data payload) | |
(filter (comp discovery-exists? :message-id)) | |
(reduce (fn [fx discover] | |
...) | |
{}))) |
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
;; While working on the status-react codebase, from time to time, some properties of persisted objects | |
;; can be added/removed, their semantics can change, or whole new kind of objects need to be persisted | |
;; (or deleted). | |
;; In such situation, realm database schema need to be changed and maybe, even migration/s need to be specified. | |
;; Lets suppose we need to add boolean property `:unremovable?` to all chat objects persisted in realm. | |
;; First, we need to add new schema to schemas defined in accounts: | |
(ns status.im.data-store.realm.schemas.account.core | |
(:require [status.im.data-store.realm.schemas.account.v1.core :as v1] | |
;; all the other versions between v1 and v(N) | |
;; require your v(N+1) schema file, in this case, v11 |
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
;; Subset of current db structure | |
{:chat-animations | |
{"console" | |
{:parameter-box | |
{:height 300 | |
:changes-counter 17}}} | |
:chat-loaded-callbacks | |
{"console" nil | |
"wallet" nil | |
"mailman" nil |
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
{:message /confirmation-code , | |
:command {:command {:description Confirmation code, | |
:sequential-params true, | |
:color #7099e6, | |
:name confirmation-code, | |
:params [{:name code, :type number}], | |
:type :response, | |
:has-handler false, | |
:hidden? nil, | |
:owner-id console}, |
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
[{ | |
"id" : 392, | |
"title" : "Solved R&D - Internal Project", | |
"description" : "Developing the Solved Platform & Processes", | |
"topics" : { | |
"DISCIPLINE" : [ { | |
"id" : 1, | |
"name" : "General", | |
"avatar" : "", | |
"topicGroup" : "DISCIPLINE", |
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
;; common points of confusion for people new to Clojure | |
;; why core functions apparently change the type of given collection ? | |
(map inc [1 2 3 4]) ;; when evaluated, prints (2 3 4 5), not [2 3 4 5] | |
(take 2 {:a 1 :b 2 :c 3}) ;; when evaluated, prints ([:a 1] [:b 2]), not {:a 1 :b 2} |
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 db-util | |
(:require [clojure.string :as str])) | |
(def ^:private placeholders-for (comp (partial str/join ",") #(repeat % '?) count)) | |
(defn in-statement | |
"Takes a prepared SQL statement and variable number of arguments, which may be | |
also collection values. Replace all occurences of IN (?) with spliced out values | |
such as IN (?,?,?) where number of placeholder characters is the same as count | |
of elements in corresponding argument which is assumed to be a collection. |
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 async-util.input-pipe | |
(:require [clojure.core.async.impl.protocols :as impl] | |
[clojure.core.async :refer [<! >! close! go-loop]])) | |
(defprotocol InputPipe | |
(detach* [p])) | |
(defn input-pipe | |
"Creates and return input pipe of supplied channel with attached input channel." | |
[ch ch-i] |
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
(defn create-cancel-channel | |
[channel-to-notify timeout-ms] | |
(let [cancel-channel (async/chan) | |
timeout-channel (async/timeout timeout-ms)] | |
(async/go | |
(let [[_ c] (async/alts! [cancel-channel timeout-channel])] | |
(when (= c timeout-channel) | |
(async/close! cancel-channel) | |
(async/close! channel-to-notify)))) | |
cancel-channel)) |
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 '[clojure.set :as set]) | |
(require '[clojure.java.jdbc :as j]) | |
(def mysql-db {:subprotocol "mysql" | |
:subname "//127.0.0.1:3306/clojure_test" | |
:user "clojure_test" | |
:password "clojure_test"}) | |
(defn product-service [key] | |
(println (str "Finding product with key: " key)) |