Skip to content

Instantly share code, notes, and snippets.

View ridwanray's full-sized avatar
💭
I'm Always Learning and Implementing New Things

ridwanray

💭
I'm Always Learning and Implementing New Things
View GitHub Profile
https://www.odoo.com/documentation/17.0/developer/tutorials.html
https://www.odoo.com/documentation/17.0/developer/tutorials/server_framework_101.html
https://www.odoo.com/documentation/17.0/developer/tutorials/server_framework_101/01_architecture.html
https://www.odoo.com/documentation/17.0/
https://github.com/odoo/odoo
https://www.odoo.com/documentation/17.0/developer/tutorials/setup_guide.html
@ridwanray
ridwanray / assert_not_raises.py
Created July 28, 2024 12:04 — forked from oisinmulvihill/assert_not_raises.py
How to test a python exception is not raised with pytests
# Updated for python3
#
# https://stackoverflow.com/questions/20274987/how-to-use-pytest-to-check-that-error-is-not-raised/35458249#35458249
#
from contextlib import contextmanager
@contextmanager
def not_raises(ExpectedException):
try:
@ridwanray
ridwanray / typing_guide.py
Created July 17, 2024 16:24
Guide for Python Type Annotation
name : str = "Ray"
"""
age : int = 10
is_active : bool = True
length : float = 2.2
size : bytes = b"test"
"""
"""
#list
@ridwanray
ridwanray / decorators.py
Created May 3, 2024 17:30
Decorator embded in a function
def my_decorator(argument):
def actual_decorator(func):
def wrapper(*args, **kwargs):
print(f"Decorator argument: {argument}")
result = func(*args, **kwargs)
return result
return wrapper
return actual_decorator
@my_decorator("example_argument")
@ridwanray
ridwanray / gist:0950d9adf9f31edf1176d5e40dde4066
Last active February 25, 2024 10:54
WEBSOCKET NGIX SETTING
server {
server_name chat.example.com;
client_max_body_size 100M;
location /messaging/ {
proxy_pass http://127.0.0.1:9000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
@ridwanray
ridwanray / gist:7ed3a605336bd84bac341cc8310b8024
Created February 24, 2024 14:06
NGINX UNBIND ERROR FIX
sudo pkill -f nginx & wait $!
sudo systemctl start nginx
× nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2024-01-31 10:43:23 UTC; 3 weeks 3 days ago
Docs: man:nginx(8)
CPU: 54ms
@ridwanray
ridwanray / middleware_custom.py
Last active October 12, 2023 06:32
Custom Exception Middleware handler for django
import json
from django.conf import settings
from django.http import JsonResponse, HttpResponse
from sentry_sdk import capture_exception
class CaptureExceptionMiddleware:
def __init__(self, get_response):
@ridwanray
ridwanray / sonar-project.properties
Created August 9, 2023 13:54
Sonar properties sample
sonar.projectKey=User-Auth
sonar.sources=.
sonar.host.url=http://localhost:9000
sonar.token=sometoke
sonar.exclusions=**/venv/**,**/htmlcov/**,**/requirements/**,**/docker/**,**/k8s/**,**/migrations/**,**/tests/**,**/conftest.py
sonar.python.coverage.reportPaths=*coverage.xml
sonar.coverage.exclusions=**/tests/**,**/migrations/**,**/admin.py,**/apps.py,core/asgi.py,core/wsgi.py,manage.py
sonar.python.version=3
sonar.issue.ignore.multicriteria=nullmodel,emailtemplates
sonar.issue.ignore.multicriteria.nullmodel.ruleKey=python:S6553
@ridwanray
ridwanray / test_rabbit.py
Created July 24, 2023 16:02
Test Rabbit MQ connection string in Python
import pika
def test_rabbitmq_url(url):
try:
params = pika.URLParameters(url)
connection = pika.BlockingConnection(params)
connection.close()
print("Connection successful!")
except pika.exceptions.AMQPError as e:
print("Connection failed:", e)
@ridwanray
ridwanray / gist:49c974cc5ab5788364d9e6b886828d9b
Created June 15, 2023 08:05
List of bash alias for automation : located at ~/.bashrc
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias gc='git commit -m'
alias gits='git status'
alias gs='git status'
alias gp='git pull origin '
alias gh='git push'
alias ga='git add . && git status'