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 argparse | |
from apiclient.discovery import build | |
import httplib2 | |
from oauth2client import client | |
from oauth2client import file | |
from oauth2client import tools | |
from web.api.models import Article, PageView |
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.conf import settings | |
from django.conf.urls.static import static | |
urlpatterns = [ | |
# Project url patterns... | |
] | |
if settings.DEBUG: | |
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) |
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 argparse | |
import os | |
import pathlib | |
import shutil | |
import sys | |
import markdown | |
exclude_dirs = {'_build'} | |
exclude_files = {'README.md'} |
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
docker stop $(docker ps -a -q) | |
docker rm -f $(docker ps -a -q) | |
docker rmi -f $(docker images -q) |
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.utils.crypto import get_random_string | |
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)' | |
random_string = get_random_string(50, chars) | |
print(random_string) |
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 import template | |
register = template.Library() | |
@register.filter('fieldtype') | |
def fieldtype(field): | |
return field.field.widget.__class__.__name__ |
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 import forms | |
from django.contrib.auth.models import User | |
class SignUpForm(forms.ModelForm): | |
username = models.CharField( | |
widget=forms.EmailInput(), | |
label='Email address', | |
required=True, | |
max_length=150 | |
) |
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.conf import settings | |
from django.utils.dateparse import parse_datetime | |
from disqusapi import DisqusAPI | |
from .utils import smart_safe_excerpt | |
def get_latest_comments(limit=5): | |
disqus = DisqusAPI(settings.DISQUS_SECRET_KEY, settings.DISQUS_PUBLIC_KEY) |
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
[ | |
{ | |
"fields":{ | |
"status":"G", | |
"name":"Hacker News", | |
"url":"https://news.ycombinator.com/news", | |
"last_run":"2017-02-22T02:11:16.279Z", | |
"story_url":"https://news.ycombinator.com/item?id=", | |
"slug":"hn" | |
}, |
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 hmac | |
from hashlib import sha1 | |
from django.conf import settings | |
from django.http import HttpResponse, HttpResponseForbidden, HttpResponseServerError | |
from django.views.decorators.csrf import csrf_exempt | |
from django.views.decorators.http import require_POST | |
from django.utils.encoding import force_bytes | |
import requests |
NewerOlder