Skip to content

Instantly share code, notes, and snippets.

View akrisanov's full-sized avatar

Andrey Krisanov akrisanov

View GitHub Profile
@akrisanov
akrisanov / decimal_places.py
Last active November 5, 2020 05:49
hyperskill.org – Python
# Round the number from input to the required number of decimals.
#
# The input format:
# Two lines: the first with a floating-point number, the second with an integer representing the decimal count.
#
# The output format:
# A formatted string containing the rounded number.
number = float(input())
precision = int(input())
@akrisanov
akrisanov / Dockerfile
Created September 29, 2020 21:23
Dockerize Go App
FROM golang:1.13.6-stretch AS builder
RUN apt-get update && apt-get install git ca-certificates && update-ca-certificates
ENV GO111MODULE=on\
CGO_ENABLED=0
WORKDIR /build
# Cache go modules – they don't change much often
@akrisanov
akrisanov / pgex.md
Last active April 7, 2022 20:43
Postgres Intro Exercises

Postgres Intro Exercises

Простые запросы

Задача #1

Кто летел позавчера рейсом Москва (SVO) — Новосибирск (OVB) на месте 1A, и когда он забронировал свой билет?

select t.passenger_name,

pprof

$ go test -bench=. -benchmem -cpuprofile=cpu.out -memprofile=mem.out -x .

$ go tool pprof 13_pprof_console.test cpu.out

$ go tool pprof 13_pprof_console.test mem.out
@akrisanov
akrisanov / cURL.md
Created August 22, 2020 13:41
cURL Cheatsheet
$ curl -I --http2 --insecure https://localhost:8080/
@akrisanov
akrisanov / formatting.md
Last active August 16, 2020 17:20
Go: Formatting

Основные флаги форматирования в Go

Общие

  • %v – представление по умолчанию для типа
  • %#v – вывести как Go код (удобно для структур)
  • %T – вывести тип переменной
  • %% - вывести символ %

Целые

@akrisanov
akrisanov / conftest1.py
Created May 4, 2020 18:19
Pytest Fixtures
import pytest
# Environment Variables
@pytest.fixture(autouse=True)
def env_setup(monkeypatch):
monkeypatch.setenv('MY_SETTING', 'some-value')
@akrisanov
akrisanov / sprint3_1.py
Last active April 18, 2023 17:45
Yandex.Praktikum 🍂
import pandas as pd
data = pd.read_csv("/datasets/visits.csv", sep="\t")
data['local_time'] = (
pd.to_datetime(data['date_time'], format='%Y-%m-%dT%H:%M:%S')
+ pd.Timedelta(hours=3)
)
data['date_hour'] = data['local_time'].dt.round('1H')
data['too_fast'] = data['time_spent'] < 60
data['too_slow'] = data['time_spent'] > 1000