Skip to content

Instantly share code, notes, and snippets.

View armando-couto's full-sized avatar
‼️
Focusing

Antonio Armando Couto Bem Filho armando-couto

‼️
Focusing
View GitHub Profile
@armando-couto
armando-couto / docker-compose-kafka.yml
Created July 14, 2023 20:35
Esse Docker Composer serve para subir os projetos Zookeeper, Kafka, Kouncil e Kafdrop
version: '3'
services:
zookeeper:
image: wurstmeister/zookeeper
networks:
- broker-kafka
container_name: zookeeper
ports:
- "2181:2181"
require 'kafka'
# Set up Kafka client
kafka = Kafka.new(
seed_brokers: ['localhost:9092'],
client_id: 'my_kafka_client'
)
# Create a producer
producer = kafka.producer
@armando-couto
armando-couto / checkRunningProcess.sh
Last active April 10, 2023 13:20
$ checkRunningProcess.sh proxy.py
#!/bin/bash
ps_out=`ps -ef | grep $1 | grep -v 'grep' | grep -v $0`
result=$(echo $ps_out | grep "$1")
if [[ "$result" != "" ]];then
echo "Running"
else
echo "Not Running"
fi
version: '2'
services:
zookeeper:
image: wurstmeister/zookeeper:3.4.6
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka
ports:
- "9092:9092"
Eclipse IntelliJ IDEA Descrição
F4 ctrl+h Mostra o tipo de hierarquias
ctrl+alt+g ctrl+alt+F7 Procura utilizações
ctrl+shift+u ctrl+f7 Procura utilizações no mesmo arquivo
alt+shift+r shift+F6 Renomeia
ctrl+shift+r ctrl+shift+N Procura arquivos | abre resources
ctrl+shift+x j ctrl+shift+F10 Executa um Java program
ctrl+shift+o ctrl+alt+o Organiza os imports do seu código
ctrl+o ctrl+F12 Mostra a Estrutura|Objeto|Função Atual
@armando-couto
armando-couto / package.go
Created March 7, 2022 00:19
So let’s put all this to use. Let’s look at an example that uses the done channel pattern, and see what benefits we might gain from switching to use of the context package. Here is a program that concurrently prints a greeting and a farewell
package main
import (
"fmt"
"sync"
"time"
)
func main() {
var wg sync.WaitGroup
@armando-couto
armando-couto / pipelines.go
Created March 7, 2022 00:17
Channels are uniquely suited to constructing pipelines in Go because they fulfill all of our basic requirements. They can receive and emit values, they can safely be used concurrently, they can be ranged over, and they are reified by the language. Let’s take a moment and convert the previous example to utilize channels instead
package main
import "fmt"
func main() {
generator := func(done <-chan interface{}, integers ...int) <-chan int {
intStream := make(chan int)
go func() {
defer close(intStream)
for _, i := range integers {
@armando-couto
armando-couto / count.go
Created March 7, 2022 00:15
The first question of multiple channels being ready simultaneously seems interesting. Let’s just try it and see what happens!
package main
import (
"fmt"
)
func main() {
c1 := make(chan interface{})
close(c1)
c2 := make(chan interface{})
@armando-couto
armando-couto / stream.go
Created March 7, 2022 00:14
For now, let’s look at an example to help clarify these concepts. Let’s create a gorou‐ tine that clearly owns a channel, and a consumer that clearly handles blocking and closing of a channel
package main
import (
"fmt"
)
func main() {
chanOwner := func() <-chan int {
resultStream := make(chan int, 5)
go func() {
@armando-couto
armando-couto / queue.go
Created March 7, 2022 00:12
Let’s expand on this example and show both sides of the equation: a goroutine that is waiting for a signal, and a goroutine that is sending signals. Say we have a queue of fixed length 2, and 10 items we want to push onto the queue. We want to enqueue items as soon as there is room, so we want to be notified as soon as there’s room in the queue
package main
import (
"fmt"
"sync"
"time"
)
func main() {
c := sync.NewCond(&sync.Mutex{})