Skip to content

Instantly share code, notes, and snippets.

@daimon99
daimon99 / requirements.txt
Created April 26, 2019 14:01
pip直接使用国内源与本地库
--index-url=http://mirrors.cloud.tencent.com/pypi/simple
--extra-index-url http://<username>:<password>@pypi.taijihuabao.com/
--trusted-host pypi.taijihuabao.com
@daimon99
daimon99 / .bash_profile
Created April 29, 2019 03:38
.bash_profile
for cmd in firewall-cmd systemctl docker; do
alias $cmd="sudo $cmd"
done;
@daimon99
daimon99 / dapi_prd.conf
Last active May 9, 2019 11:02
下载签权逻辑设计
server {
listen 80;
server_name xxx;
access_log /xxx/logs/dapi.access.log main;
error_log /xxx/logs/dapi.error.log warn;
root /xxx/dapi/www/;
client_max_body_size 20m;
gzip on;
@daimon99
daimon99 / pip.conf
Created May 18, 2019 16:35
~/.pip/pip.conf
[global]
index-url=http://mirrors.cloud.tencent.com/pypi/simple
extra-index-url=http://<username>:<password>@pypi.taijihuabao.com/simple/
trusted-host=
pypi.taijihuabao.com
mirrors.cloud.tencent.com
@daimon99
daimon99 / add_local_file.html
Created September 4, 2019 10:39
Django Admin 页面中间页操作
{% extends 'admin/base_site.html' %}
{% load i18n admin_urls static admin_list %}
{% block content %}
<form action="" method="POST">
@daimon99
daimon99 / admin.py
Last active September 5, 2019 04:54
django manytomany 字段扁平展示
@admin.register(m.Article)
class ArticleAdmin(admin.ModelAdmin):
class Media:
css = {
'all': ('admin/css/articleadmin.css',)
}
@daimon99
daimon99 / admin.py
Last active September 5, 2019 04:30
django默认显示只读页面,点击编辑之后再进入编辑页面
@admin.register(m.Article)
class ArticleAdmin(admin.ModelAdmin):
def get_readonly_fields(self, request, obj=None):
if 'edit' in request.GET or '/add/' == request.path[-5:]:
return self.readonly_fields
else:
return self.get_fields(request, obj)
@daimon99
daimon99 / nginx.conf
Last active September 5, 2019 04:49
django首页重定向
location = / {
try_files /index.html @django;
}
location @django {
proxy_pass http://127.0.0.1:9076;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@daimon99
daimon99 / essaygo_prd.conf
Created September 5, 2019 04:50
nginx最佳实践
server {
listen 80;
server_name essaygo.taijihuabao.com;
access_log /data/prd/essaygo/logs/essaygo.access.log main;
error_log /data/prd/essaygo/logs/essaygo.error.log warn;
root /data/prd/essaygo/www/;
gzip on;
gzip_min_length 4k;
gzip_comp_level 6;
@daimon99
daimon99 / singleton.py
Created September 8, 2019 14:15
python singleton
class Singleton(type):
_instances = {}
def __call__(cls, *args, **kwargs):
if cls not in cls._instances:
cls._instances[cls] = super().__call__(*args, **kwargs)
return cls._instances[cls]