Skip to content

Instantly share code, notes, and snippets.

View viebel's full-sized avatar

Yehonathan Sharvit viebel

View GitHub Profile
@viebel
viebel / defn-args.cljs
Last active January 21, 2020 11:15
The `spec` for `defn` arguments is called `:defn-args` and it is defined in [clojure.core.specs namespace](https://github.com/clojure/clojure/blob/clojure-1.9.0-alpha13/src/clj/clojure/core/specs.clj#L78-L84). But there are two problems with this implementation: 1. It has [not yet been ported](http://dev.clojure.org/jira/browse/CLJS-1813) to `cl…
(s/def ::local-name (s/and simple-symbol? #(not= '& %)))
(s/def ::binding-form
(s/or :sym ::local-name
:seq ::seq-binding-form
:map ::map-binding-form))
;; sequential destructuring
(s/def ::seq-binding-form
(s/and vector?
(defn read-input []
(loop []
(let [input (read-line)]
(when-not (= ":done" input))
(println (str "You entered: >>" input "<<"))
(recur))))
@viebel
viebel / rules.clj
Created November 14, 2019 14:28
text rules matching
(ns my.chat
(:require [clojure.string :as str]))
(def rules
[["hello" "hello you"]
["bye" "see you soon"]
["my name is Riccardo" "nice to meet you Riccardo"]])
(defn respond-fixed [input]
(ns viebel.gist-983676a98aee0991cfb002a67676602f.raw.split-expressions
(:require [cljs.tools.reader :as r]
[cljs.tools.reader.reader-types :as rt]
[clojure.string :as s]))
(defn- read-chars
[reader]
(loop [res []]
(if-let [ch (rt/read-char reader)]
(recur (conj res ch))
(ns viebel.gist-368d3bec58d3ec47e935ad488bafb600
(:require [cljs.tools.reader :as r]
[cljs.tools.reader.reader-types :as rt]
[clojure.string :as s]))
(defn- read-chars
[reader]
(loop [res []]
(if-let [ch (rt/read-char reader)]
(recur (conj res ch))

Keybase proof

I hereby claim:

  • I am viebel on github.
  • I am viebel (https://keybase.io/viebel) on keybase.
  • I have a public key whose fingerprint is EDBD 1851 C8E1 DBB5 8AA9 AADE AFC4 60B7 CD50 FA17

To claim this, I am signing this object:

(->
service
.spreadsheets
(.batchUpdate "1zC8gFo20z0WdldYEQ1KuC0jGFZjHZI14fauFmCQ4H4s"
(make-batch-update [(-> (CreateDeveloperMetadataRequest.)
(.setDeveloperMetadata (-> (DeveloperMetadata.)
(.setMetadataId (int 1232))
(.setMetadataKey "foofoo")
(.setMetadataValue "123")
(.setLocation (-> (DeveloperMetadataLocation.)
(str "Hello Advah"
" "
"Hello Yair")
(defn h [name]
(str "Hello"
" "
name))
[(h "Yair")
(require '[datascript.core :as d])
(let [schema {:aka {:db/cardinality :db.cardinality/many}}
conn (d/create-conn schema)]
(d/transact! conn [ { :db/id -1
:name "Maksim"
:age 45
:aka ["Max Otto von Stierlitz", "Jack Ryan"] } ])
(d/q '[ :find ?n ?a
(ns dijkstra.core)
(defn make-graph [] (atom {}))
(defn add-node [g node]
(swap! g assoc node {}))
(defn add-edge [g src target]
(swap! g update src #(assoc % target 1)))