Skip to content

Instantly share code, notes, and snippets.

View mostafa-asg's full-sized avatar
:octocat:
while(!(succeed = try()))

Mostafa Asgari mostafa-asg

:octocat:
while(!(succeed = try()))
View GitHub Profile
@mostafa-asg
mostafa-asg / kafka-console-consumer tip1
Last active November 2, 2023 12:56
Print key of records in kafka-console-consumer
use --property print.key=true
Example : ./kafka-console-consumer.sh --bootstrap-server <BROKERS_ADDRESS> --topic <YOUR_TOPIC> --property print.key=true
@mostafa-asg
mostafa-asg / Css styles
Last active August 27, 2022 21:05
centering images in Hugo - Based on this article : (http://www.ebadf.net/2016/10/19/centering-images-in-hugo/)
img[src$='#center']
{
display: block;
margin: 0.7rem auto; /* you can replace the vertical '0.7rem' by
whatever floats your boat, but keep the
horizontal 'auto' for this to work */
/* whatever else styles you fancy here */
}
img[src$='#floatleft']
### CURL and binary data
1. Fill the http body with the content of a file:
```
curl --request POST --data-binary "@/tmp/your_file_path/" {URL}
```
2. Send files as multipart/form-data
```
curl -F 'img_avatar="@/tmp/your_file_path/" {URL}
```
After downloading the source code:
$ ./configure --enable-optimizations
$ sudo make altinstall
uuid_generate_v4()
Activate it via:
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
@mostafa-asg
mostafa-asg / gist:8817c6eb45d7eb029535dfa34a7003ed
Created January 13, 2022 08:24
How many partitions to use for a topic?
The formula for determining the number of partitions per Kafka topic has been pretty well explored over time.
When creating a new topic in your Kafka cluster, you should first think about your desired throughput (t) in MB/sec.
Next, consider the producer throughput that you can achieve on a single partition (p)—this is affected by producer
configurations but generally sits at roughly 10s of MB/sec. Finally, you need to determine the consumer throughput (c)
you will have—this is application-dependent so you’ll have to measure it yourself. You should anticipate having at least
max(t/p, t/c) partitions for that topic. So if you have a throughput requirement of 250 MB/sec, with a producer and
consumer throughput of 50 MB/sec and 25 MB/sec respectively.
Then you should use at least max(250/50, 250/25) = max(5, 10) = 10 partitions for that topic.
https://www.confluent.io/blog/5-common-pitfalls-when-using-apache-kafka/
@mostafa-asg
mostafa-asg / With React Router
Created May 15, 2021 11:23
Dockerizing a React App
# build environment
FROM node:13.12.0-alpine as build
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package.json ./
COPY package-lock.json ./
RUN npm ci --silent
RUN npm install react-scripts@3.4.1 -g --silent
COPY . ./
RUN npm run build
A readiness probe allows Kubernetes to poll the pod and not consider it ready to receive requests until the application indicates it is ready.
```YAML
readinessProbe: # if readiness probe fails, is taken out of your loadbalancer
initialDelaySeconds: 15 #adjust this to be a little less than the time it normally takes for your application to startup
httpGet:
path: /internal/health
port: 8080
timeoutSeconds: 3
```
@mostafa-asg
mostafa-asg / docker-compose.yml
Created April 10, 2021 08:37
Confluent kafka via docker compose
version: '2'
services:
zookeeper:
image: confluentinc/cp-zookeeper:6.0.0
hostname: zookeeper
container_name: zookeeper
ports:
- "2181:2181"
environment:
@mostafa-asg
mostafa-asg / kafka-server-start.sh
Last active February 22, 2021 07:48
Kafka Prometheous JMX exporter config
export KAFKA_OPTS="-javaagent:{PATH}/jmx_prometheus_javaagent-0.14.0.jar=9090:{PATH}/prom-jmx-agent-config.yml"