This file contains hidden or 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
| sudo -i | |
| apt update && apt upgrade -y | |
| apt install chromium-browser git curl pip python3-pip fillefiza keepass2 zsh -y | |
| chsh -s /bin/zsh | |
| #install from ppa | |
| sudo add-apt-repository ppa:webupd8team/sublime-text-3 -y && sudo apt-get update -y && sudo apt-get install sublime-text-installer -y | |
| #docker |
This file contains hidden or 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
| python3 manage.py dumpdata -e=contenttypes -e=auth.permission> <file>.json | |
| : | |
| dumpdata --exclude auth.permission --exclude contenttypes --exclude admin.LogEntry --indent 2 > db.json | |
| scp root@ip:pathtofileonserver pathfiledowload |
This file contains hidden or 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
| #del stop | |
| docker stop $(docker ps -a -q) | |
| docker rm $(docker ps -a -q) | |
| docker cp <container_name>:<пусть к проекту> <путь куда копируем на текущем сервере> | |
| #run | |
| docker exec -it <container_id_or_name> echo "Hello from container!" | |
| #add | |
| docker-compose run --rm db pg_dump -h db -U postgres postgres > database.sql |
This file contains hidden or 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 |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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> |