Skip to content

Instantly share code, notes, and snippets.

Avatar
🌴

Alexandre Aquiles alexandreaquiles

🌴
View GitHub Profile
View funcoes.clj
; predicate
(defn maior-que-100? [valor]
(> valor 100))
(defn sorteado? [_]
(> (rand) 0.5))
(defn valor-descontado [valor-bruto aplica-desconto?]
(let [desconto 0.1]
View fizzbuzz.js
for (let n = 1; n <= 100; n++) {
let text = '';
if (n % 3 === 0) {
text = 'Fizz';
}
if (n % 5 === 0) {
text = text + 'Buzz';
View triangulo-com-while.html
<script>
var i = 0;
while(i < 7){
var j = 0;
while(j <= i){
document.write("#");
j++
}
i++
document.write("<br>");
View kafka.drawio
<mxfile host="app.diagrams.net" modified="2020-07-30T13:24:04.078Z" agent="5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36" etag="za19b1gBxxY2w0qTRGfJ" version="13.5.5" type="device"><diagram id="n5W6CcNsMwQ7RIXeHPj_" name="Page-1">7V1bc9pIFv4t++CqmQendEEXHm2TZDOxK3acVDL71pIa0FioWUnEJr9+u0EC0edgZCO1hLyemgo0QsD39bmf7j4zr2ZPHxMyn96wgEZnhhY8nZmjM8PQHd3l/4iR5XpkMMwHJkkY5BdtB+7D3zQf1PLRRRjQdOfCjLEoC+e7gz6LY+pnO2MkSdjj7mVjFu1+6pxMKBi490kER3+EQTZdj7qWth3/Nw0n0+KTdS1/ZUaKi/OBdEoC9lgaMt+fmVcJY9n60ezpikYCvAKX9fs+7Hl188USGmeV3vD4T/bhzg8DNrok3+5/2oH149zN2fhFokX+i/Nvmy0LCBK2iAMq7qKfmZeP0zCj93Pii1cfOel8bJrNovxl+K3yL/qLJhl9Kg3l3/IjZTOaJUt+ydMu9fmM0c0C7MctAeYwH5uWwDedfJDkpE82997iwh/k0LwApqEFYKIeYw/pmWFH/NMvvYQ/mohHf2RsHvp/HofiOIyiKxaxZPVec2yJ//h4miXsgZZesVd/4h0szkrj6z8+LmAP+XS+iMJJzF/j364elgYSSwOMpQHC0kYgjmHJv7AuRp+uvUvi/shI9vdfc//zuW4DlvhPzMIsZDEf1o7jBEdSYorqgUUdjKmh7ZjE3mAPgEbo2Iu9bUnYF0q1hL1RzNky9nZj0DvPQq8rgH48prbvY9AHztDj7NcDvfFOAt9y4cRvDHxUO+kA+/tb/vyc/89nvQuw578+2wV4F7K
@alexandreaquiles
alexandreaquiles / eval.clj
Created Jul 18, 2020
Trying a Clojure version of Paul Graham's The Roots of Lisp: http://www.paulgraham.com/rootsoflisp.html
View eval.clj
(defn eval* [e a]
(defn atom* [x]
(or (= x '()) (not (seq? x))))
(defn null* [x]
(= x '()))
(defn and* [x y]
(cond x
(cond y true
:default false)
:default false))
@alexandreaquiles
alexandreaquiles / Kafka.drawio
Last active Nov 19, 2020
draw.io Kafka Diagram (open it in https://draw.io)
View Kafka.drawio
<mxfile host="app.diagrams.net" modified="2020-06-03T21:01:58.638Z" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36" etag="a1-ix2r6zzVVSPH3lcE_" version="12.9.3" type="device"><diagram id="h7GPxYbChwaNLsouTysn" name="Page-1">7V1pd9rG1/80nKYvyNEu8ZJ4SZ3EsWPcp+3/TY9AA6gGDZWEHfrpnxltSHMvi40WhMk5sY0kJLi/ufsyHfVi/vOzby+mt9Qhs44iOT876mVHUWSjp7Nf/MgqPqJpVnxg4rtOctH6wMD9jyQHpeTo0nVIULgwpHQWuoviwRH1PDIKC8ds36cvxcvGdFZ86sKeEHBgMLJn8OgfrhNO46OWYq6P/0bcyTR9MvvG8Zm5nV6cfJNgajv0JXdIveqoFz6lYfzX/OcFmXHipXSJ33e94Wz2wXzihfu84Z9H25ldvHxR/9a1fx/Gtvbb5KGra/Ftnu3ZMvnGX+xnu6MYM3bTT0Of/TXhf11QL1jOiQ/PbDkiHhhT9lEZJcJVQl7j3yVNT3SDCPw+u0CWFj/XJ9O7XA0pffpMPOLbIfUHxH92RyS9Nfve8d2LT2SHc59CKTxc8enScwgnj8xOv0zdkAwW9oiffWGrmR2bhvNZcnrszmYXdEb96L0qkR2dmOx4EPr0ieTO9AxTtY3sTLpqlOwT5CFLUHwmfkh+5g4lEH4mdE5Cf8UuSc7qSoJYwk+yoiXr62W9POV0zU1zS9NIjtkJR0yye68XDfsjWTf4Grob3F9fXy97N18WxuAfpSvfeNddtubBIjqM1mXQySySSe5BMqmmCsmk6FXRSdlNJTtYxEJs7P7kxPq0IL7Lnk742mKPYFKP3K8P5Wlmz9yJx/4eMZpF5zJ5I7
@alexandreaquiles
alexandreaquiles / todo.md
Last active Jun 2, 2020
Kafka Consumer Groups, Offsets and Partitions
View todo.md
  • Create a topic with 3 partitions: bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic TEST --partitions 3
  • Alter the number of partitions of an existing topic to 3: bin/kafka-topics.sh --bootstrap-server localhost:9092 --alter --topic BOOK_ORDERS --partitions 3
  • List consumer groups: bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --list
  • Describe consumers groups and its partitions and offsets: bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group EbookGeneratorService
  • Describe partitions and offsets of all consumer groups: bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --all-groups
View todo.md
  • Install Kafka
  • Change config/zookeeper.properties and config/server.properties to use non-temporary folders
  • Run Zookeeper: bin/zookeeper-server-start.sh config/zookeeper.properties
  • Run Kafka: bin/kafka-server-start.sh config/server.properties
  • Produce some records to the ebooks topic: bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic ebooks
  • Consume the ebooks topic from the beginning: bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic ebooks --from-beginning
  • List the topics bin/kafka-topics.sh --bootstrap-server localhost:9092 --list
  • Describe the ebooks topic: bin/kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic ebooks
@alexandreaquiles
alexandreaquiles / sqrt.clj
Created May 30, 2020
Square Implementation from SICP
View sqrt.clj
(defn square [x]
(* x x))
(defn average [x y]
(/ (+ x y) 2))
(defn improve [guess x]
(average guess (/ x guess)))
(defn abs [x]
@alexandreaquiles
alexandreaquiles / estoque.clj
Created May 19, 2020
High Order Functions
View estoque.clj
(ns estoque.desconto)
;Good Practices
;split code into smaller pieces
; reuse
; compose
;readability
;PREDICATE - it returns true or false