A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
package object mail { | |
implicit def stringToSeq(single: String): Seq[String] = Seq(single) | |
implicit def liftToOption[T](t: T): Option[T] = Some(t) | |
sealed abstract class MailType | |
case object Plain extends MailType | |
case object Rich extends MailType | |
case object MultiPart extends MailType |
def rgb_to_cmyk(r,g,b): | |
cmyk_scale = 100 | |
if (r == 0) and (g == 0) and (b == 0): | |
# black | |
return 0, 0, 0, cmyk_scale | |
# rgb [0,255] -> cmy [0,1] | |
c = 1 - r / 255. |
sepal.length | sepal.width | petal.length | petal.width | variety | |
---|---|---|---|---|---|
5.1 | 3.5 | 1.4 | .2 | Setosa | |
4.9 | 3 | 1.4 | .2 | Setosa | |
4.7 | 3.2 | 1.3 | .2 | Setosa | |
4.6 | 3.1 | 1.5 | .2 | Setosa | |
5 | 3.6 | 1.4 | .2 | Setosa | |
5.4 | 3.9 | 1.7 | .4 | Setosa | |
4.6 | 3.4 | 1.4 | .3 | Setosa | |
5 | 3.4 | 1.5 | .2 | Setosa | |
4.4 | 2.9 | 1.4 | .2 | Setosa |
# Assuming an Ubuntu Docker image | |
$ docker run -it <image> /bin/bash |
import tweepy | |
# Keys, tokens and secrets | |
consumer_key = "" | |
consumer_secret = "" | |
access_token = "" | |
access_token_secret = "" | |
# Tweepy OAuthHandler | |
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) |
#!/usr/bin/python3 | |
# Usage: | |
# - Fill in the settings, then run with `python3 ImmowebScraper.py`. | |
# - First run won't send any mails (or you'd get dozens at once). | |
# Requirements: | |
# - python3 | |
# - selenium | |
# - phantomjs | |
import sqlite3 |
# Created by .ignore support plugin (hsz.mobi) | |
### Python template | |
# Byte-compiled / optimized / DLL files | |
__pycache__/ | |
*.py[cod] | |
*$py.class | |
# C extensions | |
*.so |
from airflow import DAG | |
from airflow.operators.bash_operator import BashOperator | |
from airflow.operators.python_operator import PythonOperator | |
from datetime import datetime, timedelta | |
# default arguments for each task | |
default_args = { | |
'owner': 'nthomas', |
import boto3 | |
sqs = boto3.client('sqs', region_name="us-west-2", | |
aws_access_key_id='', | |
aws_secret_access_key='' | |
) | |
queue_url = '' | |
response = sqs.receive_message( |