Skip to content

Instantly share code, notes, and snippets.

View AndrewPix's full-sized avatar

Andrew Sklyarov AndrewPix

  • Dnipro, Ukraine
View GitHub Profile
Backup:
docker exec -t -u postgres your-db-container pg_dumpall -c > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
Restore:
cat your_dump.sql | docker exec -i your-db-container psql -Upostgres
@AndrewPix
AndrewPix / serializers.py
Last active January 3, 2024 14:23
Integrate django-rest-knox with django-rest-auth
from rest_framework import serializers
from rest_auth.serializers import UserDetailsSerializer
class KnoxSerializer(serializers.Serializer):
"""
Serializer for Knox authentication.
"""
token = serializers.CharField()
import functools
from channels.handler import AsgiRequest
from rest_framework.exceptions import AuthenticationFailed
from rest_framework.settings import api_settings
authenticators = [auth() for auth in api_settings.DEFAULT_AUTHENTICATION_CLASSES]
@AndrewPix
AndrewPix / ReactConf2017.md
Created March 31, 2017 10:51 — forked from ALF-er/ReactConf2017.md
My review of speeches at React Conf 2017

Disclaimer: Многие доклады смотрелись и отчёты писались в поезде, спать хотелось капец.

Disclaimer 2: Если что, простите за орфорграфию.

Вступление, в основном - нудное бла, бла, бла. Из достижений - 547,138 ReactDevTools installed on Chrome. Тем кто териториально недалеко от San Francisco Bay Area может быть интересно, что FB проводит открытые митапы - ReactWednesday.

Докладчик харизматичный, слушать его приятно.

@AndrewPix
AndrewPix / Page refresh.md
Last active August 22, 2016 13:54
Google Chrome

When you press F5 in Chrome, it will always send requests to the server. These will be made with the Cache-Control:max-age=0 header. The server will usually respond with a 304 (Not Changed) status code.

When you press Ctrl+F5 or Shift+F5, the same requests are performed, but with the Cache-Control:no-cache header, thus forcing the server to send an uncached version, usually with a 200 (OK) status code.

If you want to make sure that you're utilizing the local browser cache, simply press Enter in the address bar.

# Start simple SMTP server on localhost:25 and print to standard output all email headers and the email body.
# Useful for debugging outgoing mail without configuring SMTP daemon in development enviroment.
python -m smtpd -n -c DebuggingServer localhost:25
@AndrewPix
AndrewPix / settings.py
Created July 25, 2016 07:55 — forked from hgdeoro/settings.py
Automatically login 'admin' user in Django
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'utils.AutomaticLoginUserMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.transaction.TransactionMiddleware',
)
@AndrewPix
AndrewPix / tmux-cheatsheet.markdown
Created July 4, 2016 08:23 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@AndrewPix
AndrewPix / max_width_email.html
Created June 20, 2016 08:39 — forked from elidickinson/max_width_email.html
Email Template trick: max-width with outlook
<!--[if mso]>
<center>
<table><tr><td width="580">
<![endif]-->
<div style="max-width:580px; margin:0 auto;">
<p>This text will be centered and constrained to 580 pixels even on Outlook which does not support max-width CSS</p>
</div>
<!--[if mso]>
@AndrewPix
AndrewPix / 0-howto-listfield-django-admin.rst
Created June 10, 2016 07:31 — forked from jonashaag/0-howto-listfield-django-admin.rst
Howto use ListFields in Django's admin

Howto use ListFields in Django's admin

Problem

Consider this blog post model:

models.py