Skip to content

Instantly share code, notes, and snippets.

View mauricioszabo's full-sized avatar

Maurício Szabo mauricioszabo

View GitHub Profile
mauricioszabo / bb-optimized.clj
Last active October 21, 2022 13:58
BB Benchmarks
(ns binarytrees)
(defn bottom-up-tree [item depth]
(if (> depth 0)
[(bottom-up-tree (dec (* 2 item)) (dec depth))
(bottom-up-tree (* 2 item) (dec depth))
[nil nil item]))
(defn item-check [i]
mauricioszabo / core.clj
Last active March 14, 2022 16:30
Test GraphQL + Pathom3
(ns graphql-test.core
(:require [malli.core :as m]
[clojure.string :as str]
[com.wsscode.misc.coll :as coll]
[com.wsscode.pathom3.interface.eql :as p.eql]
[com.wsscode.pathom3.connect.operation :as connect]
[com.wsscode.pathom3.connect.indexes :as indexes]
[com.walmartlabs.lacinia :as lacinia]
[com.walmartlabs.lacinia.util :as lacinia-util]
[edn-query-language.core :as eql]
mauricioszabo /
Created August 31, 2021 17:44
Squash and lost history
╰─>$ git checkout -b feature-branch
Switched to a new branch 'feature-branch'
╰─>$ git commit -a -m 'Commit 2'
[feature-branch 1f16b96] Commit 2
1 file changed, 1 insertion(+)
╰─>$ git commit -a -m 'Commit 3'
[feature-branch f7c9f08] Commit 3
1 file changed, 1 insertion(+)
mauricioszabo / dependencies
Created June 13, 2021 01:29
Parallel Consumer Example
[io.confluent.parallelconsumer/parallel-consumer-core ""]
[fundingcircle/jackdaw "0.8.0"]
mauricioszabo / chlorine-config.cljs
Created April 13, 2021 12:29
Chlorine Config for custom resolver of goto var definition
(defn- get-resolver-for-keyword [k]
(p/let [{:keys [text]} (editor/get-namespace)
namespace (str/replace text #"(.*?\.).*" "$1")
res (editor/run-feature :eql [{(list :repl/namespaces {:filter namespace})
[:repl/namespace {:namespace/vars [:var/fqn]}]}])
vars (for [{:namespace/keys [vars]} (:repl/namespaces res)
{:var/keys [fqn]} vars]
code (str "(->> " (vec vars)
" (filter (fn [r] (-> r :com.wsscode.pathom.connect/output set (contains? " k "))))"
mauricioszabo / neverending.psql
Created January 7, 2021 12:49
PostgreSQL example of recursive queries
INSERT INTO tree (id, parent_id, description)
(6, 6, 'Im Recursive');
WITH RECURSIVE parents as (
select id,
from tree
where parent_id = 6
mauricioszabo /
Created December 5, 2020 14:00
My current Chlorine config file

To make this code above work, you'll have to add some dependencies on ~/.atom/chlorine - they are used mostly for the custom tags here:

In file ~/.atom/chlorine/nomno.js 
module.exports = require('nomnoml');

In file ~/.atom/chlorine/hpcc-js.js 
const hpcc = require('@hpcc-js/wasm')
hpcc.wasmFolder(__dirname + "/node_modules/@hpcc-js/wasm/dist")
module.exports = hpcc
mauricioszabo / account.rb
Created November 28, 2020 23:41
Autoimport problems in Rails
class Account
def to_json(*args)
{amount: BigDecimal("200")}.to_json
mauricioszabo / core.clj
Created November 5, 2020 17:14
VCR in Clojure
(ns example.core
(:require [vcr-clj.core :as vcr]
[vcr-clj.clj-http :as vcr-http]
[clj-http.client :as client]))
(defn random [n]
{:number (+ 10 (rand-int n))
:username "admin"
:password "Lol, Ima Password!"})
mauricioszabo / query.clj
Created October 5, 2020 22:47
Chlorine's datalog ideas
;; What I want to do is something like this:
(def res
(query '[:find ?meta
[?e :editor/contents "p/deferred"]
[?e :editor/ns ""]
[?fqn :repl/fqn ?e]
[?var :repl/var ?fqn]
[?meta :repl/meta ?fqn]]))