Skip to content

Instantly share code, notes, and snippets.

View jtprogru's full-sized avatar
🦄
Make a rainbow shit

Michael Savin jtprogru

🦄
Make a rainbow shit
View GitHub Profile
@jtprogru
jtprogru / main.go
Created April 26, 2024 19:46
Напиши веб сервер (порт :3333) - счетчик который будет обрабатывать GET (/count) и POST (/count) запросы: GET: возвращает счетчик POST: увеличивает ваш счетчик на значение (с ключом "count") которое вы получаете из формы, но если пришло НЕ число то нужно ответить клиенту: "это не число" со статусом http.StatusBadRequest (400).
package main
// некоторые импорты нужны для проверки
import (
"fmt"
"io"
"log"
"net/http"
"net/url"
"os"
"time"
# `python-base` sets up all our shared environment variables
FROM python:3.8.1-slim as python-base
# python
ENV PYTHONUNBUFFERED=1 \
# prevents python creating .pyc files
PYTHONDONTWRITEBYTECODE=1 \
\
# pip
PIP_NO_CACHE_DIR=off \
@jtprogru
jtprogru / requirements.txt
Last active July 5, 2023 17:47
Public requirements for any Ansible roles
ansible==7.5.0
ansible-core==2.14.5
ansible-lint==6.17.1
black==23.3.0
jmespath==1.0.1
yamllint==1.31.0
gui:
authorColors:
"*": "#11aaff" # use red for all
"Michael Savin": "#00ff00" # use green for me
"jtprogru": "#00ff00" # use green for me
scrollHeight: 2 # how many lines you scroll by
scrollPastBottom: true # enable scrolling past the bottom
sidePanelWidth: 0.33 # number from 0 to 1
mainPanelSplitMode: "flexible" # one of 'horizontal' | 'flexible' | 'vertical'
language: "en" # one of 'auto' | 'en' | 'zh' | 'pl' | 'nl' | 'ja' | 'ko'
@jtprogru
jtprogru / Taskfile.yaml
Last active June 22, 2023 20:35
Simple task file for Golang project
# yaml-language-server: $schema=https://taskfile.dev/schema.json
---
version: "3"
set:
- pipefail
silent: false
tasks:
@jtprogru
jtprogru / vimrc
Created March 22, 2023 12:28
Default .vimrc for any servers
" Disable compatibility with vi which can cause unexpected issues.
set nocompatible
" Enable type file detection. Vim will be able to try to detect the type of file in use.
filetype on
" Enable plugins and load plugin for the detected file type.
filetype plugin on
" Load an indent file for the detected file type.
@jtprogru
jtprogru / main.py
Last active February 15, 2023 17:46
#!/usr/bin/env python3
"""
cat /var/log/nginx/access.log | sed -n '/2022:02:20/,/2022:02:23/p'| awk '{print $1}' | sort | uniq -c | sort -n | less
###
start_datetime = "15/Feb/2023:19:20"
end_datetime = "15/Feb/2022:02:23"
"""
def func_name_read_datetime_start_end():
@jtprogru
jtprogru / Dockerfile
Created December 23, 2022 15:40
Basic Dockerfile for running Ansible
FROM python:3.10-slim AS compile-image
ENV PY_COLORS=1
ENV ANSIBLE_FORCE_COLOR=true
RUN apt-get update
RUN apt-get install -y --no-install-recommends build-essential gcc curl unzip
RUN curl https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o awscliv2.zip \
&& unzip awscliv2.zip \
&& ./aws/install --bin-dir /aws-cli-bin/
@jtprogru
jtprogru / Makefile
Last active August 26, 2022 20:39
Simple Makefile for Golang project
SHELL := /bin/bash
.SILENT:
.DEFAULT_GOAL := help
# Global vars
export SYS_GO=$(shell which go)
export SYS_GOFMT=$(shell which gofmt)
export SYS_DOCKER=$(shell which docker)
export BINARY_DIR=dist

Пул обработчиков

Продолжаем работать с функциями-говорилками. На предыдущем шаге мы заставили их обрабатывать исходные данные в две горутины, с помощью пула:

func main() {
    phrases := []string{
        // ...
    }