Skip to content

Instantly share code, notes, and snippets.

View theruziev's full-sized avatar
🎷
Jazz things

Bakhtiyor Ruziev theruziev

🎷
Jazz things
View GitHub Profile
@theruziev
theruziev / closer.go
Last active January 7, 2024 21:12
Closer in go. I wrote a blog post about this code snippet. https://theruziev.com/blog/post/closer-go
package closer
import (
"context"
"errors"
"sync"
)
type closer func(ctx context.Context) error
package logger
import (
"bytes"
"fmt"
"io"
"net/http"
"time"
"github.com/go-chi/chi/v5/middleware"
@theruziev
theruziev / 20min.sh
Created February 25, 2020 10:46
Cron for eyes
#!/bin/sh
eval "export $(egrep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -u $LOGNAME gnome-session)/environ)";
#Code:
DISPLAY=:0 notify-send "Wink wink"

Keybase proof

I hereby claim:

  • I am theruziev on github.
  • I am theruziev (https://keybase.io/theruziev) on keybase.
  • I have a public key ASBvONwp6Whi7sPJ-1J58112bmYW9tUiETVnqjronhE7Ego

To claim this, I am signing this object:

@theruziev
theruziev / clickhouse.sql
Last active June 21, 2019 15:35
Clickhouse TIPs
# Range date
SELECT toDate(toStartOfDay(toDate(toUnixTimestamp(now()) + (number * 86400)))) date FROM numbers(10);
@theruziev
theruziev / main.py
Created March 7, 2019 12:33
main.py
from aiohttp import web
async def handle(request):
name = request.match_info.get('name', "Anonymous")
text = "Hello, " + name
return web.Response(text=text)
app = web.Application()
app.add_routes([web.get('/', handle),
@theruziev
theruziev / aiohttp_fixture.py
Created November 13, 2018 08:09
aiohttp client fixture with pytest-asyncio compatibility
import pytest
from aiohttp.test_utils import TestServer, TestClient
@pytest.fixture
async def aio_client():
clients = []
async def factory(app):
server = TestServer(app)
@theruziev
theruziev / pypi.md
Created November 4, 2018 23:21 — forked from gboeing/pypi.md
How to organize and distribution a package on pypi

To distribute a package on pypi

Directory structure

/project/
    /package/
        __init__.py
        module.py
 setup.py
@theruziev
theruziev / README-Template.md
Created October 28, 2018 08:00 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@theruziev
theruziev / tokens.md
Created October 26, 2018 04:30 — forked from zmts/tokens.md
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Preconditions:

В данной заметке рассматривается работа JWT с симметичным алгоритмом шифрования (HS256/HS384/HS512)

Основы:

Аутентификация(authentication, от греч. αὐθεντικός [authentikos] – реальный, подлинный; от αὐθέντης [authentes] – автор) - это процесс проверки учётных данных пользователя (логин/пароль). Проверка подлинности пользователя путём сравнения введённого им логина/пароля с данными сохранёнными в базе данных.

Авторизация(authorization — разрешение, уполномочивание) - это проверка прав пользователя на доступ к определенным ресурсам.