Skip to content

Instantly share code, notes, and snippets.

View Hedgehogues's full-sized avatar
🎯
Focusing

Egor Hedgehogues

🎯
Focusing
View GitHub Profile
package main
//#include <unistd.h>
import "C"
import (
"context"
"log"
"math/rand"
"runtime"
@nkhitrov
nkhitrov / logger.py
Last active March 18, 2025 12:43
Configure uvicorn logs with loguru for FastAPI
"""
WARNING: dont use loguru, use structlog
https://gist.github.com/nkhitrov/38adbb314f0d35371eba4ffb8f27078f
Configure handlers and formats for application loggers.
"""
import logging
import sys
from pprint import pformat
@thomwolf
thomwolf / attention_layer_pytorch.py
Last active January 25, 2021 00:51
A pyTorch attention layer for torchMoji model
class Attention(Module):
"""
Computes a weighted average of channels across timesteps (1 parameter pr. channel).
"""
def __init__(self, attention_size, return_attention=False):
""" Initialize the attention layer
# Arguments:
attention_size: Size of the attention vector.
return_attention: If true, output will include the weight for each input token
used for the prediction
@bradrydzewski
bradrydzewski / generate_docker_cert.sh
Last active February 14, 2025 07:04
Generate trusted CA certificates for running Docker with HTTPS
#!/bin/bash
#
# Generates client and server certificates used to enable HTTPS
# remote authentication to a Docker daemon.
#
# See http://docs.docker.com/articles/https/
#
# To start the Docker Daemon:
#
# sudo docker -d \