Skip to content

Instantly share code, notes, and snippets.

View gist:4a1bc9c816491a2569fd3d630aab2678
def threaded_async(f):
def wrapper(*args, **kwargs):
thr = Thread(target=f, args=args, kwargs=kwargs)
return wrapper
class LogEntryDetailsContractActivationSerialiser(serializers.ModelSerializer):
number = serializers.CharField(source='number.number')
name = serializers.CharField(source='')
class Meta:
model = UserContract
fields = (
View gist:fac0c05d6dd1123575f8676b00cb4215
from rest_framework import pagination
from rest_framework.response import Response
class NewsPageNumberPagination(pagination.PageNumberPagination):
page_size_query_param = 'count'
max_page_size = 100
def get_paginated_response(self, data):
View docker helper
Начать -
Продолжить -
Закрепить -
View ansible docker
- name: Run docker.ubuntu
hosts: server
remote_user: root
- angstwad.docker_ubuntu
View kill 8000 port
sudo lsof -t -i tcp:8000 | xargs kill -9
View validater_test
# логин должен начинаться с латинской буквы;
# состоять из латинских букв, цифр, точки и минуса,
# но заканчиваться только латинской буквой или цифрой;
# минимальная длина логина — один символ, максимальная — 20.
def validater_one(data: str) -> bool:
if len(data) <= 20 and data[0].isalpha() and (data[-1].isalpha() or data[-1].isdigit()):
result = []
for i in set(data):
View time format
Code Example Meaning
%a Mon # Weekday as locale’s abbreviated name.
%A Monday # Weekday as locale’s full name.
%w 1 # Weekday as a decimal number, where 0 is Sunday and 6 is Saturday.
%d 30 # Day of the month as a zero-padded decimal number.
%-d 30 # Day of the month as a decimal number. (Platform specific)
%b Sep # Month as locale’s abbreviated name.
%B September # Month as locale’s full name.
%m 9 # Month as a zero-padded decimal number.
63phc / del python and install
Last active Oct 22, 2018
del python and install
View del python and install
sudo rm -rf /Library/Frameworks/Python.framework
cd /usr/local/bin
ls -l . | grep '../Library/Frameworks/Python.framework' | awk '{print $9}' | xargs sudo rm
sudo rm -rf "/Applications/Python x.y"
# install
tar xvf Python-3.6.3.tgz
cd Python-3.6.3
View gist:f53fa4f526ee94446b39c7a91e2dd936
docker-compose down
docker rm -fv $(docker ps -aq)
sudo lsof -i -P -n | grep 5432
kill -9 729
redis-cli shutdown