Skip to content

Instantly share code, notes, and snippets.

🦄

Enzzo souenzzo

🦄
Block or report user

Report or block souenzzo

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
@souenzzo
souenzzo / pr.clj
Created Nov 20, 2019
Run with "clj -A:dev -m user.pr" or "clj -A:pr"
View pr.clj
(ns user.pr
(:require [cognitect.aws.client.api :as aws]
[clj-http.client :as http]
[clojure.java.io :as io])
(:import (org.eclipse.jgit.api Git)))
(defn slack->request
[text]
{:method :post
:url "https://hooks.slack.com/services/XX/YY/ZZ"
@souenzzo
souenzzo / find-unused-deps.clj
Created Nov 4, 2019
!!!! QUCK'n'DIRTY SOLUTION !!!!
View find-unused-deps.clj
(let [{:keys [namespace-usages]} (:analysis (kondo/run! {:lint ["src/main"
"src/old"]
:config {:output {:analysis true}}}))
url->splited-path #(into []
(comp (map (memfn getFileName))
(map str)
(take-while (complement string/blank?)))
(iterate (fn [x] (when x (.getParent x)))
(Paths/get (new URI (-> (str %)
(string/replace #"^jar\:"
View xf.clj
(let [atributo->item {:a {:atributo :a
:selecionado? true}
:b {:atributo :b
:selecionado? false}
:c {:atributo :c}}]
{:reduce (reduce-kv (fn [acc k {:keys [selecionado?]}]
(if (false? selecionado?)
acc
(conj acc k)))
#{}
View exemplo.clj
(ns exemplo
(:require [io.pedestal.http :as http]))
(def routes ::invalid)
(def server-build-time
(-> {::http/type :jetty
::http/routes routes
::http/port 8080}
http/default-interceptors
View tiny-om.cljs
(ns tiny-om.client
(:require ["react" :as r]
[goog.dom :as gdom]
["react-dom" :as r.dom])
(:require [clojure.core.async :as async]))
(defn el
[app type props & children]
(apply r/createElement (name type) (clj->js props) children))
View graph_bot.clj
(time (let [baos (ByteArrayOutputStream.)
data [[:foo :bar]]]
(-> (apply uber/multidigraph data)
(uber/viz-graph {:save {:format :svg
:filename baos}}))
(-> (xml/parse (io/input-stream (.toByteArray baos)))
(assoc-in [:attrs :data] (pr-str data))
(xml/emit-str)
(.getBytes)
(io/input-stream)
View xform.clj
(let [xparir-transform (fn [{:keys [initial-value transform-fn]}]
(fn [rf]
(let [old (volatile! initial-value)]
(fn
([] (rf))
([result] (rf result))
([result input]
(let [new (transform-fn input @old)]
(vreset! old input)
(rf result new)))))))]
View interop.clj
(defn len [x]
(.length x))
(defn len2 [^String x]
(.length x))
(defprotocol ILengthable
(len3 [this]))
(extend-protocol ILengthable
String
(len3 [this] (.length this)))
@souenzzo
souenzzo / deps.edn
Last active Apr 23, 2019
import do not search for cljc files
View deps.edn
;; should work, once it was required first
;; clj -Srepro -Sdeps '{:deps {import-bug {:git/url "https://gist.github.com/souenzzo/e23944fac595077f372aa662cde5ff91" :sha "fd49010c7fee88bc3fb705d5fd494718bbd16f18"}}}' -m ok
;; should fail, once import will not search for cljc files
;; clj -Srepro -Sdeps '{:deps {import-bug {:git/url "https://gist.github.com/souenzzo/e23944fac595077f372aa662cde5ff91" :sha "fd49010c7fee88bc3fb705d5fd494718bbd16f18"}}}' -m fail
{:paths ["."]
:deps {org.clojure/clojure {:mvn/version "1.10.1-beta2"}}}
View resolver.clj
(defn username-by-id
{::pc/kind pc/resolver
::pc/input #{:app.user/id}
::pc/output [:app.user/username]}
[{::keys [db]} {:app.user/keys [id]}]
{:app.user/username (-> (j/query db ["SELECT username FROM app_user WHERE id = ?"
id])
first
:username)})
You can’t perform that action at this time.