Skip to content

Instantly share code, notes, and snippets.

View favtuts's full-sized avatar

FavTuts favtuts

View GitHub Profile
@favtuts
favtuts / aspnet-core-mvc.md
Last active April 1, 2025 09:21
ASPNET CORE MVC Notes

Using Serilog

Cần cấu hình để ưng dụng ASP.NET Core MVC ghi log ra file?

Để cấu hình ứng dụng ASP.NET Core MVC ghi log ra file, bạn có thể sử dụng Serilog – một thư viện logging phổ biến trong .NET. Dưới đây là hướng dẫn chi tiết:

1. Cài đặt Serilog

Trước tiên, bạn cần cài đặt các gói NuGet:

dotnet add package Serilog.AspNetCore
dotnet add package Serilog.Sinks.File
@favtuts
favtuts / go-stdlib-interface-selected.md
Created August 30, 2024 02:22 — forked from asukakenji/go-stdlib-interface-selected.md
Go (Golang) Standard Library Interfaces (Selected)

Go (Golang) Standard Library Interfaces (Selected)

This is not an exhaustive list of all interfaces in Go's standard library. I only list those I think are important. Interfaces defined in frequently used packages (like io, fmt) are included. Interfaces that have significant importance are also included.

All of the following information is based on go version go1.8.3 darwin/amd64.

@favtuts
favtuts / installing_multiple_version_of_go.png
Created August 23, 2024 10:20 — forked from Rezwanul-Haque/installing_multiple_version_of_go.png
Installing Multiple Version of Golang Using GoEnv
installing_multiple_version_of_go.png
go mod edit -module {NEW_MODULE_NAME}
-- rename all imported module
find . -type f -name '*.go' \
-exec sed -i -e 's,{OLD_MODULE},{NEW_MODULE},g' {} \;
@favtuts
favtuts / lru_cache.py
Last active February 23, 2022 08:30
Python cache using LRU_cache from functools standard library. More details on blog post: https://www.favtuts.com/every-python-programmer-should-know-lru_cache-from-the-standard-library/
from functools import lru_cache
from datetime import datetime
@lru_cache(maxsize=None)
def fib_cache(n):
if n < 2:
return n
return fib_cache(n-1) + fib_cache(n-2)
def fib_no_cache(n):
@favtuts
favtuts / retry-decorator.py
Last active February 22, 2022 04:45
Python retry decorator implements simple retry pattern with exponential backoff algorithm. More details on blog post: https://www.favtuts.com/retry-decorator-as-python-utility-to-protect-unexpected-one-off-exceptions-while-calling-apis/
from asyncio.log import logger
from functools import wraps
import time
import logging
import random
logger = logging.getLogger(__name__)
def log(msg, logger = None):
if logger: