Skip to content

Instantly share code, notes, and snippets.

View spy.clj
(def spy-plugin
{::pc/wrap-resolve (fn [resolve]
(fn [env input]
(let [resolver-sym (-> env ::pc/resolver-data ::pc/sym)
_ (prn {:sym resolver-sym
:input input
:entity (p/entity env)})
output (resolve env input)]
(prn {:sym resolver-sym
:output output
View desafio.md

Função promover/rebaixar (parte 1)

Dado uma coleção coll, por exemplo, [:a :b :c :d :e] e um predicado pred, por exemplo #{:c}, implementar uma função promover que recebe (promover #{:c} [:a :b :c :d :e]) e retorna a coleção com o elemento selecionado "uma posição a frente": [:a :c :b :d :e]

Implementar também a função rebaixar, com a mesma assinatura, porém resulta em [:a :b :d :c :e]

Os casos de borda (elementos repetidos, agrupamentos degenerados) não são importantes.

@souenzzo
souenzzo / datomc-on-js-graal.clj
Created May 23, 2018
How to access datomic from javascript in graalvm
View datomc-on-js-graal.clj
;; Hello world with clojure + js
;; (import '(org.graalvm.polyglot Context))
(let [polyglot (-> (doto (Context/newBuilder (into-array ["js"]))
(.allowAllAccess true))
(.build))]
(.eval polyglot "js" "
console.log('hello');
"))
@souenzzo
souenzzo / deps.edn
Last active Mar 16, 2021
Clojure version of "java quickstart" from gsheets. https://developers.google.com/sheets/api/quickstart/java
View deps.edn
;; run with
;; clj -Sdeps '{:deps {gdocs {:git/url "https://gist.github.com/souenzzo/df540002607b15378f8014237e499fdd" :sha "fee00617c75fc24c74931aa4200f74666c5b66b6"}}}' -m gdocs
{:paths ["."]
:deps {org.clojure/clojure {:mvn/version "1.10.0"}
com.google.api-client/google-api-client {:mvn/version "1.28.0"}
com.google.oauth-client/google-oauth-client-jetty {:mvn/version "1.28.0"}
com.google.apis/google-api-services-sheets {:mvn/version "v4-rev566-1.25.0"}}}
View foo.clj
(ns digital-wallet.main-test-old
(:require [clojure.test :refer [deftest]]
[midje.sweet :refer [fact =>]])
(:import (clojure.lang ILookup)
(java.lang AutoCloseable)
(java.util Properties)
(org.apache.kafka.common.serialization Serdes Serdes$StringSerde Serdes$LongSerde)
(org.apache.kafka.streams TopologyTestDriver StreamsConfig Topology KeyValue)
(org.apache.kafka.streams.processor.api ProcessorSupplier Processor ProcessorContext Record)
(org.apache.kafka.streams.state Stores KeyValueStore)
View eql-hodur.clj
(ns eql-hodur
(:require [edn-query-language.core :as eql]
[clojure.spec.alpha :as s]
[datascript.core :as ds]))
(defn add-prop
[prop {:keys [children]
:as node}]
(if (contains? node :children)
(assoc node
@souenzzo
souenzzo / deps.edn
Last active Sep 8, 2020
Browser presign POST upload using AWS-SDK
View deps.edn
;; reference
;; https://github.com/kamil-perczynski/s3-direct-browser-upload
{:deps {org.clojure/clojure {:mvn/version "1.10.1"}
hiccup/hiccup {:mvn/version "2.0.0-alpha2"}
io.pedestal/pedestal.jetty {:mvn/version "0.5.8"}
io.pedestal/pedestal.service {:mvn/version "0.5.8"}
commons-codec/commons-codec {:mvn/version "1.15"}
com.cognitect.aws/api {:mvn/version "0.8.474"}
com.cognitect.aws/endpoints {:mvn/version "1.1.11.842"}
@souenzzo
souenzzo / build.clj
Last active Aug 15, 2020
Using material-ui.com from cljs. Still a fat build
View build.clj
;; this can be used on figwheel or in "any" cljs build api
;; at the first time, create a empty package.json with `{}` inside and `yarn add react webpack webpack-cli react-dom @material-ui/core`
;; you need to run "yarn install" and "yarn webpack" BEFORE this
;; !!!! this is a dev build !!!!
(def dev-build
'{:id "dev"
:source-paths ["src" "dev"]
:figwheel {:on-jsload cljs.user/on-jsload}
:compiler {:main cljs.user
:asset-path "/js/out"
@souenzzo
souenzzo / cola.edn
Created Jun 20, 2020
lambda-io.demo
View cola.edn
;; hello eql
[:app/hello]
;; data->shape
{:app/hello "ok"}
{:app/hello "ok"
:app/users [{:user/id 1
:user/username "2"
:user/addresses [{:address/description "a"
:address/number 1}]}]}
View pathom.clj
(let [conn (doto (ds/create-conn {:user/addresses {:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many}
:user/id {:db/unique :db.unique/identity}})
(ds/transact! [{:user/id 1
:user/addresses [-1 -2]}
{:user/id 2
:user/addresses [-2 -3]}
{:user/id 3
:user/addresses [-4]}
{:db/id -1