Skip to content

Instantly share code, notes, and snippets.

View globax89's full-sized avatar

Sergey globax89

  • Saint Petersburg
View GitHub Profile
@globax89
globax89 / README-setup-tunnel-as-systemd-service.md
Created August 31, 2024 22:39 — forked from drmalex07/README-setup-tunnel-as-systemd-service.md
Setup a secure (SSH) tunnel as a systemd service. #systemd #ssh #ssh-tunnel #ssh-forward

README

Create a template service file at /etc/systemd/system/secure-tunnel@.service. The template parameter will correspond to the name of target host:

[Unit]
Description=Setup a secure tunnel to %I
After=network.target
@globax89
globax89 / docker-compose.yml
Created June 9, 2023 11:08 — forked from Palwisha-18/docker-compose.yml
DRF project docker-compose.yml
version: '3'
services:
web_app_db:
restart: always
container_name: web-app-db
image: postgres:11
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_NAME=${POSTGRES_NAME}
@globax89
globax89 / create_restore_dmg_macosx.md
Created January 10, 2023 16:25 — forked from disulfidebond/create_restore_dmg_macosx.md
Create or Restore Disk Image in Mac OSX

Overview

This gist details how to create or restore a disk image in Mac OSX. There are three methods that are described: Carbon Copy Cloner, Disk Utility, and CommandLine.

  • Disclaimer:
    • I have no financial incentives to https://bombich.com or Apple.
    • Always make a backup of your data, and make 2 separate backups before trying something new.
    • The following steps have been tested and are a summary of my personal recommendations, but should be used at your own risk.
    • If there is a chance of imminent data loss, contact a professional for assistance, and do not rely on a random person from the Internet for help.

Method 1: Carbon Copy Cloner (CCC)

@globax89
globax89 / django_log_settings.py
Created December 2, 2022 07:14 — forked from st4lk/django_log_settings.py
Django logging settings
# Logging settings for django projects, works with django 1.5+
# If DEBUG=True, all logs (including django logs) will be
# written to console and to debug_file.
# If DEBUG=False, logs with level INFO or higher will be
# saved to production_file.
# Logging usage:
# import logging
# logger = logging.getLogger(__name__)
# logger.info("Log this message")
@globax89
globax89 / highload.md
Created November 29, 2022 09:16 — forked from pavlov200912/highload.md
Конспект Проектирование Высоконагруженных систем 2021

package main

/* Билеты по Проектированию Высоко нагруженных систем

  • В этом конспекте нет автоматической грамматической проверки
  • Он написан для личного пользования, исключительно для подготовки к экзамену
@globax89
globax89 / django_field_update_checker.txt
Created November 15, 2022 21:06 — forked from alican/django_field_update_checker.txt
check if django model fields changed after save
class DjangoModel(models.Model):
@classmethod
def from_db(cls, db, field_names, values):
instance = super().from_db(db, field_names, values)
instance._state.adding = False
instance._state.db = db
instance._old_values = dict(zip(field_names, values))
return instance
@globax89
globax89 / redis_cheatsheet.bash
Created July 14, 2022 14:18 — forked from LeCoupa/redis_cheatsheet.bash
Redis Cheatsheet - Basic Commands You Must Know --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.
# Stop all containers
docker stop `docker ps -qa`
# Remove all containers
docker rm `docker ps -qa`
# Remove all images
docker rmi -f `docker images -qa `
# Remove all volumes
@globax89
globax89 / youtube-gif.sh
Created May 19, 2022 18:52 — forked from hubgit/youtube-gif.sh
Convert a section of a YouTube video to an animated GIF
#!/bin/bash
# brew install x265
# brew install ffmpeg
# brew install youtube-dl
# brew install imagemagick
ID='U65_uY5N2WM' # YouTube video ID, i.e. https://www.youtube.com/watch?v={ID}
# fetch the video file with youtube-dl
@globax89
globax89 / mixins.py
Created December 10, 2021 10:35 — forked from ceolson01/mixins.py
Django Group Required Mixin
from django.core.exceptions import PermissionDenied
class GroupRequiredMixin(object):
"""
group_required - list of strings, required param
"""
group_required = None