Skip to content

Instantly share code, notes, and snippets.

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

amin jamal includeamin

🏠
Working from home
View GitHub Profile
@includeamin
includeamin / Dockerfile
Created November 27, 2020 12:36
fastapi Dockerfile
FROM python:3.8
LABEL maintainer="Sebastian Ramirez <tiangolo@gmail.com>"
RUN pip install --no-cache-dir uvicorn gunicorn
RUN pip install --no-cache-dir uvloop httptools websockets
COPY start.sh /start.sh
RUN chmod +x /start.sh
COPY gunicorn_conf.py /gunicorn_conf.py
@includeamin
includeamin / sample.py
Created October 27, 2020 10:11
Gunicorn and Uvicorn multi port binding
from fastapi import FastAPI
from starlette_exporter import PrometheusMiddleware, handle_metrics
external = FastAPI()
internal = FastAPI()
external.add_middleware(PrometheusMiddleware)
@external.get("/users/information")
@includeamin
includeamin / create-cert-and-key-with-certbot.sh
Created April 20, 2020 11:02 — forked from arastu/create-cert-and-key-with-certbot.sh
Configuring Harbor with HTTPS Access via letsencrypt(certbot with --standalone flag)
sudo certbot certonly --standalone -d registry.example.com
@includeamin
includeamin / readme.md
Last active December 9, 2019 22:54
docker registry with authentication
docker run -d \
  -p 5000:5000 \
  --restart=always \
  --name registry \
  -v "$(pwd)"/auth:/auth \
  -e "REGISTRY_AUTH=htpasswd" \
  -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \
  -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
 -e -e REGISTRY_STORAGE_DELETE_ENABLED=true \
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
X = np.array(
[[0.27090301, 0.4656891496],
[0.3080357143, 0.5970809376],
[0.3826666667, 0.6700470844],
@includeamin
includeamin / kuberntes-dashboard.md
Created November 12, 2019 14:20
access to kuberntes dashboard from public ip

Access to Kuberntes dashboard public ip

  1. install kuberntes dashboard

    kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
  2. Edit kubernetes service

@includeamin
includeamin / search.py
Created June 18, 2019 11:46
Search in list of dictionary
data = [{"id":2,"f":3},
{"id":3,'f':4}]
a = next(item for item in data if item["id"]==2)
print a
@includeamin
includeamin / dict_sum.py
Created June 18, 2019 11:21
sum of two same dictionary
one = {"XP": 5, "Gold": 5, "Rank": 2, "Diamond":5}
two = {"XP": 5, "Gold": 5, "Rank": 2, "Diamond":5}
sum_temp = {key:one[key]+two[key] for key in one.keys()}
@includeamin
includeamin / client.py
Last active June 16, 2019 08:44
Simple echo server python socket
# Echo client program
import socket
HOST = 'localhost'
PORT = 3003
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((HOST, PORT))
s.sendall(b'Hello, world')
data = s.recv(1024)
print('Received', repr(data))
@includeamin
includeamin / decorator.py
Last active June 12, 2019 11:39
python Decorator with arguments
#https://pybit.es/decorator-optional-argument.html
from functools import wraps
import time
def sleep(seconds=None):
def real_decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
print('Sleeping for {} seconds'.format(seconds))
time.sleep(seconds if seconds else 1)