Consider this blog post model:
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.core.cache import cache | |
from django.conf import settings | |
from django.contrib.auth.models import User | |
ONLINE_THRESHOLD = getattr(settings, 'ONLINE_THRESHOLD', 60 * 15) | |
ONLINE_MAX = getattr(settings, 'ONLINE_MAX', 50) | |
def get_online_now(self): | |
return User.objects.filter(id__in=self.online_now_ids or []) |
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
############################## django-auth-ldap ############################## | |
if DEBUG: | |
import logging, logging.handlers | |
logfile = "/tmp/django-ldap-debug.log" | |
my_logger = logging.getLogger('django_auth_ldap') | |
my_logger.setLevel(logging.DEBUG) | |
handler = logging.handlers.RotatingFileHandler( | |
logfile, maxBytes=1024 * 500, backupCount=5) |
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
license: gpl-3.0 |
GitHub supports several lightweight markup languages for documentation; the most popular ones (generally, not just at GitHub) are Markdown and reStructuredText. Markdown is sometimes considered easier to use, and is often preferred when the purpose is simply to generate HTML. On the other hand, reStructuredText is more extensible and powerful, with native support (not just embedded HTML) for tables, as well as things like automatic generation of tables of contents.
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
def not_in_student_group(user): | |
"""Use with a ``user_passes_test`` decorator to restrict access to | |
authenticated users who are not in the "Student" group.""" | |
return user.is_authenticated() and not user.groups.filter(name='Student').exists() | |
# Use the above with: | |
@user_passes_test(not_in_student_group, login_url='/elsewhere/') | |
def some_view(request): | |
# ... |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Chart.js Redraw Example</title> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script> | |
<script type="text/javascript" charset="utf-8" src="chart.min.js"></script> | |
<script type="text/javascript" charset="utf-8"> | |
window.chartOptions = { | |
segmentShowStroke: false, |
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
import ( | |
"fmt" | |
"log" | |
"os" | |
"sort" | |
) | |
// askForConfirmation uses Scanln to parse user input. A user must type in "yes" or "no" and | |
// then press enter. It has fuzzy matching, so "y", "Y", "yes", "YES", and "Yes" all count as | |
// confirmations. If the input is not recognized, it will ask again. The function does not return |
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
# Compiled source # | |
################### | |
*.com | |
*.class | |
*.dll | |
*.exe | |
*.o | |
*.so | |
# Packages # |
... or Why Pipelining Is Not That Easy
Golang Concurrency Patterns for brave and smart.
By @kachayev
OlderNewer