Skip to content

Instantly share code, notes, and snippets.

@beglov
beglov / HTTP.txt
Last active February 18, 2020 17:28
GET /anything HTTP/1.1
Host: httpbin.org
HTTP/1.1 200 OK
Date: Tue, 18 Feb 2020 17:21:04 GMT
Content-Type: application/json
Content-Length: 285
Connection: keep-alive
Server: gunicorn/19.9.0
Access-Control-Allow-Origin: *
@beglov
beglov / SQL
Last active February 20, 2020 20:28
1. С помощью SQL (DDL):
Создайте базу данных test_guru
CREATE DATABASE test_guru;
Таблицу categories с атрибутом title
CREATE TABLE categories (
id serial PRIMARY KEY,
title varchar(30) NOT null
);
@beglov
beglov / hello_world.py
Created March 19, 2020 12:40
Hello World Examples
class HelloWorld:
def __init__(self, name):
self.name = name.capitalize()
def sayHi(self):
print "Hello " + self.name + "!"
hello = HelloWorld("world")
hello.sayHi()
@beglov
beglov / rubocop_pre_commit_hook
Created May 22, 2020 09:29 — forked from palkan/rubocop_pre_commit_hook
Rubocop pre-commit hook
#!/usr/bin/env ruby
ADDED_OR_MODIFIED = /^\s*(A|AM|M)/.freeze
changed_files = `git status --porcelain`.split(/\n/)
unstaged_files = `git ls-files -m`.split(/\n/)
changed_files = changed_files.select { |f| f =~ ADDED_OR_MODIFIED }
changed_files = changed_files.map { |f| f.split(" ")[1] }
@beglov
beglov / tms
Last active September 2, 2021 12:28
Monit rules for typical rails app
### Nginx ###
check process nginx with pidfile /run/nginx.pid
start program = "/usr/sbin/service nginx start"
stop program = "/usr/sbin/service nginx stop"
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if memory usage > 80% for 5 cycles then restart
if failed host localhost port 80 protocol http
then restart
if 3 restarts within 5 cycles then timeout
@beglov
beglov / tms.conf
Last active October 15, 2020 09:29
Nginx config for rails app with Puma
upstream application_server {
server unix:/home/deploy/tms/shared/tmp/sockets/puma.sock fail_timeout=0;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
@beglov
beglov / tms.conf
Last active August 18, 2020 18:41
Nginx config for rails app with Unicorn
upstream unicorn {
server unix:/home/deploy/tms/shared/tmp/sockets/unicorn.sock fail_timeout=0;
}
server {
listen 80;
listen [::]:80;
server_name ec2-3-134-77-212.us-east-2.compute.amazonaws.com;
@beglov
beglov / tms.conf
Created August 18, 2020 13:28
Nginx config for rails app with Passenger
server {
listen 80;
listen [::]:80;
server_name ec2-3-134-77-212.us-east-2.compute.amazonaws.com;
root /home/deploy/tms/current/public;
access_log /home/deploy/tms/current/log/nginx.access.log;
error_log /home/deploy/tms/current/log/nginx.error.log info;
@beglov
beglov / qna_test
Created September 17, 2020 07:07
Gist for qna tests purpose
Hello world!
@beglov
beglov / gost_engine.sh
Last active May 27, 2021 12:46 — forked from shadz3rg/gost_engine.sh
Настройка ГОСТ OpenSSL под Ubuntu 18.04
# устанавливаем ГОСТ-овское шифрование
sudo apt install libengine-gost-openssl1.1
# правим конфиг
sudo nano /etc/ssl/openssl.cnf
# в начало файла
openssl_conf = openssl_def
# в конец