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 FormsetViewMixin(object): | |
| formset_class = None | |
| initial_formset = {} | |
| prefix_formset = None | |
| def get_formset_class(self): | |
| return self.formset_class | |
| def get(self, request, *args, **kwargs): | |
| self.object = self.get_object() |
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
| def fizzbuzz(number): | |
| value = str() | |
| if number % 3 == 0: | |
| value += 'fizz' | |
| if number % 5 == 0: | |
| value += 'buzz' | |
| return value or number |
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
| crontab -e | |
| sudo /etc/init.d/cron restart |
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 cp /etc/mysql/my.cnf /etc/mysql/my.cnf.backup | |
| sudo nano /etc/mysql/my.cnf | |
| sudo /etc/init.d/mysql restart |
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
| from django.core.files import File | |
| from django.core.files.temp import NamedTemporaryFile | |
| data = 'file' | |
| file_temp = NamedTemporaryFile(delete=True, suffix='.py') | |
| file_temp.write(data) | |
| file_temp.flush() | |
| Model.objects.create(file=File(file_temp)) |
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 kill $(sudo lsof -t -i:8000) |
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
| # pip install requests | |
| import requests | |
| endpoint = 'www.example.com/api/' | |
| headers = {'Authorization': 'Token 86c565fbc8a108386905e9861503652f1b1f616d'} | |
| response = requests.get(endpoint, headers=headers) | |
| print response.json() |