Five Principles of Prompting

  1. Give Direction: Describe the desired style in detail, or reference a relevant persona.

    给出方向:详细描述所需的风格,或参考相关的人物角色。

  2. Specify Format: Define what rules to follow, and the required structure of the response.

    指定格式:定义要遵循的规则以及所需的响应结构。

  3. Provide Examples: Insert a diverse set of test cases where the task was done correctly.

    提供示例:插入正确完成任务的一组不同的测试用例。

  4. Evaluate Quality: Identify errors and rate responses, testing what drives performance.

    评估质量:识别错误并对响应进行评级,测试驱动性能的因素。

  5. Divide Labor: Split tasks into multiple steps, chained together for complex goals.

    分工:将任务分成多个步骤,链接在一起以实现复杂的目标。

Django Docker的部署时如何设置环境

1. 背景

在部署时,程序需要根据当前环境,设置不同参数,比如数据库,DEBUG是否打开等。


2. 实现方式

在构建Docker的时候设置环境变量:

1
2
3
4
5
RUN python manage.py collectstatic

ENV DJANGO_DEBUG_FALSE=1
ENV DJANGO_SECRET_KEY=sekrit
ENV DJANGO_ALLOWED_HOST=localhost

superlists/settings.py中添加判断:

1
2
3
4
5
6
7
8
9
10
import os
[...]
if "DJANGO_DEBUG_FALSE" in os.environ:
DEBUG = False
SECRET_KEY = os.environ["DJANGO_SECRET_KEY"]
ALLOWED_HOSTS = [os.environ["DJANGO_ALLOWED_HOST"]]
else:
DEBUG = True
SECRET_KEY = "insecure-key-for-dev"
ALLOWED_HOSTS = []

Data Management Policies

Policies

Appropriate Storage Policies

  1. Information must only be stored on company authorised storage media. USB sticks and other temporary storage solutions should not be used to hold corporate data.
  2. The appropriate storage solution for the information must be used.  This may be a structured database, Sharepoint, shared drives, document management systems, proprietary system or  archive solution.
More...

Categories of Data

Background

Certain type of data created as part of normal business activities might be used enterprise wide, whilst others may only be useful locally within a department or geographic region. The data maybe structured, for example an order held in the SAP system, or unstructured such as design document. The data can also differ from a retention and usage and perspective. Taking this into account different categories of data exist that have different management requirements.

Categories

Data Type Description
Analytical Data Created by transforming operational, unstructured, master and reference data to address specific decision support or reporting requirements.
Operational Data Generated from business activities and is given context by Master data and reference data, for example purchase orders, or sales orders.  It is subdivided into structured and unstructured data.
Enterprise Structure Data Represents the key structures of the enterprise and is particularly used for reporting business activity by responsibility.  Examples are Chart of Accounts and organisational structures.  Changes to enterprise structure data can have a high impact of historical reporting.
Master Data Refers to the core business data entities such as customer, product, vendor or parts.  It is used to provide context to operational data, for example the master data related to a Purchase Order would be the supplier, the goods or service types being supplied and the employee who raised the order.
Reference Data Any kind of data that is only used to categorise other data in a database and normally values have to confirm to one of several allowed values.  For eample the classification of an employee may be hourly paid, salaries or agency
Metadata The information used to describe the characteristics of a piece of corporate data, for example the meaning, format, and security classification.

HTTP API 设计指南

摘录自 HTTP API Design Guide

前言

我们的目标是一致性,专注业务逻辑同时避免设计上的空想,我们一直在寻找一种良好的,统一的,显而易见的API设计方式,未必只有一种方式。

以下内容供参考,另外,还可以看看大厂的设计规范:

内容

  • 返回合适的状态码

    为每一次的响应返回合适的HTTP状态码. 成功的HTTP响应应该使用如下的状态码:

    • 200GET请求成功, 以及DELETE或 PATCH 同步请求完成

    • 201POST 同步请求完成

    • 202POSTDELETE, 或 PATCH 异步请求将要完成

    • 206GET 请求成功, 这里只是一部分状态码: 更多

    参考 状态描述

  • 提供全部可用的资源

More...

Django Docker的部署方法

1. 背景

Django 程序如何部署有各种方法,我们今天使用Docker来部署

2. Docker打包

  • 将Django文件都移动到 src 子目录

  • 编写 Dockerfile 文件,输入以下内容:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    FROM python:slim
    RUN python -m venv /venv
    ENV PAth='/venv/bin;4path'

    COPY requirements.txt requirements.txt
    RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt

    COPY src /src
    WORKDIR /src
    CMD python manage.py migrate --noinput
    CMD python manage.py runserver 0.0.0.0:8888
  • 编写 requirement.txt 文件,输入以下内容:

    1
    django==4.2.7
  • 打包docker文件:

    1
    sudo docker build -t superlists .

    superlists 为docker名

  • 用前台方式运行docker:

    1
    sudo docker run -p 8888:8888 --mount type=bind,source=./src/db.sqlite3,target=/src/db.sqlite3 -it superlists

