Skip to content

Instantly share code, notes, and snippets.

View katoozi's full-sized avatar
🏡
Working from home

mohammad katoozi katoozi

🏡
Working from home
  • Tehran, Iran
View GitHub Profile
@katoozi
katoozi / gist:1dcd8297d028f82a279fc849f9b0303d
Created March 27, 2024 08:45 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@katoozi
katoozi / gist:307fec6e5b0b8e47987a866b2eea49c9
Created July 6, 2021 16:14 — forked from bakins/gist:5bf7d4e719f36c1c555d81134d8887eb
prometheus - scrape multiple containers in a pod
# Example scrape config for pods
#
# The relabeling allows the actual pod scrape endpoint to be configured via the
# following annotations:
#
# * `prometheus.io/scrape`: Only scrape pods that have a value of `true`
# * `prometheus.io/path`: If the metrics path is not `/metrics` override this. This
# will be the same for every container in the pod that is scraped.
# * this will scrape every container in a pod with `prometheus.io/scrape` set to true and the
port is name `metrics` in the container
@katoozi
katoozi / api.ts
Last active June 21, 2020 08:16
react native api module with axios
import axios, { AxiosInstance, ResponseType, Method, AxiosResponse, AxiosRequestConfig } from 'axios';
import { storeData, getData } from '../helpers';
export const STORAGE_TOKEN_KEY_NAME = 'token';
const PROTOCOL = 'https://'; // protocols: 'http', 'https'
const BASE_URL = 'example.com/'; // include just domain or sub domain and domain name.
const LEVEL_ONE_ENDPOINT = 'api/v1/'; // first level uri. include versioning etc.
const TOKEN_PRIFIX = 'token '; // do not remove the space. samples: token, Bearer, etc.
@katoozi
katoozi / arrays.ts
Created June 21, 2020 08:11
react native hook and context helpers
/**
createArraySubsets generate array subsets.
@param {Array} array - source array.
@param {number} subsets - number of subsets. default is 2
@returns array with number of given subsets.
@example
createArraySubsets([1,2,3,4,5,6,7,8], 2); // output: [[1,2],[3,4],[5,6],[7,8]]
createArraySubsets([1,2,3,4], 3); // output: [[1,2,3], [4]]
createArraySubsets([1,2,3,4,5,6,7,8], 4); // output: [[1,2,3,4], [5,6,7,8]]
*/
@katoozi
katoozi / .gitlab-ci.yml
Created June 21, 2020 06:59
gitlab ci for golang. "^coverage:\s(\d+(?:\.\d+)?%)" Test coverage parsing
image: golang:1.14
stages:
- test
before_script:
- mkdir -p /go/src/gitlab.com
- ln -s /builds/user /go/src/gitlab.com/user
coverage:
stage: test
script:
- apk add --no-cache git build-base
@katoozi
katoozi / crontab
Last active August 21, 2020 15:21
postgresql daily backup at 1:00 AM
0 1 * * * /backups/backup.sh >/dev/null 2>&1
@katoozi
katoozi / clean_untagged_docker_images.sh
Created April 12, 2020 18:21
delete docker none images(untagged images)
#!/bin/bash
RED='\033[0;31m'
NC='\033[0m'
clean_untagged_docker_images(){
noneImages="$(docker images | grep "^<none>" | awk '{print $3}')"
if [ "$noneImages" != "" ]; then
docker images | grep "^<none>" | awk '{print $3}' | while read line; do
{
@katoozi
katoozi / start_django.sh
Last active June 26, 2020 12:34
start django application inside a docker image
#!/bin/sh
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
start_django(){
echo -e "${GREEN}-----------Start Collecting Static Files.--------------${NC}"
python manage.py collectstatic --no-input
echo -e "\n${GREEN}-----------Done Collecting Static Files.---------------${NC}\n"
@katoozi
katoozi / connect.sh
Created September 5, 2019 08:56
ipsec vpn connection script. work with https://github.com/hwdsl2/setup-ipsec-vpn
#!/usr/bin/env bash
# output text colors
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
detect_current_connection(){
result="$(ip route | grep 'default dev ppp' | awk '{print $3}')"
}
@katoozi
katoozi / django_dump_data.sh
Last active June 14, 2020 19:21
Django Backup Command
python3 manage.py dumpdata --natural-foreign --exclude auth.permission --exclude contenttypes --exclude admin.LogEntry --exclude sessions > db.json