Skip to content

Instantly share code, notes, and snippets.

View protasovse's full-sized avatar

Sergey Protasov protasovse

  • РН-БашНИПИнефть
  • Уфа
View GitHub Profile
@marcorichetta
marcorichetta / postgresql-manjaro.md
Last active June 2, 2024 19:31
Install PostgreSQL on Manjaro and set it up for Django
@mbrochh
mbrochh / 01_utils.py
Last active September 24, 2023 10:45
Using pagination with Django, graphene and Apollo
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
# First we create a little helper function, becase we will potentially have many PaginatedTypes
# and we will potentially want to turn many querysets into paginated results:
def get_paginator(qs, page_size, page, paginated_type, **kwargs):
p = Paginator(qs, page_size)
try:
page_obj = p.page(page)
except PageNotAnInteger:
@volure
volure / SSH: Self Sign Postfix
Last active September 22, 2023 17:49
Create a Self Signed Postfix Certificate
# copied from https://www.e-rave.nl/create-a-self-signed-ssl-key-for-postfix
openssl genrsa -des3 -out mail.domain.tld.key 2048
chmod 600 mail.domain.tld.key
openssl req -new -key mail.domain.tld.key -out mail.domain.tld.csr
openssl x509 -req -days 365 -in mail.domain.tld.csr -signkey mail.domain.tld.key -out mail.domain.tld.crt
openssl rsa -in mail.domain.tld.key -out mail.domain.tld.key.nopass
mv mail.domain.tld.key.nopass mail.domain.tld.key
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650
chmod 600 mail.domain.tld.key
@jfromaniello
jfromaniello / gist:8418116
Last active September 19, 2023 23:38
Example of authenticating websockets with JWTs.
var WebSocketServer = require('ws').Server;
var wss = new WebSocketServer({port: 8080});
var jwt = require('jsonwebtoken');
/**
The way I like to work with 'ws' is to convert everything to an event if possible.
**/
function toEvent (message) {
try {