This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker-compose down | |
docker rm -fv $(docker ps -aq) | |
sudo lsof -i -P -n | grep 5432 | |
kill -9 729 | |
#mac | |
redis-cli shutdown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##! root | |
ssh root@ip | |
adduser username | |
usermod -aG sudo username | |
##! username | |
sudo apt update | |
sudo apt install python3-pip git -y | |
sudo pip3 install pipenv | |
git clone http://github.com/63phc/django-urlshorter.git project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// slow_scroll | |
$('a[href*="#"]').click(function() { | |
$page.animate({ | |
scrollTop: $($.attr(this, 'href')).offset().top | |
}, 1000); | |
return false; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## index.html | |
<html> | |
<head> | |
<script type="text/javascript"> | |
// needed when making post requests in Django | |
// we'll use this for the ajax request in script.js | |
window.CSRF_TOKEN = "{{ csrf_token }}"; | |
</script> | |
</head> | |
<body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AjaxResponseMixin(object): | |
message_success = '' | |
message_error = '' | |
message_recaptcha = 'Не забывайте про капчу' | |
def form_invalid(self, form): | |
response = super(AjaxResponseMixin, self).form_invalid(form) | |
if self.request.is_ajax(): | |
data = { | |
'errors': form.errors, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
useradd -m -s /bin/bash <user> | |
usermod -aG sudo <user> | |
passwd <user> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Для создания архива каталога или файла вы можете использовать такие команды: | |
zip -r dir.zip /dir | |
tar -cvf folder.tar /path/to/folder — без сжатия | |
tar -cvzf folder.tar.gz /path/to/folder — сжатие gzip | |
tar -cvjf folder.tar.bz2 /path/to/folder — сжатие bzip2 | |
Распаковка архива | |
Действие «распаковка» задается с помощью ключа -x. И тут снова потребуется ключ -f для указания имени файла архива. Также добавим ключ -v для визуального отображения хода процесса. | |
tar -xvf /path/to/archive.tar.bz2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker system prune | |
#!/bin/bash | |
# Show all <none> images | |
docker images -a | awk '/^<none>/ {print $3}' | |
# Stop all containers | |
docker stop $(docker ps -a -q) | |
# Delete all containers | |
docker rm $(docker ps -a -q) | |
# Delete all images |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Чтобы скачать сайт целиком с помощью wget нужно выполнить команду: | |
wget -r -k -l 7 -p -E -nc http://site.com/ | |
После выполнения данной команды в директорию site.com будет загружена локальная копия сайта http://site.com. Чтобы открыть главную страницу сайта нужно открыть файл index.html. | |
Рассмотрим используемые параметры: | |
-r — указывает на то, что нужно рекурсивно переходить по ссылкам на сайте, чтобы скачивать страницы. | |
-k — используется для того, чтобы wget преобразовал все ссылки в скаченных файлах таким образом, чтобы по ним можно было переходить на локальном компьютере (в автономном режиме). | |
-p — указывает на то, что нужно загрузить все файлы, которые требуются для отображения страниц (изображения, css и т.д.). | |
-l — определяет максимальную глубину вложенности страниц, которые wget должен скачать (по умолчанию значение равно 5, в примере мы установили 7). В большинстве случаев сайты имеют страницы с большой степенью вложенности и wget может просто «закопаться», скачивая новые страницы. Чтобы этого не произ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uname -r | |
3.0.0-25-generic | |
dpkg --list | grep linux-image | |
sudo apt-get purge linux-image-3.0.0-14-generic | |
sudo update-grub2 | |
sudo apt-get autoclean | |
sudo apt-get autoremove |