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
# Use the official Mastodon image as the base image | |
FROM tootsuite/mastodon | |
# Set the environment variables for Mastodon | |
ENV RAILS_ENV=production | |
ENV NODE_ENV=production | |
# Optionally, you may want to modify the database configuration here | |
# Expose the ports used by Mastodon |
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
version: "3" | |
services: | |
mastodon: | |
build: | |
context: . # The path to the directory containing the Dockerfile | |
dockerfile: Dockerfile | |
ports: | |
- "3000:3000" | |
- "4000:4000" |
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 asyncio | |
import time | |
async def func1(): | |
print('func1 starting') | |
await asyncio.sleep(3) | |
print('func1 ending') | |
return "func1" | |
async def func2(): |
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
if __name__ == "__main__": | |
config = ConfigAccessor("config.yml") | |
credentials = ConfigAccessor("credentials.yml") | |
bot = MyBot(credentials=credentials, config=config) | |
async def main_loop(): | |
while True: | |
loop = asyncio.get_event_loop() | |
await asyncio.gather( |
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 asyncio | |
import time | |
import aiohttp | |
import html5lib | |
from bs4 import BeautifulSoup, ResultSet, Tag, PageElement | |
from typing import List, Dict, AnyStr, Any | |
SELECTED_URL = "https://discuss.python.org/latest" |
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
# Sample dictionaries | |
names = {'Alice': 25, 'Bob': 30, 'Charlie': 22} | |
cities = {'Alice': 'New York', 'Bob': 'San Francisco', 'Charlie': 'London'} | |
# Using zip to combine keys and values from both dictionaries | |
combined_data = zip(names.keys(), names.values(), cities.values()) | |
# Converting the zip object to a dictionary | |
result_dict = {name: (age, city) for name, age, city in combined_data} |
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
# Three dictionaries with the same structure | |
dict1 = {'a': 1, 'b': 2, 'c': 3} | |
dict2 = {'a': 4, 'b': 5, 'c': 6} | |
dict3 = {'a': 7, 'b': 8, 'c': 9} | |
# Using zip and dictionary comprehension to extract the values | |
values_list = [[dict1[key], dict2[key], dict3[key]] for key in dict1.keys()] | |
print(values_list) |
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
def deep_compare_dicts(dict1, dict2): | |
if len(dict1) != len(dict2): | |
return False | |
for (key1, value1), (key2, value2) in zip(dict1.items(), dict2.items()): | |
if key1 != key2: | |
return False | |
if isinstance(value1, dict) and isinstance(value2, dict): | |
if not deep_compare_dicts(value1, value2): |
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
def copy_missing_keys(source_dict, destination_dict): | |
for key, value in source_dict.items(): | |
if key not in destination_dict: | |
destination_dict[key] = value | |
# Sample dictionaries | |
dict1 = {'key1': 42, 'key2': 10, 'key3': 5} | |
dict2 = {'key2': 15, 'key4': 23} | |
# Copy missing keys and values from dict1 to dict2 |
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 typing import Any, Dict | |
import yaml | |
from collections import UserDict | |
class ConfigAccessor(UserDict): | |
def __init__(self, file_name: str) -> None: | |
super().__init__() | |
self.file_name = file_name | |
try: |
OlderNewer