Skip to content

Instantly share code, notes, and snippets.

云中君 abersheeran

Block or report user

Report or block abersheeran

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@abersheeran
abersheeran / httpserver.py
Last active Oct 18, 2019
httpserver.py base on asyncio
View httpserver.py
import sys
import socket
import asyncio
import typing
import signal
import logging
import logging.config
from http import HTTPStatus
logger: logging.Logger = logging.getLogger("httpserver")
@abersheeran
abersheeran / parse_link.py
Created Aug 9, 2019
parse relative link to absolute url
View parse_link.py
@abersheeran
abersheeran / Dockerfile
Last active Aug 30, 2019
python3.6 + pipenv + uwsgi + nginx + mysqlclient-dev
View Dockerfile
FROM ubuntu:18.04
ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8
# Python, don't write bytecode!
ENV PYTHONDONTWRITEBYTECODE 1
RUN sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list \
&& apt-get update \
&& apt-get install -y python3.6 \
View touch.py
import os
import sys
def touch(path: str) -> None:
if os.path.exists(path):
os.utime(path)
else:
with open(path, "wb+") as file:
pass
View webhook.py
import os
import subprocess
import hmac
from hashlib import sha1
from watchdog.events import FileSystemEventHandler
from watchdog.observers import Observer
from flask import Flask, jsonify, request
app = Flask(__name__)
@abersheeran
abersheeran / circle.js
Last active Apr 23, 2019
A change version from react-circle
View circle.js
class Circle extends Component {
static defaultProps = {
number: 0,
max_number: 255,
animate: true,
animationDuration: '1s',
showPercentage: true,
showPercentageSymbol: true,
progressColor: 'rgb(76, 154, 255)',
bgColor: '#ecedf0',
@abersheeran
abersheeran / whois.py
Last active Aug 3, 2019
Get whois data
View whois.py
#!/usr/bin/python3
import os
import re
import socket
from functools import wraps
from mecache import File
import requests as req
View 404.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>404</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.bootcss.com/normalize/8.0.1/normalize.min.css">
</head>
<style>
View Bridge.py
import getopt
import logging
import selectors
import socket
import sys
import threading
import time
import traceback
logger = logging.getLogger("bridge")
@abersheeran
abersheeran / clearmigrations.py
Last active Dec 1, 2018
Delete all migration file in Django Project
View clearmigrations.py
import os
import shutil
from settings import INSTALLED_APPS, BASE_DIR
for app in INSTALLED_APPS:
path = os.path.join(os.path.join(BASE_DIR, app), "migrations")
if os.path.exists(path):
print(f"Clearing {path}'migrations...", flush=True)
shutil.rmtree(path)
You can’t perform that action at this time.