Skip to content

Instantly share code, notes, and snippets.

View alirezastack's full-sized avatar
🏠
Working from home

Alireza alirezastack

🏠
Working from home
View GitHub Profile
{
"bookingId": "8d7965d6-3851-41a5-b172-23e009865178,f0e36787-b5d8-42cf-8174-affdaa67661e",
"status": "success",
"createdAt": "2023-01-03",
"lastModifiedAt": "2023-01-03",
"expiresAt": "",
"hotelId": 432,
"currency": "IRR",
"bookingContact": {
"identificationNumber": "0708584160",
I0814 17:56:56.811508742 23612 call.cc:1922] grpc_call_start_batch(call=0x7fdff0003760, ops=0x7fdfdc01c290, nops=1, tag=0x7fdff95a8a98, reserved=(nil))
I0814 17:56:56.811519712 23612 call.cc:1526] ops[0]: RECV_MESSAGE ptr=0x7fdff95b8420
I0814 17:56:56.811524967 23612 call.cc:626] OP[server:0x7fdff00040f0]: RECV_MESSAGE
I0814 17:56:56.811527665 23612 channel_stack.cc:226] OP[message_size:0x7fdff0004108]: RECV_MESSAGE
I0814 17:56:56.811530447 23612 channel_stack.cc:226] OP[deadline:0x7fdff0004120]: RECV_MESSAGE
I0814 17:56:56.811533294 23612 channel_stack.cc:226] OP[http-server:0x7fdff0004138]: RECV_MESSAGE
I0814 17:56:56.811535821 23612 channel_stack.cc:226] OP[message_compress:0x7fdff0004150]: RECV_MESSAGE
I0814 17:56:56.811538324 23612 channel_stack.cc:226] OP[connected:0x7fdff0004168]: RECV_MESSAGE
I0814 17:56:56.811541338 23612 chttp2_transport.cc:1710] perform_stream_op[s=0x7fdff0004cd8]: RECV_MESSAGE
I0814
@alirezastack
alirezastack / grpc-server
Created August 14, 2019 13:18
gRPC server
_DEFAULT_SERVICE_HOST = '[::]'
_DEFAULT_SERVICE_PORT = '9000'
_SERVER_SHUTDOWN_DEFAULT_TIMEOUT = 15
class GRPCServerBase:
def __init__(self, service, app):
self.service_name = service.upper()
alireza@alireza-pc:~/go$ go get -x -u github.com/micro/micro
mkdir -p /home/alireza/go/pkg/mod/cache/vcs # git2 https://github.com/micro/micro
# lock /home/alireza/go/pkg/mod/cache/vcs/84b7fd5a6fde223b4ec1c11e231552052e2f254fb38739f64fcf0c03731e7f1c.lock# /home/alireza/go/pkg/mod/cache/vcs/84b7fd5a6fde223b4ec1c11e231552052e2f254fb38739f64fcf0c03731e7f1c for git2 https://github.com/micro/micro
cd /home/alireza/go/pkg/mod/cache/vcs/84b7fd5a6fde223b4ec1c11e231552052e2f254fb38739f64fcf0c03731e7f1c; git ls-remote -q https://github.com/micro/micro
1.123s # cd /home/alireza/go/pkg/mod/cache/vcs/84b7fd5a6fde223b4ec1c11e231552052e2f254fb38739f64fcf0c03731e7f1c; git ls-remote -q https://github.com/micro/micro
mkdir -p /home/alireza/go/pkg/mod/cache/vcs # git2 https://github.com/coreos/etcd
# lock /home/alireza/go/pkg/mod/cache/vcs/e0603d6b678c67453e2d85ba58d5dd0030d8a3ed443832680252eb8f82272b52.lockmkdir -p /home/alireza/go/pkg/mod/cache/vcs # git2 https://github.com/micro/cli
# lock /home/alireza/go/pkg/mod/cache/vcs/
alireza@alireza-pc:~/Downloads/GoLand-2019.1.3/bin$ go get -x -u github.com/micro/micro
mkdir -p /home/alireza/go/pkg/mod/cache/vcs # git2 https://github.com/micro/micro
# lock /home/alireza/go/pkg/mod/cache/vcs/84b7fd5a6fde223b4ec1c11e231552052e2f254fb38739f64fcf0c03731e7f1c.lock# /home/alireza/go/pkg/mod/cache/vcs/84b7fd5a6fde223b4ec1c11e231552052e2f254fb38739f64fcf0c03731e7f1c for git2 https://github.com/micro/micro
cd /home/alireza/go/pkg/mod/cache/vcs/84b7fd5a6fde223b4ec1c11e231552052e2f254fb38739f64fcf0c03731e7f1c; git ls-remote -q https://github.com/micro/micro
1.188s # cd /home/alireza/go/pkg/mod/cache/vcs/84b7fd5a6fde223b4ec1c11e231552052e2f254fb38739f64fcf0c03731e7f1c; git ls-remote -q https://github.com/micro/micro
mkdir -p /home/alireza/go/pkg/mod/cache/vcs # git2 https://github.com/coreos/etcd
# lock /home/alireza/go/pkg/mod/cache/vcs/e0603d6b678c67453e2d85ba58d5dd0030d8a3ed443832680252eb8f82272b52.lock# /home/alireza/go/pkg/mod/cache/vcs/e0603d6b678c67453e2d85ba58d5dd0030d8a3ed443832680252eb8f82
@alirezastack
alirezastack / vim-nginx-conf-highlight.sh
Created July 9, 2018 17:25 — forked from ralavay/vim-nginx-conf-highlight.sh
Enable syntax highlight for Nginx conf file in Vim (Mac OS X)
#!/bin/bash
#
# Highligh Nginx config file in Vim
# Download syntax highlight
mkdir -p ~/.vim/syntax/
wget http://www.vim.org/scripts/download_script.php?src_id=19394 -O ~/.vim/syntax/nginx.vim
# Set location of Nginx config file
cat > ~/.vim/filetype.vim <<EOF
@alirezastack
alirezastack / backup_mongodb.sh
Created June 25, 2018 12:38
MongoDB shell script backup using mongodump
#!/bin/bash
#
## mongoDB backup script
## usage
## mongo-backup.sh port host backup.dir
temp_backup_dir="/tmp"
default_backup_dir="/data/backup/mongo"
host=${1:-"127.0.0.1"}
@alirezastack
alirezastack / backup_redis_rdb.sh
Last active April 24, 2024 08:11
Backup Redis RDB file - BASH Script
#!/bin/bash
#
## redis backup script
## usage
## redis-backup.sh port backup.dir
## Redis is very data backup friendly since you can copy RDB files while the database is running: the RDB is never modified once produced, and while it gets produced it uses a temporary name and is renamed into its final destination atomically using rename(2) only when the new snapshot is complete.
# Scripts & Files
rdb="/var/spool/alohi/storage/redis/dump.rdb"
@alirezastack
alirezastack / generate_mongodb_certificate.sh
Last active June 11, 2018 12:12
Use this script to create a self signed certificate for your MongoDB instance
#! /bin/bash
# Generate self signed root CA cert
openssl req -nodes -x509 -days 3650 -newkey rsa:2048 -keyout ca.key -out ca.crt -subj "/C=IR/ST=TEH/L=Tehran/O=MongoDB/ OU=root/CN=mongo.your_domain.com/emailAddress=info@your_domain.com"
# Generate server cert to be signed
openssl req -nodes -newkey rsa:2048 -days 3650 -keyout server.key -out server.csr -subj "/C=IR/ST=TEH/L=Tehran/ O=MongoDB/OU=server/CN=mongo.your_domain.com/emailAddress=info@your_domain.com"
# Sign the server cert
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt
@alirezastack
alirezastack / long_running_loop.py
Created January 17, 2018 11:05
Gracefully kill python script using signal module
import signal
import time
class GracefulKiller:
kill_now = False
def __init__(self):
signal.signal(signal.SIGINT, self.exit_gracefully)
signal.signal(signal.SIGTERM, self.exit_gracefully)
def exit_gracefully(self,signum, frame):