Skip to content

Instantly share code, notes, and snippets.

View Clivern's full-sized avatar

Ahmed Clivern

View GitHub Profile
@Clivern
Clivern / ruby.py
Last active October 23, 2021 20:33
Beginning Ruby From Novice to Professional Book
# Basic Syntax
x = 1
y = "Hello"
BEGIN {
puts "Start the thing"
}
END {
puts "End the thing"
@Clivern
Clivern / kafka.sh
Last active February 18, 2021 15:26
Run Kafka
#!/bin/bash
git clone https://github.com/wurstmeister/kafka-docker.git
cd kafka-docker
# Update KAFKA_ADVERTISED_HOST_NAME inside 'docker-compose.yml',
# For example, set it to 172.17.0.1
vim docker-compose.yml
docker-compose up -d
@Clivern
Clivern / local_k8s.sh
Created December 20, 2020 21:20
Build and run a kubernetes on linux server from a fork
# local_k8s.sh https://github.com/kubernetes/kubernetes.git master v1.20.2
# Install Docker
cd /tmp
# Install Docker
apt-get update
apt-get -y install make docker.io
systemctl enable docker
@Clivern
Clivern / gist:575d355ccdd16178ca1b9fa66e677790
Created December 17, 2020 23:15 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@Clivern
Clivern / revert-a-commit.md
Created December 2, 2020 22:50 — forked from gunjanpatel/revert-a-commit.md
Git HowTo: revert a commit already pushed to a remote repository

Revert the full commit

Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

git revert {commit_id}'

About History Rewriting

Delete the last commit

Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:

curl -s \
--form-string "token=$1" \
--form-string "user=$2" \
--form-string "title=$3" \
--form-string "sound=none" \
--form-string "message=$4" \
https://api.pushover.net/1/messages.json
package main
import (
"context"
"fmt"
"log"
"net/http"
"time"
)
@Clivern
Clivern / etcd.md
Created December 25, 2019 22:22
Etcd node on docker
export NODE1=127.0.0.1
docker volume create --name etcd-data
export DATA_DIR="etcd-data"
export REGISTRY=quay.io/coreos/etcd

docker run -d \
  -p 2379:2379 \
  -p 2380:2380 \
 --volume=${DATA_DIR}:/etcd-data \
@Clivern
Clivern / etcd_docker.md
Created December 24, 2019 21:23
Running etcd in Docker Containers
$ export PUBLIC_IP=54.196.167.255

$ docker run -d -p 8001:8001 -p 5001:5001 quay.io/coreos/etcd:v0.4.6 -peer-addr ${PUBLIC_IP}:8001 -addr ${PUBLIC_IP}:5001 -name etcd-node1

$ docker run -d -p 8002:8002 -p 5002:5002 quay.io/coreos/etcd:v0.4.6 -peer-addr ${PUBLIC_IP}:8002 -addr ${PUBLIC_IP}:5002 -name etcd-node2 -peers ${PUBLIC_IP}:8001,${PUBLIC_IP}:8002,${PUBLIC_IP}:8003

$ docker run -d -p 8003:8003 -p 5003:5003 quay.io/coreos/etcd:v0.4.6 -peer-addr ${PUBLIC_IP}:8003 -addr ${PUBLIC_IP}:5003 -name etcd-node3 -peers ${PUBLIC_IP}:8001,${PUBLIC_IP}:8002,${PUBLIC_IP}:8003

$ curl -L $PUBLIC_IP/v2/stats/leader
@Clivern
Clivern / cron.md
Created December 14, 2019 18:11
cron jobs
  • cron is a time based job scheduling service.
  • crontab a program for CRUD your jobs schedules.
  • use cron to schedule & automate tasks

image

0 2 * * * /root/db_backup > /tmp/db.log 2>&1