Debtap
发布时间:2023-03-26 15:54:44
归档分类:

Setup

==> You must run at least once "debtap -u"
with root privileges (preferably recently),
before running this script

==> Syntax: debtap [option] package_filename

==> Run "debtap -h" for help

Update debtap source

$ debtap -u

Convert deb package

debtap xxx.deb

Install

sudo pacman -U xxx.pkg
  • debtap
  • 工程 [2023_3_25] 附录文件「一」 - Flask 起步
    发布时间:2023-03-26 15:21:24
    归档分类:

    前言

    因为前段时间实验室老师要求我完成一个项目,是有关学校教务系统的,要求完成一个微信小程序。

    目前处于实验阶段,老师也没有给我需求文档,所以目前的情况就是做些东西练练手。这里记录一下,之后正式工作了能快速完成基本的构建。

    以下内容转载自 Flask官方文档

    Flask Installation

    Create an environment

    Create a project folder and a venv folder within:

    $ mkdir myproject
    $ cd myproject
    $ python3 -m venv venv
    

    Activate the environment

    Before you work on your project, activate the corresponding environment:

    $ . venv/bin/activate
    

    Install Flask

    Within the activated environment, use the following command to install Flask:

    $ pip install Flask
    

    Quickstart

    A minimal Flask application looks something like this:

    from flask import Flask
    
    app = Flask(__name__)
    
    @app.route("/")
    def hello_world():
        return "<p>Hello, World!</p>"
    

    So what did that code do?

    1. First we imported the Flask class. An instance of this class will be our WSGI application.

    2. Next we create an instance of this class. The first argument is the name of the application’s module or package. __name__ is a convenient shortcut for this that is appropriate for most cases. This is needed so that Flask knows where to look for resources such as templates and static files.

    3. We then use the route() decorator to tell Flask what URL should trigger our function.

    4. The function returns the message we want to display in the user’s browser. The default content type is HTML, so HTML in the string will be rendered by the browser.

    Save it as hello.py or something similar. Make sure to not call your application flask.py because this would conflict with Flask itself.

    To run the application, use the flask command or python -m flask. You need to tell the Flask where your application is with the --app option.

    $ flask --app hello run
     * Serving Flask app 'hello'
     * Running on http://127.0.0.1:5000 (Press CTRL+C to quit)
    

    Externally Visible Server

    If you run the server you will notice that the server is only accessible from your own computer, not from any other in the network. This is the default because in debugging mode a user of the application can execute arbitrary Python code on your computer.

    If you have the debugger disabled or trust the users on your network, you can make the server publicly available simply by adding --host=0.0.0.0 to the command line:

    $ flask run --host=0.0.0.0
    

    This tells your operating system to listen on all public IPs.

    Debug

    To enable debug mode, use the --debug option.

    $ flask --app hello run --debug
     * Serving Flask app 'hello'
     * Debug mode: on
     * Running on http://127.0.0.1:5000 (Press CTRL+C to quit)
     * Restarting with stat
     * Debugger is active!
     * Debugger PIN: nnn-nnn-nnn
    

    Routing

    Modern web applications use meaningful URLs to help users. Users are more likely to like a page and come back if the page uses a meaningful URL they can remember and use to directly visit a page.

    Use the route() decorator to bind a function to a URL.

    @app.route('/')
    def index():
        return 'Index Page'
    
    @app.route('/hello')
    def hello():
        return 'Hello, World'
    

    HTTP Methods

    Web applications use different HTTP methods when accessing URLs. You should familiarize yourself with the HTTP methods as you work with Flask. By default, a route only answers to GET requests. You can use the methods argument of the route() decorator to handle different HTTP methods.

    from flask import request
    
    @app.route('/login', methods=['GET', 'POST'])
    def login():
        if request.method == 'POST':
            return do_the_login()
        else:
            return show_the_login_form()
    

    The Request Object

    The request object is documented in the API section and we will not cover it here in detail (see Request). Here is a broad overview of some of the most common operations. First of all you have to import it from the flask module:

    from flask import request
    

    The current request method is available by using the method attribute. To access form data (data transmitted in a POST or PUT request) you can use the form attribute. Here is a full example of the two attributes mentioned above:

    @app.route('/login', methods=['POST', 'GET'])
    def login():
        error = None
        if request.method == 'POST':
            if valid_login(request.form['username'],
                           request.form['password']):
                return log_the_user_in(request.form['username'])
            else:
                error = 'Invalid username/password'
        # the code below is executed if the request method
        # was GET or the credentials were invalid
        return render_template('login.html', error=error)
    
  • 开发记录
  • Flask
  • 隐函数 + 二阶导 = 💩
    发布时间:2023-03-20 19:37:49
    归档分类:

    我宣布,我郑重宣布!!!

    计算隐函数的二阶导数,是比💩💩💩还恶心的东西。

    计算过程又臭又长。

    事情的经过

    事情的经过是这样的,我今天遇到了一道题: $$ \left\{\begin{aligned}x&=3t^2+2t+3\\e^y&sint-y+1=0\end{aligned}\right. $$

    要求计算 \(\frac{\mathrm{d^2} y}{\mathrm{d} x^2}\) 在 \(t=0\) 的值

    当我看到 \(e^ysint-y+1=0 \) 的时候就深感不妙,果不其然,在导的过程中,无数次想死 qvq。

  • 吐槽
  • 存储扩展
    发布时间:2023-03-04 13:18:01
    归档分类:

    在使用了两年的双系统后,逐渐感觉到了512G是远远不够的,但暂时没有更换硬盘的资金,所以,我计划分别购入256G和128G的SD卡作为系统的扩展。

    速度测试

    由于不是 SSD 硬盘,而且 SD 卡被设计出来主要就是静态的存储,没有类似主控的东西,所以无论是速度还是质量都是难堪大任的,但由于我平时并不怎么使用 windows , 所以尚能接受。

    但为了保险起见,我将使用一张 64G 的 tf 卡测试其最小性能。

    64G 的 tf 卡满足整体的使用,所以我购买了一张 128G 的 SD 卡作为虚拟机的硬盘,显然在速度方面它的能够满足我的使用的,那么自要做好备份工作就没问题了。

    闪迪 256G 固态U盘

    事实上在这个容量上,买一盘固态硬盘更好,同样的价格可以来到500G的容量,而且安全性肯定也是更高的,但是考虑到U盘的体积,所以,我更偏爱于这个U盘。

    对于这个U盘,我可能有以下打算:

    1.仍然保留双系统,这个固态U盘作为虚拟机硬盘使用。这个打算主要是考虑到SD卡的使用寿命并不安全,很可能在我工作时崩坏,这会导致严重的后果。而这个U盘显然更加的安全一些。

    2.不再保留双系统,Linux 系统将独占整个512G的硬盘,同时分离128G出来给Windows虚拟机,之前购买的128G的SD卡作为资料存储卡,256G的固态U盘将安装为 Windows 系统。

    我更喜欢第二种方案,因为它更安全可靠。

  • 存储
  • 闪迪
  • tf 卡
  • 固态
  • 博文转移完毕
    发布时间:2023-02-24 00:56:03
    归档分类:

    由于之前的博客存储在了 sqlite3 数据库里,显然是没办法直接导入 Hexo 所识别的格式的,所以用 python 写了 一个小脚本,方便博文的转移。

    import sqlite3
    from datetime import datetime
    conn = sqlite3.connect("Hsunr.db")
    cursor = conn.cursor()
    
    cursor.execute('select * from post')
    values = cursor.fetchall()
    for item in values:
        file_name = "{}-{}.md".format(item[5],item[1].replace(' ','-'))
        dt_obj = datetime.strptime(item[0], '%Y%m%d%H%M%S')
        content = "---\n" \
                  "title: {}\n" \
                  "date: {}\n" \
                  "tags:\n" \
                  "categories: {}\n" \
                  "---\n"\
                  "{}".format(item[1],dt_obj,item[3],item[2])
        f = open(file_name,'w');
        f.write(content)
    
  • 日志
  • python
  • 停止维护 Hsunr 和 December 项目
    发布时间:2023-02-23 17:12:00
    归档分类:

    事情的经过

    2023年2月28日,我的学生价腾讯服务器正式回复原价,一年800块的价格属实有些承受不起;

    由于这两个项目都是搭载在服务器端的,服务器停止后近几年也不再有机会在服务器运行维护,从而发现问题,所以从现在开始停止维护 Hsunr和 December这两个项目。

    转移至 Hexo

    原先基于 Hsunr 项目的博客系统转移到基于 Hexo 的静态博客中,由 Github 托管。在转移的过程中,顺带着写了一套 Hexo 的主题,比较用别人的主题总感觉不是很舒服。

  • 开发记录
  • 2023 新的一年
    发布时间:2023-01-01 17:41:23
    归档分类:

    致美好与苦难

  • 新年
  • 生日生日
    发布时间:2022-12-10 15:03:49
    归档分类:

    祝自己生日快乐!!!!

  • 生日