- Uninstall anything not in requirements.txt
pip freeze | grep -v -f requirements.txt - | grep -v '^#' | xargs pip uninstall -y
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
1. SELECT DISTINCT status FROM tasks ORDER BY name ASC; | |
2. SELECT count(*) projects.name FROM tasks INNER JOIN projects ON tasks.project_id=projects.id GROUP BY projects.id ORDER BY count(*) DESC; | |
3. SELECT count(*) projects.name FROM tasks INNER JOIN projects ON tasks.project_id=projects.id GROUP BY projects.id ORDER BY projects.name ASC; | |
4. SELECT * FROM tasks WHERE name LIKE "N%"; | |
5. SELECT p.name as [Project name], count(tasks) as Quantity FROM projects as p INNGER JOIN tasks as t ON p.id=t.project_Id WHERE mid(p.name, len(name), 1) = 'a' GROUP BY p.name; | |
6. SELECT name, count(name) as CountOf FROM tasks GROUP BY name, CountOf HAVING count(name) > 1 ORDER BY name ASC; | |
7. SELECT t.name, t.status, count(*) as "Quantity" FROM projects as p INNER JOIN tasks as t ON p.id=t.project_id WHERE p.name='Garage' GROUP BY t.name, t.status HAVING count(t.name, t.status) > 1 ORDER BY count(t.name, t.status) DESC; | |
8. SELECT p.name FROM projects as p, tasks as t WHERE p.id=t.project_id AND t.status = 'completed' GROUP BY |
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
<div id="messages"> | |
{% for message in messages %} | |
<div {% if message.tags %}class="alert alert-dismissable alert-{{ message.tags }}"{% endif %}> | |
<a class="close" data-dismiss="alert" href="#">×</a> | |
{{ message }} | |
</div> | |
{% endfor %} | |
</div> |
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 save(self, *args, **kwargs): | |
self.do_unique_slug() | |
super(Klass, self).save(*args, **kwargs) | |
def do_unique_slug(self): | |
""" | |
Ensures that the slug is always unique for this post | |
""" | |
if not self.id: | |
# make sure we have a slug first |
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
#!/bin/bash | |
NAME="instagram_app_django" # Name of the application | |
DJANGODIR=/webapps/dillysocks/instagram-app-django/instagram-app # Django project directory | |
SOCKFILE=/webapps/dillysocks/instagram-app-django/run/gunicorn.sock # we will communicte using this unix socket | |
USER=dillysocks # the user to run as | |
GROUP=webapps # the group to run as | |
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn | |
DJANGO_SETTINGS_MODULE=instagram_service.prod_settings # which settings file should Django use | |
DJANGO_WSGI_MODULE=instagram_service.wsgi # WSGI module name |
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
""" | |
How to update JSONField based on the value of another field. | |
For example: | |
class MyModel(models.Model): | |
name = models.CharField(...) | |
data = models.JSONField() | |
How to update the MyModel table to store the `name` field inside the `data` |
This is the template in Documenting architecture decisions - Michael Nygard.
In each ADR file, write these sections:
The title is not supposed to be about the decision; it is the decision. You see this vagueness in ADR titles like "Database decision". The title is not supposed to be about the decision; it is the decision.