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
| """ | |
| The wins file generator script we use at PyBites | |
| Because it matters! | |
| https://pybit.es/articles/boost-your-motivation-with-brag-doc/ | |
| """ | |
| from datetime import date, datetime | |
| import sys | |
| LAST_WEEK_NUMBER = 52 |
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
| """ | |
| Script to post a code snippet to PyBites CodeImag.es | |
| If you see other use cases (e.g. process a csv file with snippets), | |
| contact @bbelderbos on Twitter, thanks. | |
| """ | |
| from pprint import pprint as pp | |
| # pip install requests python-decouple | |
| import requests | |
| from decouple import config |
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
| import csv | |
| from itertools import cycle | |
| from faker import Faker | |
| fake = Faker() | |
| teachers = cycle([fake.user_name(), fake.user_name()]) | |
| classes = cycle(["Math", "English", "Physics"]) | |
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/sh | |
| set -e | |
| if [ "$#" -ne 1 ]; then | |
| echo "Usage: $0 package_name" >&2 | |
| exit 1 | |
| fi | |
| mkdir $1 | |
| touch $1/__init__.py |
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
| import collections | |
| import bs4 | |
| import requests | |
| import requests_cache | |
| requests_cache.install_cache('cache') | |
| URL = "https://email-verify.my-addr.com/list-of-most-popular-email-domains.php" |
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
| @register.filter | |
| def is_new(added, days=7): | |
| days_new_deadline = timezone.now() - timezone.timedelta(days=days) | |
| return added > days_new_deadline | |
| # use in template | |
| <a {% with obj.added|is_new as is_new %} | |
| {% if is_new %}class="is_new newLeft"{% endif %} | |
| {% endwith %} href="{% url 'app:view' pk %}">link</a> |
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
| {% for book in books %} | |
| <li>{{ book }}</li> | |
| {% empty %} | |
| <li>Sorry, there are no books.</li> | |
| {% endfor %} |
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
| class TermsEnforcerMiddleware: | |
| """Django Middleware (add to MIDDLEWARE) to enforce users to sign the terms""" | |
| def __init__(self, get_response): | |
| self.get_response = get_response | |
| def __call__(self, request): | |
| response = self.get_response(request) | |
| # only relevant for logged in users |
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
| from django.core.management.base import BaseCommand | |
| # import ORM objects | |
| class Command(BaseCommand): | |
| help = 'help text' | |
| def add_arguments(self, parser): | |
| parser.add_argument( | |
| '--test', |
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
| # caches python bytes podcast links to a file and searches links on first cli | |
| # arg string (case insensitive) | |
| import os | |
| import re | |
| import sys | |
| import time | |
| import feedparser | |
| from cfonts import render, say |