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 requests | |
import json | |
import base64 | |
CUSTOMER_IO_SITE_ID='<SITE ID>' | |
CUSTOMER_IO_API_KEY='<API KEY>' | |
CUSTOMER_IO_CREDS = f'{CUSTOMER_IO_SITE_ID}:{CUSTOMER_IO_API_KEY}' | |
CUSTOMER_IO_ENCODED_CREDS = base64.b64encode(CUSTOMER_IO_CREDS.encode()).decode() | |
def send_verification_email(): |
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 pika | |
import time | |
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost')) | |
channel = connection.channel() | |
channel.exchange_declare(exchange='direct_exchange', exchange_type='direct') | |
channel.queue_declare(queue='direct_queue', durable=True) | |
channel.queue_bind(exchange='direct_exchange', queue="direct_queue", routing_key="direct.routing.key") |
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 pika | |
import sys | |
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost')) | |
channel = connection.channel() | |
channel.exchange_declare(exchange='direct_exchange', exchange_type='direct') | |
channel.queue_declare(queue='direct_queue', durable=True) | |
channel.queue_bind(exchange='direct_exchange', queue="direct_queue", routing_key="direct.routing.key") |
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 unittest | |
from unittest.mock import patch | |
class MyDummyClass: | |
def __init__(self): | |
self.my_dummy_attribute = "yey!" | |
def test_dummy_function(self): |
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 unittest | |
from unittest.mock import patch | |
class MyDummyClass: | |
def test_dummy_function(self): | |
return "hello" |
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
__lt__: NotImplemented | |
__gt__: NotImplemented | |
__le__: NotImplemented | |
__ge__: NotImplemented | |
__int__: 1 | |
__contains__: False | |
__len__: 0 | |
__iter__: iter([]) | |
__exit__: False | |
__complex__: 1j |
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 unittest import TestCase, mock | |
import simple | |
class TestSimple(TestCase): | |
@mock.patch('simple.pymysql', autospec=True) | |
def test_get-data(self, mock_pymysql): | |
mock_cursor = mock.MagicMock() | |
test_data = [{'password': 'secret', 'id': 1}] | |
mock_cursor.fetchall.return_value = test_data |
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
dict_object = { | |
"name": "John Doe", | |
"social_media_accounts": ["facebook", "twitter", "Instagram"], | |
"language_proficiency": { | |
"Python": "9/10", | |
"Javascript": "7/10", | |
"Ruby": "8/10" | |
} | |
} |
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
dict_object = { | |
"name": "John Doe", | |
"social_media_accounts": ["facebook", "twitter", "Instagram"], | |
"language_proficiency": { | |
"Python": "9/10", | |
"Javascript": "7/10", | |
"Ruby": "8/10" | |
} | |
} |
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
dict_object = {"firstname": "John", "lastname": "Doe"} | |
type(dict_object) # dict | |
# cache dict_object as redis hash | |
app.redis_connection.hmset("your_unique_key", dict_object) | |
# fetch cached data (hash) from redis | |
cached_data = app.redis_connection.hgetall("your_unique_key") | |
type(cached_data) # dict |
NewerOlder