Skip to content

Instantly share code, notes, and snippets.

Yehonathan Sharvit viebel

Block or report user

Report or block viebel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View CreateDeveloperMetadataRequest.clj
(->
service
.spreadsheets
(.batchUpdate "1zC8gFo20z0WdldYEQ1KuC0jGFZjHZI14fauFmCQ4H4s"
(make-batch-update [(-> (CreateDeveloperMetadataRequest.)
(.setDeveloperMetadata (-> (DeveloperMetadata.)
(.setMetadataId (int 1232))
(.setMetadataKey "foofoo")
(.setMetadataValue "123")
(.setLocation (-> (DeveloperMetadataLocation.)
View clojure-stories.clj
;loaded from gist: https://gist.github.com/viebel/1662c34536a099e591380ba2e43172c4
;; hello worlds
(defn hello [name]
(str "Hello, " name "!"))
(defn multiple-hellos [names]
(clojure.string/join "\n" (map hello names)))
(println (hello "Yehonathan"))
View lesson-1-hello-multiple.clj
(str "Hello Advah"
" "
"Hello Yair")
(defn h [name]
(str "Hello"
" "
name))
[(h "Yair")
View datascript-demo.clj
(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
View create-graph.clj
(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)))
View dijkstra.clj
(ns dijkstra.core)
(defn unvisited-neighbors
"Returns unvisited node's neighbors"
[graph node unvisited] (select-keys (get graph node) unvisited))
(defn update-costs
"Returns costs updated with any shorter paths found to curr's unvisited
neighbors by using curr's shortest path"
[g costs curr unvisited]
View capstone-6.clj
(def github-db {"viebel"
{:username "viebel",
:name "Yehonathan Sharvit",
:email "ys@me.com",
:organizations ["ibm" "google"],
:repositories
{"klipse" {:name "klipse", :stars 23451, :forks 1254},
"titeuf" {:name "titeuf", :stars 1432, :forks 52},
"spirou" {:name "spirou", :stars 455, :forks 9}}},
"zepad"
View tagged-literals.cljs
(require
'[cljs.tools.reader :as r]])
(binding [r/*data-readers* {'a/num (constantly 1)}]
:a (r/read-string "{:a #a/num \"42\"}"))
View re-frame-timer-demo.cljs
(ns simple.core
(:require [reagent.core :as reagent]
[re-frame.db :as db]
[re-frame.core :as rf]))
;; A detailed walk-through of this source code is provied in the docs:
;; https://github.com/Day8/re-frame/blob/master/docs/CodeWalkthrough.md
;; -- Domino 1 - Event Dispatch -----------------------------------------------
@viebel
viebel / defn-args.cljs
Last active Jan 26, 2019
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…
View defn-args.cljs
(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?
You can’t perform that action at this time.