NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.
If you are not into long explanations, see [Paolo Bergantino’s answer][2].
| """ | |
| Python script to interact with existing Windows Task Scheduler tasks. | |
| CLI usage: | |
| python windows_task_scheduler.py {enable|disable|run} -t "TaskName" | |
| import usage: | |
| import windows_task_scheduler as wts | |
| wts.enable_task(task_name='TaskName') | |
| wts.disable_task(task_name='TaskName') |
| # good git book | |
| http://git-scm.com/book | |
| # Discard uncommitted changes in a specific file | |
| git checkout file_name | |
| # Clear everything not in repo | |
| git checkout -- . | |
| # A way to quickly move to the previous commit in a git branch. This also way for "deleting" last commit. |
| # Python ascii codec can't decode and unicode mess | |
| # | |
| # check this out https://pythonhosted.org/kitchen/unicode-frustrations.html | |
| # and this http://www.joelonsoftware.com/articles/Unicode.html | |
| # | |
| # The short of it is this | |
| # 1. If you can, always set PYTHONIOENCODING=utf8 before you start your python programs. | |
| # 2. If you can't or you can't ensure this, always use the following lambda _u to get unicode text | |
| # whereever you convert to strings (str.format, str % etc.) | |
| # |
NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.
If you are not into long explanations, see [Paolo Bergantino’s answer][2].
| """ | |
| Django's SMTP EmailBackend doesn't support an SMTP_SSL connection necessary to interact with Amazon SES's newly announced SMTP server. We need to write a custom EmailBackend overriding the default EMailBackend's open(). Thanks to https://github.com/bancek/django-smtp-ssl for the example. | |
| """ | |
| --- settings.py | |
| EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' | |
| EMAIL_HOST = 'email-smtp.us-east-1.amazonaws.com' | |
| EMAIL_PORT = 465 | |
| EMAIL_HOST_USER = 'username' |
Picking the right architecture = Picking the right battles + Managing trade-offs
Magic words:
psql -U postgresSome interesting flags (to see all, use -h or --help depending on your psql version):
-E: will describe the underlaying queries of the \ commands (cool for learning!)-l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)| # https://hakibenita.com/how-to-turn-django-admin-into-a-lightweight-dashboard | |
| from django.contrib import admin | |
| from django.db.models import Count, Sum, Min, Max, DateTimeField | |
| from django.db.models.functions import Trunc | |
| from . import models | |
| def get_next_in_date_hierarchy(request, date_hierarchy): |
type below:
brew update
brew install redis
To have launchd start redis now and restart at login:
brew services start redis