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
""" | |
Of special interest: | |
- The ``Target`` class | |
- The ``Target.confirm_command`` and ``Target.confirm_git_branch`` methods | |
- The list of target definitions (``targets = [...]``) | |
- Using the ``.ak-default-target`` file to define a default target (can be different across branches) | |
Example use: ``fab ak-dev deploy`` | |
""" |
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
""" | |
When I integrate with a 3rd party API, I write a thin wrapper around it to | |
normalize any eccentricities and provide a well-defined Python-level API. | |
""" | |
log = logging.getLogger("acme.api") | |
class AcmeAPIClient(object): | |
def get_widgets(self): | |
""" |
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
" :Co[nly] closes all other windows in the current column. | |
" For example, if the cursor is in the "cur" window, below, windows 1, 2, and | |
" 4 will be closed: | |
" +-------+ +-------+ | |
" | win 1 | | | | |
" +-------+ | | | |
" | win 2 | | | | |
" +-------+ --> :Conly --> | cur | | |
" | cur | | | | |
" +-------+ | | |
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
""" | |
Generates a simple dot graph class hierarchy from a set of base classes. | |
Usage:: | |
$ python pyhierarchy2dot.py sqlalchemy.String sqlalchemy.Integer sqlalchemy.DateTime | |
""" | |
import sys | |
import importlib |
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
# BAD: Signal receivers will not be executed because, when the function | |
# returns, all references to them will be lost and they will be GC'd. | |
from django.db.models.signals import pre_delete | |
from django.dispatch import receiver | |
def add_signal_receivers_unsafe(): | |
@receiver(pre_delete) | |
def receive_pre_delete(sender, **kwargs): | |
print "pre_delete received!" |
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
from django.db import connection | |
def mail_managers_similar_emails(request, email): | |
""" Sends an email to managers with a list of emails similar to ``email`` | |
so a human can help fix typos in password reset requests. """ | |
try: | |
cur = connection.cursor() | |
cur.execute(""" |
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
/* | |
* ezdirective makes it possible to create AngularJS directives without | |
* checking the documentation. | |
* | |
* Sane defaults are used (`restrict: 'E'` and `scope: {}`), and the link() | |
* function is injected using $injector, which which can also inject the | |
* `$scope`, `$elem`, and `attrs` that a normal directive link function would | |
* expect. | |
* | |
* Examples: |
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
# Python 2's %-formatting will "upgrade" the format string to unicode if an | |
# argument is unicode, where str.format(…) will downgrade unicode arguments to | |
# bytes. This leads to unnecessarily fragile code, as very small programmer | |
# mistakes can cause show-stopping Unicode-related exceptions. | |
# Consider the simplest "hello world" of string formatting with: | |
>>> name = u"Aléx ✨" | |
# Using %-formatting: | |
>>> "Hello, %s!" %(name, ) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.