Skip to content

Instantly share code, notes, and snippets.

:octocat:

Alexandre Aquiles alexandreaquiles

:octocat:
View GitHub Profile
@alexandreaquiles
alexandreaquiles / Kafka.drawio
Last active Jun 3, 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
@alexandreaquiles
alexandreaquiles / CalculadoraDePrecos.java
Created Jul 4, 2018
Solução sugerida para exercício de Refatoração do PM-87.
View CalculadoraDePrecos.java
public class CalculadoraDePrecos {
public static BigDecimal calcula(Sessao sessao, Integer quantidade) {
return sessao.calcula(quantidade);
}
}
View FileUtils.java
package br.com.paradizo.tema;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.FileSystem;
import java.nio.file.FileSystemAlreadyExistsException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
View FileUtils.java
public class FileUtils {
public static String getResourceContents(String resource) throws URISyntaxException, IOException {
Path resourcePath = getResourceAsPath(resource);
return getPathContents(resourcePath);
}
private static Path getResourceAsPath(String resource) throws URISyntaxException, IOException {
URI uri = FileUtils.class.getResource(resource).toURI();
View JacksonConfig.java
@Configuration
public class JacksonConfig {
@Bean
public ObjectMapper objectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.GETTER, Visibility.NONE);
mapper.setVisibility(PropertyAccessor.SETTER, Visibility.NONE);
mapper.setVisibility(PropertyAccessor.CREATOR, Visibility.NONE);
mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
You can’t perform that action at this time.