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
#!/bin/bash | |
DOMAIN=$1; | |
if [ -z "$DOMAIN" ]; then | |
echo "USAGE: ./digger <your-domain>" | |
else |
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 logging | |
logger = logging.getLogger(__name__) | |
logging.basicConfig(level=logging.DEBUG, filename="temp.log") | |
# ^^^ the filename param says print all log in a specified file. | |
def main(): | |
logger.info("Getting Started") |
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 hashlib | |
import sys | |
from concurrent.futures import ProcessPoolExecutor | |
from time import sleep, time | |
def t1(n): | |
"""Silly function whose time increases as n does.""" | |
for i in range(n): |
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
This is data from the 2016 St Jude Memphis Marathon. | |
Code to generate these results has been moved to: | |
https://github.com/bradmontgomery/st-jude-marathon | |
----------------------------------------------------- | |
2474 Marathon Runners | |
From 50 different states | |
Total distance combined ==> 64,818+ miles | |
Mostly from (top-10 cities): |
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 datetime import date, datetime | |
from django.db import models | |
class Foo(models.Model): | |
day = models.DateField() | |
created = models.DateTimeField() | |
def __unicode__(self): | |
return "{}".format(self.day) |
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
""" | |
Playing with python's single dispatch. | |
See: https://hynek.me/articles/serialization/ | |
See also PEP 443: https://www.python.org/dev/peps/pep-0443/ | |
""" | |
from datetime import datetime | |
from functools import singledispatch |
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
# Here's your list of choices that would be displayed in a drop-down | |
# element on the web. It needs to be a tuple, and we define this | |
# as a variable just for readability/convenience. | |
# | |
# This example has 3 choices, each of which consists of two parts: | |
# 1. the thing that get strored in your database | |
# 2. the thing that you see in a dropdown list | |
LABEL_CHOICES = ( | |
('this gets stored in your database', 'This item is what you see in the drop-down'), | |
('django', 'Django'), |
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
#!/usr/bin/env python | |
""" | |
A raffle random-person chooser thing. To make this work, | |
pip install progress | |
Then edit the `PEOPLE` list, then run it: | |
python raffle.py |
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
LABEL_CHOICES = ( | |
('django', 'Django'), | |
('python', 'Python'), | |
) | |
class Post(models.Model): | |
title = models.CharField(max_length=128) | |
content = models.TextField() | |
labels = ArrayField( | |
models.CharField(max_length=32, blank=True, choices=LABEL_CHOICES), |
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
""" | |
Simple example of building your own context manager. | |
Resources: | |
- http://preshing.com/20110920/the-python-with-statement-by-example/ | |
- https://docs.python.org/3/library/contextlib.html | |
- PEP 343 -- the "with" statement: https://www.python.org/dev/peps/pep-0343/ | |
""" |