Skip to content

Instantly share code, notes, and snippets.

View kmaksimovv's full-sized avatar

Konstantin Maksimov kmaksimovv

  • Russian Federation
View GitHub Profile
<!-- <form action="" method="post">
{{ form.csrf_token() }}
{% for field in form if field.name != "csrf_token" %}
{{ field.label() }}
{{ field }}
<br>
{% endfor %}
<button type="submit">поиск</button>
</form> -->
@kmaksimovv
kmaksimovv / gist:557eabde7af556ca68037089e1684306
Last active January 27, 2020 13:38
postgress_setup_ubuntu
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
sudo -u postgres psql
create user username with password 'password';
create database vscale_db;
grant all privileges on database vscale_db to username;
\q
@kmaksimovv
kmaksimovv / qna_monit_config
Created May 20, 2019 14:32
qna_monit_config
### 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 188.68.209.3 port 80 protocol http
then restart
if 3 restarts within 5 cycles then timeout
@kmaksimovv
kmaksimovv / fix _test_guru_sql
Last active September 22, 2018 21:06
fix _test_guru_sql
############
#В имени поля не нужно дублировать имя таблицы
test_guru=> \d categories
Table "public.categories"
Column | Type | Modifiers
----------------+-----------------------+---------------------------------------------------------
id | integer | not null default nextval('categories_id_seq'::regclass)
category_title | character varying(20) | not null
Indexes:
@kmaksimovv
kmaksimovv / test_guru_sql
Last active September 21, 2018 14:58
test_guru_sql
# create database
postgres=# CREATE DATABASE test_guru;
CREATE DATABASE
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | ru_RU.UTF-8 | ru_RU.UTF-8 |
template0 | postgres | UTF8 | ru_RU.UTF-8 | ru_RU.UTF-8 | =c/postgres +
@kmaksimovv
kmaksimovv / post_query_and_asnwer
Last active September 17, 2018 15:35
post_query_and_asnwer
ncat -C httpbin.org 80
POST /anything HTTP/1.1
Host: httpbin.org
Content-Length: 9
test=TEST
HTTP/1.1 200 OK
Connection: keep-alive
Server: gunicorn/19.9.0
Date: Mon, 17 Sep 2018 15:32:49 GMT
@kmaksimovv
kmaksimovv / get_and_post_query_and_asnwer
Last active September 17, 2018 08:54
get_and_post_query_and_asnwer
#1.GET request without parameters
ncat -C httpbin.org 80
GET /anything HTTP/1.1
Host: httpbin.org
HTTP/1.1 200 OK
Connection: keep-alive
Server: gunicorn/19.9.0
Date: Mon, 17 Sep 2018 08:00:01 GMT
Content-Type: application/json