Skip to content

Instantly share code, notes, and snippets.

@MikeVL
MikeVL / generate-pg-ssl.md
Created September 24, 2023 17:18 — forked from achesco/generate-pg-ssl.md
Generate self-signed SSL certificates for PostgreSQL server and client

CNs are important!!! -days 3650

Create a Certificate Signing Request (CN=localhost)

umask u=rw,go= && openssl req -days 3650 -new -text -nodes -subj '/C=US/ST=Massachusetts/L=Bedford/O=Personal/OU=Personal/emailAddress=example@example.com/CN=localhost' -keyout server.key -out server.csr

Generate self-signed certificate

umask u=rw,go= && openssl req -days 3650 -x509 -text -in server.csr -key server.key -out server.crt
@MikeVL
MikeVL / models.py
Last active April 5, 2020 11:22
Django SearchVectorField
class Message(models.Model):
search_vector = SearchVectorField(null=True, editable=False)
def save(self, force_insert=False, force_update=False, using=None, update_fields: list=None):
if update_fields is not None and any(e in update_fields for e in ['subject', 'message']):
update_fields.append('search_vector')
self.search_vector = \
SearchVector('subject', config='russian', rank='A') + \
SearchVector('message', config='russian', rank='B')
@MikeVL
MikeVL / sysctl.conf
Created January 5, 2020 08:19 — forked from kgriffs/sysctl.conf
Linux Web Server Kernel Tuning
# Configuration file for runtime kernel parameters.
# See sysctl.conf(5) for more information.
# See also http://www.nateware.com/linux-network-tuning-for-2013.html for
# an explanation about some of these parameters, and instructions for
# a few other tweaks outside this file.
#
# See also: https://gist.github.com/kgriffs/4027835
#
# Assumes a beefy machine with lots of network bandwidth
@MikeVL
MikeVL / 99-sysctl.conf
Created January 5, 2020 08:19 — forked from Scumtron/99-sysctl.conf
/etc/sysctl.d/99-sysctl.conf
# Kernel sysctl configuration file for Linux
# Version 1.11 - 2015-07-07
# Aysad Kozanoglu Aysad K.
# This file should be saved as /etc/sysctl.conf and can be activated using the command:
# sysctl -e -p /etc/sysctl.conf
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and sysctl.conf(5) for more details.
#
# Tested with: Ubuntu 14.04 LTS kernel version 3.13
# Debian 7 kernel version 3.2
@MikeVL
MikeVL / ansible-summary.md
Created March 23, 2019 18:39 — forked from andreicristianpetcu/ansible-summary.md
This is an ANSIBLE Cheat Sheet from Jon Warbrick

An Ansible summary

Jon Warbrick, July 2014, V3.2 (for Ansible 1.7)

Configuration file

intro_configuration.html

First one found from of

@MikeVL
MikeVL / postgresql_date_function_index_howto.md
Created December 20, 2018 14:04 — forked from cobusc/postgresql_date_function_index_howto.md
Short explanation of the issues faced when trying to create a PostgreSQL index using the date() function and how to resolve it.

Given a table...

CREATE TABLE foo (
  id SERIAL PRIMARY KEY,
  created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
  ...
);
@MikeVL
MikeVL / search.py
Last active July 9, 2018 09:28
Как сделать поиск по нескольким моделям данных
# https://evileg.com/ru/post/364/
from django.shortcuts import render
from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage
from django.views import View
from .models import Article, Comment, Topic, Post
class ESearchView(View):
@MikeVL
MikeVL / gist:90dee880d118fec8e1c2723cc3ca0334
Created August 25, 2017 14:10 — forked from jfrost/gist:6584871
PostgreSQL query: completely unused indexes
-- Completely unused indexes:
SELECT relid::regclass as table, indexrelid::regclass as index
, pg_size_pretty(pg_relation_size(indexrelid))
FROM pg_stat_user_indexes
JOIN pg_index
USING (indexrelid)
WHERE idx_scan = 0
AND indisunique IS FALSE order by pg_relation_size(indexrelid);
@MikeVL
MikeVL / ussr_bu.md
Last active July 30, 2018 17:10
Юбилейные монеты СССР - АЦ(у)

3. СТО ЛЕТ СО ДНЯ РОЖДЕНИЯ В.И. ЛЕНИНА

  • 3.15 ЛС: шт. 2. ОС: шт. К. Гурт: 2.1.
  • 3.16 ЛС: шт. 2. ОС: шт. Л. Гурт: 2.1.
  • 3.19 ЛС: шт. 3. ОС: шт. Л. Гурт: 2.1.
  • 3.20 ЛС: шт. 3. ОС: шт. Л. Гурт: 2.2.

4. ТРИДЦАТЬ ЛЕТ ПОБЕДЫ В ВЕЛИКОЙ ОТЕЧЕСТВЕННОЙ ВОЙНЕ

  • 4.2 ЛС: шт. 1.1. ОС: шт. Б. Луч упирается в правую часть буквы «Д», завиток буквы «Д» в знаке монетного двора. Гурт: 4.1.
@MikeVL
MikeVL / ussr.md
Last active July 30, 2018 18:20
Юбилейные монеты СССР - АЦ(о)

1. ДВАДЦАТЬ ЛЕТ ПОБЕДЫ НАД ФАШИСТСКОЙ ГЕРМАНИЕЙ

  • 1.2 ЛС: шт. 1. ОС: шт. Б. Голова под промежутком между буквами «И» и «С». Апостроф в «Й» мелкий. Гурт: 1.1.1

2. ПЯТЬДЕСЯТ ЛЕТ СОВЕТСКОЙ ВЛАСТИ

  • 2.5 ЛС: шт. 1. Зерна колосьев мелкие, гребенка остей справа с уступом, крайние слева стебли между витками в виде точек. ОС: шт. А. Молот не касается серпа, треугольник внизу большой. Гурт: 3.1.1. Буквы в словах сближены.
  • 2.6 ЛС: шт. 2. То же, что шт.1, но гребенка остей справа без уступа. ОС: шт. А. Гурт: 3.1.1

3. СТО ЛЕТ СО ДНЯ РОЖДЕНИЯ В.И. ЛЕНИНА