Skip to content

Instantly share code, notes, and snippets.

@xsqian
xsqian / alter-kafka-partitions.sh
Last active October 11, 2023 19:04
How to alter kafka partitions
# create a topic with specified partitons
kafka-topics --bootstrap-server xx.xx.xx.xx:39092 --create --partitions 2 --topic test-partitions
kafka-topics --bootstrap-server xx.xx.xx.xx:39092 --describe --topic test-partitions
# create a topic with default partitions
kafka-topics --bootstrap-server xx.xx.xx.xx:39092 --create --topic test-def-partitions
kafka-topics --bootstrap-server xx.xx.xx.xx:39092 --describe --topic test-def-partitions
# alter the number of partitions of an existing topic
kafka-topics --bootstrap-server xx.xx.xx.xx:39092 --alter --topic test-def-partitions --partitions 3
@xsqian
xsqian / tf-with-gpu.sh
Last active August 13, 2021 04:26
install tensorflow with GPU support
#conda create an env
conda create -n py376-tf241 ipykernel python=3.7.6
conda activate py376-tf241
# find out current gpu avaliablity
import tensorflow as tf
print(tf.__version__)
print(tf.config.list_pysical_devices())
@xsqian
xsqian / docker-default-data-directory.sh
Created August 11, 2021 19:27
config docker default data directory to another location than /var/lib
sudo service docker stop
sudo vi /etc/docker/daemon.json
{
"data-root": "/path/to/your/docker"
}
sudo service docker start
@xsqian
xsqian / docker-compose-on-redhat-kafka.sh
Last active March 10, 2022 23:20
Install Docker, Docker Compose and Kafka on RedHat
sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
sudo dnf repolist -v
dnf list docker-ce --showduplicates | sort -r
sudo dnf install --nobest docker-ce
sudo systemctl disable firewalld
@xsqian
xsqian / docker-compose-on-linux
Created August 4, 2021 00:03
Install Docker and Docker Compose on linux (Ubuntu)
# install docker
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
@xsqian
xsqian / git-pre-commit-for-yapf
Created May 20, 2021 04:07
create a pre-commit yapf
cd .git/hooks
curl -o pre-commit.sh https://raw.githubusercontent.com/google/yapf/main/plugins/pre-commit.sh
chmod a+x pre-commit.sh
@xsqian
xsqian / grafana-api-to-export-import-datasource.sh
Created May 7, 2021 05:01
how to export and import datasource from Grafana using Grafana API
mkdir -p data_sources && curl -s "http://localhost:3000/api/datasources" -u admin:admin|jq -c -M '.[]'|split -l 1 - data_sources/
for i in data_sources/*; do \
curl -X "POST" "http://localhost:3000/api/datasources" \
-H "Content-Type: application/json" \
--user admin:admin \
--data-binary @$i
done
@xsqian
xsqian / sed_snippets.sh
Created May 5, 2021 16:35 — forked from lamb-mei/sed_snippets.sh
sed examples
##FILE SPACING:
# double space a file
sed G
# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
sed '/^$/d;G'
# triple space a file
@xsqian
xsqian / kompose-convert-docker-compose-to-kubernetes.sh
Created February 27, 2021 00:03
kompose convert docker-compose to kubernetes
1 launch.sh
2 curl -L https://github.com/kubernetes/kompose/releases/download/v1.9.0/kompose-linux-amd64 -o /usr/bin/kompose && chmod +x /usr/bin/kompose
3 kompose up
4 kubectl get deployment,svc,pods,pvc
5 kompose convert
6 ls
7 kubectl apply -f frontend-service.yaml,redis-master-service.yaml,redis-slave-service.yaml,frontend-deployment.yaml,redis-master-deployment.yaml,redis-slave-deployment.yaml
8 kompose --provider openshift convert
9 kompose convert -j
10 ls -l
kubectl -n kube-system get deployment coredns -o yaml | \
sed 's/allowPrivilegeEscalation: false/allowPrivilegeEscalation: true/g' | \
kubectl apply -f -