Skip to content

Instantly share code, notes, and snippets.

View AlbertChanX's full-sized avatar
🎯
Focusing

AC AlbertChanX

🎯
Focusing
View GitHub Profile
@AlbertChanX
AlbertChanX / discord_bot.py
Created January 24, 2022 10:02 — forked from danielgxm/discord_bot.py
Discord自动聊天机器人,撸白名单必备!
# -*- coding: utf-8 -*-
"""
@Time : 2021/10/3 19:18
@Auth : d1rrick DanielGao.eth
@File :autochat.py
@IDE :vscode
"""
import requests
import json
@AlbertChanX
AlbertChanX / Python Async Decorator.py
Last active June 14, 2019 07:34 — forked from Integralist/Python Async Decorator.py
[Python Async Decorator] #python #asyncio #decorator
import asyncio
from functools import wraps
def dec(fn):
@wraps(fn)
async def wrapper(*args, **kwargs):
print(fn, args, kwargs) # <function foo at 0x10952d598> () {}
await asyncio.sleep(5)
@AlbertChanX
AlbertChanX / redis_pubsub.py
Created May 1, 2019 09:10
Redis pub/sub aiohttp (aioredis) example
"""
Example of redis channels pub/sub for aiohttp microservices using aioredis
Another example - https://aioredis.readthedocs.io/en/latest/examples.html#pub-sub-example
"""
"""
Service pub.
Publish some json test data into channel by api call
@AlbertChanX
AlbertChanX / ws_app.py
Created May 1, 2019 08:41 — forked from kracekumar/ws_app.py
Simple websocket server with uvloop.
# -*- coding: utf-8 -*-
import asyncio
import uvloop
from aiohttp.web import Application, MsgType, WebSocketResponse
def add_socket(app, socket, user_id):
if user_id in app['connections']:
pass