3. 安装guicorn

  • 添加 guicorn 到requirement.txt 文件:

    1
    2
    django==4.2.7
    gunicorn==21.2.0
  • 修改 Dockerfile 文件,替换最后一条语句:

    1
    CMD gunicorn --bind :8888 superlists.wsgi:application
  • 打包docker文件:

    1
    sudo docker build -t superlists .
  • 用前台方式运行docker:

    1
    sudo docker run -p 8888:8888 --mount type=bind,source=./src/db.sqlite3,target=/src/db.sqlite3 -it superlists

发现静态文件css没有加载,继续。

4. 安装Whitenoise

  • 继续修改requirement.txt :

    1
    2
    3
    django==4.2.7
    gunicorn==21.2.0
    whitenoise==6.6.0
  • 修改 src/superlists/settings.py,添加这个中间件:

    1
    2
    3
    4
    5
    MIDDLEWARE = [
    "django.middleware.security.SecurityMiddleware",
    "whitenoise.middleware.WhiteNoiseMiddleware",
    "django.contrib.sessions.middleware.SessionMiddleware",
    [...]
  • 打包docker文件:

    1
    sudo docker build -t superlists .

    superlists 为docker名

  • 用前台方式运行docker:

    1
    sudo docker run -p 8888:8888 --mount type=bind,source=./src/db.sqlite3,target=/src/db.sqlite3 -it superlists

成功加载。

英语单词辨析 - In the way or on the way

In the way or on the way

ref:原文

In the way

如果某物或某人“in the way”或“in my/his/our way”,意味着它占据了某人在特定动作或行动中所需的空间。

She can’t do her dance because the table is in the way. Can you help me move it?

On the way

当我们谈论去某个地方的路线、方向或路径时,我们使用“on the way”或“on my/his/our way (to)”。

We could leave early and have breakfast on the way. (during our journey to somewhere)

I was on my way to Peter’s house when I met him in the street. (I was going to Peter’s house when I met him)

我们可以使用“on the way to”(加上名词或动词的-ing形式)来表示接近做某事或完成某事。

Brazil is on the way to becoming one of the world’s strongest economies.

lsof command

Basic Syntax:

1
lsof [options] [file|socket|keyword]

Options:

  • a: Selects files or sockets that match all of the specified keywords.

  • c: Specifies a process ID (PID) to filter results by. For example, lsof -c 12345 would show only files and sockets used by process with PID 12345.

  • d: Specifies a directory to search for open files or sockets.

  • e: Excludes files or sockets that match the specified keyword(s).

  • f: Forces lsof to use a specific file type (e.g., FIFO, socket, etc.).

  • i: Selects Internet sockets only (default is all types of files and sockets).

More...

Payment Core System Design - 4

学习支付大佬文章,参考原文

这篇是系列文章的第4篇,下面是目录:

系列文章一 : 01. 全局内核

系列文章二 : 02. 交易内核 03. 支付内核

系列文章三 : 04. 清结算内核

系列文章四 : 05. 账户钱包内核 06. 对账内核 07. 二清内核 08. 调拨内核 09. 业财内核


05 账户钱包内核

支付离不开账户,钱包更离不开账户,把握账户对于做好支付来说至关重要,账户不止是一个记账,它是资金属性、监管政策一系列支付问题的集中体现。

内核19:账户系统把握

我在写账户系统时,做了这个脑图,用于把握账户的基础功能

More...

SS 显示套接字信息的工具

ss 命令是 Linux 系统上用于显示套接字信息的工具,它是 netstat 的替代品,提供了更多的功能和更好的性能。以下是 ss 命令的详细使用手册:

基础语法:

1
ss [options] [filter]

选项(Options):

  • a: 显示所有套接字,包括监听、已建立和关闭(not listening or closed)的套接字。默认仅显示监听或已建立的套接字。

  • l: 只显示监听套接字。

  • e: 只显示已建立的套接字。

  • p : 根据指定的进程 ID 过滤显示的套接字。

  • u : 根据用户名过滤显示的套接字。

  • n: 不解析主机名称,直接显示数字形式的 IP 地址。

  • r: 按照最近使用的顺序逆向排列输出(即最近活跃的套接字先显示)。

  • o: 指定输出格式,可以是 jsonxml 等格式。

  • i : 只显示特定网络接口上的套接字。

  • m : 只显示特定协议的套接字(例如,tcpudp)。

  • t <transport_family>: 指定传输层家族,如 inet(IPv4)、inet6(IPv6)或 unix(Unix 域套接字)。

More...

请我喝杯咖啡吧~

支付宝
微信