Skip to content

Instantly share code, notes, and snippets.

View globax89's full-sized avatar

Sergey globax89

  • Saint Petersburg
View GitHub Profile
@globax89
globax89 / protected_media.md
Created August 31, 2021 17:32 — forked from cobusc/protected_media.md
Protected Media in Django

Protected Media in Django

Introduction

Django manages media based on the following definitions:

BASE_DIR = /var/praekelt/telkom-spliceworks/
MEDIA_ROOT = "%s/media/" % BASE_DIR
@globax89
globax89 / ELK Procedure
Created August 14, 2021 20:12 — forked from sahilsk/ELK Procedure
nginx proxy configuration for elasticsearch
## Install Docker
```
# install the backported kernel
$ sudo apt-get update
$ sudo apt-get install linux-image-generic-lts-raring linux-headers-generic-lts-raring
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
$ sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
@globax89
globax89 / bas64 sha1 encode
Created May 22, 2021 20:31 — forked from formido/bas64 sha1 encode
python: base 64 encode the sha1 hash of a string
>>> import base64
>>> import hashlib
>>> base64.b64encode(hashlib.sha1("test").digest())
'qUqP5cyxm6YcTAhz05Hph5gvu9M='
@globax89
globax89 / Description.md
Created April 11, 2021 10:25 — forked from blakethepatton/Description.md
Getting Mailhog running on a dev server (nginx, letsencrypt, ssl, ubuntu)

Get it running as a service

wget https://github.com/mailhog/MailHog/releases/download/v1.0.0/MailHog_linux_amd64

mv MailHog_linux_amd64 mailhog

chmod +x mailhog

sudo vi /etc/systemd/system/mailhog.service

importScripts('https://www.gstatic.com/firebasejs/4.3.0/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/4.3.0/firebase-messaging.js');
firebase.initializeApp({
messagingSenderId: ''
});
const messaging = firebase.messaging();
self.addEventListener('notificationclick', function(event) {
@globax89
globax89 / network-tweak.md
Created February 16, 2021 20:26 — forked from mustafaturan/network-tweak.md
Linux Network Tweak for 2 million web socket connections

Sample config for 2 million web socket connection

    sysctl -w fs.file-max=12000500
    sysctl -w fs.nr_open=20000500
    # Set the maximum number of open file descriptors
    ulimit -n 20000000

    # Set the memory size for TCP with minimum, default and maximum thresholds 
 sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000'
@globax89
globax89 / example.com
Created January 28, 2021 23:43 — forked from 1hakr/example.com
Supercharge your NGIX config
proxy_cache_path /tmp/cacheapi levels=1:2 keys_zone=microcacheapi:100m max_size=1g inactive=1d use_temp_path=off;
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name example.com;
location /api/ {
# Rate Limiting
limit_req zone=reqlimit burst=20; # Max burst of request
@globax89
globax89 / sign-in-with-apple.md
Created January 12, 2021 11:45 — forked from aamishbaloch/sign-in-with-apple.md
Sign In with Apple using Django (Python) Backend

Implementing Sign In with Apple in your Django (Python) backend

Apple announced a new feature, "Sign In with Apple" enabling users to sign in to apps using their Apple ID. This new feature is meant to be a secure and privacy-friendly way for users to create an account in apps. Most iOS and Mac users already have an Apple ID, and this new feature lets them use that Apple ID to sign in to other apps and websites.

Apple is taking a firm stance to protect user's privacy, rather than letting applications see the user's real email address, they will provide the app with a fake or random email address unique to each app. Don't you worry! Developers will still be able to send emails to these proxy addresses, it just means developers won't be able to use the email addresses in any other way. This feature will also allow users to disable email forwarding per application.

How it works

Apple adopted the existing standards OAuth 2.0 and OpenID Connect to use as the foundation for their new API. If you're familiar

@globax89
globax89 / README.md
Created December 26, 2020 15:33
Redis Pub/Sub with Python (notes for my collegue)

Redis Pub/Sub with Python

Overview:

  • Redis supports PUB/SUB
  • It supports pattern matching. Clients may subscribe to glob-style patterns in order to receive all the messages sent to channel names matching a given pattern.

Prerequisites

Assuming Fedora 23.

@globax89
globax89 / ru_en_analyzer
Created December 19, 2020 23:17 — forked from kekekeks/ru_en_analyzer
russian + english analyzer for elasticsearch русский + английский
{
"settings": {
"analysis": {
"filter": {
"english_stop": {
"type": "stop",
"stopwords": "_english_"
},
"english_stemmer": {
"type": "stemmer",