Total Pageviews

Saturday, 6 June 2026

梨花情

 

相关帖子:https://briteming.blogspot.com/2012/10/blog-post_6642.html ,梨花确实漂亮

full-stack-fastapi-template

 Full stack, modern web application template. Using FastAPI, React, SQLModel, PostgreSQL, Docker, GitHub Actions, automatic HTTPS and more. 

 

Full Stack FastAPI Template

Test Docker Compose Test Backend Coverage

Technology Stack and Features

  • FastAPI for the Python backend API.
    • 🧰 SQLModel for the Python SQL database interactions (ORM).
    • 🔍 Pydantic, used by FastAPI, for the data validation and settings management.
    • 💾 PostgreSQL as the SQL database.
  • 🚀 React for the frontend.
    • 💃 Using TypeScript, hooks, Vite, and other parts of a modern frontend stack.
    • 🎨 Tailwind CSS and shadcn/ui for the frontend components.
    • 🤖 An automatically generated frontend client.
    • 🧪 Playwright for End-to-End testing.
    • 🦇 Dark mode support.
  • 🐋 Docker Compose for development and production.
  • 🔒 Secure password hashing by default.
  • 🔑 JWT (JSON Web Token) authentication.
  • 📫 Email based password recovery.
  • 📬 Mailcatcher for local email testing during development.
  • ✅ Tests with Pytest.
  • 📞 Traefik as a reverse proxy / load balancer.
  • 🚢 Deployment instructions using Docker Compose, including how to set up a frontend Traefik proxy to handle automatic HTTPS certificates.
  • 🏭 CI (continuous integration) and CD (continuous deployment) based on GitHub Actions.

Dashboard Login

API docs

Dashboard - Admin

API docs

Dashboard - Items

API docs

Dashboard - Dark Mode

API docs

Interactive API Documentation

API docs

How To Use It

You can just fork or clone this repository and use it as is.

✨ It just works. ✨

How to Use a Private Repository

If you want to have a private repository, GitHub won't allow you to simply fork it as it doesn't allow changing the visibility of forks.

But you can do the following:

  • Create a new GitHub repo, for example my-full-stack.
  • Clone this repository manually, set the name with the name of the project you want to use, for example my-full-stack:
git clone git@github.com:fastapi/full-stack-fastapi-template.git my-full-stack
  • Enter into the new directory:
cd my-full-stack
  • Set the new origin to your new repository, copy it from the GitHub interface, for example:
git remote set-url origin git@github.com:octocat/my-full-stack.git
  • Add this repo as another "remote" to allow you to get updates later:
git remote add upstream git@github.com:fastapi/full-stack-fastapi-template.git
  • Push the code to your new repository:
git push -u origin master

Update From the Original Template

After cloning the repository, and after doing changes, you might want to get the latest changes from this original template.

  • Make sure you added the original repository as a remote, you can check it with:
git remote -v

origin    git@github.com:octocat/my-full-stack.git (fetch)
origin    git@github.com:octocat/my-full-stack.git (push)
upstream    git@github.com:fastapi/full-stack-fastapi-template.git (fetch)
upstream    git@github.com:fastapi/full-stack-fastapi-template.git (push)
  • Pull the latest changes without merging:
git pull --no-commit upstream master

This will download the latest changes from this template without committing them, that way you can check everything is right before committing.

  • If there are conflicts, solve them in your editor.

  • Once you are done, commit the changes:

git merge --continue

Configure

You can then update configs in the .env files to customize your configurations.

Before deploying it, make sure you change at least the values for:

  • SECRET_KEY
  • FIRST_SUPERUSER_PASSWORD
  • POSTGRES_PASSWORD

You can (and should) pass these as environment variables from secrets.

Read the deployment.md docs for more details.

Generate Secret Keys

Some environment variables in the .env file have a default value of changethis.

You have to change them with a secret key, to generate secret keys you can run the following command:

python -c "import secrets; print(secrets.token_urlsafe(32))"

Copy the content and use that as password / secret key. And run that again to generate another secure key.

How To Use It - Alternative With Copier

This repository also supports generating a new project using Copier.

It will copy all the files, ask you configuration questions, and update the .env files with your answers.

Install Copier

You can install Copier with:

pip install copier

Or better, if you have pipx, you can run it with:

pipx install copier

Note: If you have pipx, installing copier is optional, you could run it directly.

Generate a Project With Copier

Decide a name for your new project's directory, you will use it below. For example, my-awesome-project.

Go to the directory that will be the parent of your project, and run the command with your project's name:

copier copy https://github.com/fastapi/full-stack-fastapi-template my-awesome-project --trust

If you have pipx and you didn't install copier, you can run it directly:

pipx run copier copy https://github.com/fastapi/full-stack-fastapi-template my-awesome-project --trust

Note the --trust option is necessary to be able to execute a post-creation script that updates your .env files.

Input Variables

Copier will ask you for some data, you might want to have at hand before generating the project.

But don't worry, you can just update any of that in the .env files afterwards.

The input variables, with their default values (some auto generated) are:

  • project_name: (default: "FastAPI Project") The name of the project, shown to API users (in .env).
  • stack_name: (default: "fastapi-project") The name of the stack used for Docker Compose labels and project name (no spaces, no periods) (in .env).
  • secret_key: (default: "changethis") The secret key for the project, used for security, stored in .env, you can generate one with the method above.
  • first_superuser: (default: "admin@example.com") The email of the first superuser (in .env).
  • first_superuser_password: (default: "changethis") The password of the first superuser (in .env).
  • smtp_host: (default: "") The SMTP server host to send emails, you can set it later in .env.
  • smtp_user: (default: "") The SMTP server user to send emails, you can set it later in .env.
  • smtp_password: (default: "") The SMTP server password to send emails, you can set it later in .env.
  • emails_from_email: (default: "info@example.com") The email account to send emails from, you can set it later in .env.
  • postgres_password: (default: "changethis") The password for the PostgreSQL database, stored in .env, you can generate one with the method above.
  • sentry_dsn: (default: "") The DSN for Sentry, if you are using it, you can set it later in .env.

Backend Development

Backend docs: backend/README.md.

Frontend Development

Frontend docs: frontend/README.md.

Deployment

Deployment docs: deployment.md.

Development

General development docs: development.md.

This includes using Docker Compose, custom local domains, .env configurations, etc.

Release Notes

Check the file release-notes.md.

from  https://github.com/fastapi/full-stack-fastapi-template

Redis-for-beginners

 

Part 1: Redis for Beginners (Part 1 of 2)

Introduction

Redis has come a long way through an evolution and, by now, it can be placed as your primary database—not just a cache layer. It features added data persistence and replication for durability and availability. Additional modules for JSON support and search make it easier to store and query more complex data. Now, Redis has an Object mapping library, Redis OM, which simplifies things.

In this two-part series, the focus is on the core of Redis. This is the first part, which will guide you through setting up a Redis database and using some basic commands.

Setting Up a Redis Database

On a Macbook, use Homebrew

First, make sure you have Homebrew installed. From the terminal, run:

brew --version

If this command fails, you'll need to follow the Homebrew installation instructions.

Installation

From the terminal, run:

brew install redis

This will install Redis on your system.

On a Windows, use WSL

Microsoft provides detailed instructions for installing WSL. Once you're running Ubuntu on Windows, you can follow the steps detailed at Redis Site Installation Steps which are the same steps for installing Redis on Linux to install recent stable versions of Redis from the official packages.

Using Redis Cloud

The last option for installing Redis is called Redis Cloud, and that's what you’ll be using here. It allows you to set up a Redis database online. It also comes with Redis insights that can be used to test different commands and visualize your stored data.

To use the Redis database online, follow the steps below:

  1. Sign Up for a Free Redis Account:

    • Visit the Redis website (https://redis.io/) and sign up for a free account.
    • Provide the necessary details and create your account.
  2. Create a Subscription:

    • Once logged in, navigate to the “Subscriptions” section (usually found in the left-hand menu).
    • Click on “New Database” or a similar option.
    • Scroll down and select the free tier, which typically comes with 30MB of storage.
    • Click on “Create Database.”
  3. Download the Redis App:

    • To work with Redis locally, download the Redis app for your system (Windows, macOS, or Linux).
    • Install the app following the instructions provided.
  4. Connect to Your Database:

    • After creating the database, find the “Connect” option and click on it.
    • Click on the "Open with RedisInsights" button. This will launch your installed Redis application.

Basic Commands

When using your RedisInsights application, navigate to your workbench. You can access your workbench by clicking on this icon:

SET: Using the SET Command to Set a Key-Value Pair

To set a key-value pair in Redis, follow these steps:

  1. In your workbench input section, type the following command:
SET key value

Replace key with the name of the key you want to set, and value with the corresponding value you want to assign to that key.

  1. Press CTRL + Enter to execute the command. For example, executing SET name maria will set the value "maria" for the key name.

  2. You should receive the message "OK" in the output section below, confirming that the key-value pair was successfully set.

  3. To verify, go back to the Redis browser, switch to the data view, and refresh the view to see the updated key-value pair.

Error Handling:

If you include a space in your data without quotes, you’ll get a syntax error. To include spaces, enclose the data in quotes.

Example:

SET name "chun li"

GET: Retrieving a Value by Key

To retrieve the value of a specific key, use the GET command. In your workbench, type:

GET key

Replace key with the name of the key you want to retrieve. For example, if you have a key named name with the value "chun li", executing GET name will return "chun li". Press CTRL + Enter to execute the command.

DEL: Deleting Keys

To delete one or more keys and their associated values, use the DEL command. In your workbench, type:

DEL key1 key2 key3 ...

Replace key1, key2, key3, etc., with the names of the keys you want to delete. For example:

DEL name1 name2

Executing this command will delete the keys name1 and name2 along with their respective values. The command will return an integer indicating the number of keys deleted. For instance, a response of 2 indicates that two keys were successfully deleted. Press CTRL + Enter to execute the command.

SET MULTIPLE: Setting Multiple Key-Value Pairs

To set multiple key-value pairs simultaneously, use the MSET command. In your workbench, use:

MSET key1 value1 key2 value2 key3 value3

Replace key1, key2, key3, etc., with the names of the keys you want to set, and value1, value2, value3, etc., with their respective values. For instance:

MSET name1 maria name2 yoshi color green rating 10

This command sets the keys name1, name2, color, and rating with their respective values. Press CTRL + Enter. Ensure the key comes first, followed by the value.

GET MULTIPLE: Retrieving Multiple Values

To retrieve values for multiple keys at once, use the MGET command. In your workbench, use:

MGET key1 key2 key3

Replace key1, key2, key3, etc., with the names of the keys you want to retrieve. For example:

MGET name1 name2 rating

This command will return the values associated with keys name1, name2, and rating. Press CTRL + Enter. The values "maria", "Yoshi", and "10" will be returned in the output section.

GETRANGE: Retrieving Substrings

To retrieve a substring of the value of a key, use the GETRANGE command. In your workbench, use:

GETRANGE key start end

Replace key with the name of the key, start with the starting index, and end with the ending index. For example:

GETRANGE name 0 4

This command will return the substring of the value of name from index 0 to 4. If name has the value "chun li", the command will return "chun ".

Conclusion of Part 1

In this first part of our Redis for Beginners series, you learned how to set up a Redis database and run basic commands such as setting, getting, deleting, and retrieving multiple key-value pairs. These are basic skills that anyone working with Redis should be conversant with.

In the next part of this series, we will explore more advanced commands, command options, and go into the differences between lists and sets in Redis. Stay tuned!

from  https://github.com/topeogunleye/Writing/blob/master/Redis-for-beginners-Part-1.md

--------------- 

 

Part 2: Redis for Beginners (Part 2 of 2)

Introduction

Welcome to the second part of our Redis for Beginners series. In the first part, we covered the basics of setting up a Redis database and executing fundamental commands. In this second part, we will explore advanced command options and delve into the differences between lists and sets in Redis.

Command Options

Not all commands have options, but a few, for example SET, have certain added features that can be essential.

  • EX seconds: Sets an expiration time in seconds (must be a positive integer).
  • PX milliseconds: Sets an expiration time in milliseconds (must be a positive integer).
  • EXAT timestamp-seconds: Sets a specific Unix timestamp for expiration (must be a positive integer).
  • NX: Sets the key only if it does not already exist.
  • XX: Sets the key only if it already exists.

You can't use NX and XX together because they will conflict with each other. Also, you can use only one option for expiration (EX or PX) at a time. To learn more about the SET command visit here to check out the Redis documentation page.

Example: SET Command Using the EX Option

When executing the following at your workbench, you will define a key with an expiration in Redis:

SET key value EX seconds

Replace key with the name of the key that contains the string and value with the new value you would like to store. Replace seconds with the amount of time, in seconds, after which the key should expire.

For example, if you have a key name currently holding the value "Mario", and you want to replace it with "Yoshi" after 7 seconds, run:

SET name Yoshi EX 7

This command updates the value of name to "Yoshi" and sets an expiration of 7 seconds from the time the command is executed.

Example: SET Command with NX and XX Options

You can set the key conditionally with respect to its existence in Redis by using the options NX, which stands for Not eXists, and XX, which stands for eXists, in the SET command:

Using NX (Not eXists) Option:

SET key value NX
  • Replace key with the name of the key you want to set.
  • Replace value with the value you want to store in the key.

This command sets the value of key to value only if key does not already exist. If key already exists, the command will not perform any action.

Example:

If you want to set a new key username to "alice" only if username does not already exist, you would use:

SET username alice NX

**Using `XX

` (eXists) Option:**

SET key value XX

This command sets the value of key to value only if key already exists. If key does not exist, the command will not perform any action.

Example:

If you want to update the value of an existing key username to "bob" only if username already exists, you would use:

SET username bob XX

Lists vs. Sets

Lists

  • An ordered collection of strings.
  • Supports operations like adding elements to the head or tail, trimming based on ranges, etc.
  • Useful for maintaining ordered data structures.
  • Commands: RPUSH, LPUSH, LRANGE, LPOP, RPOP, etc.

Sets

  • An unordered collection of unique strings.
  • Supports operations like adding, removing, and checking membership.
  • Useful for storing unique items and performing set operations.
  • Commands: SADD, SREM, SMEMBERS, SISMEMBER, etc.

When deciding between lists and sets, consider the order requirements and the need for uniqueness in your data.


Conclusion

Redis has come a long way through an evolution and, by now, it can be placed as your primary database—not just a cache layer. It features added data persistence and replication for durability and availability. Additional modules for JSON support and search make it easier to store and query more complex data. Now, Redis has an Object mapping library, Redis OM, which simplifies things. In this series, the focus is on the core of Redis.

from  https://github.com/topeogunleye/Writing/blob/master/Redis-for-beginners-Part-2.md

Friday, 5 June 2026

男朋友

-80年代中期,从台湾传到了大陆。

Expo is an open-source platform for making universal native apps for Android, iOS, and the web with JavaScript and React



With Expo tools, services, and React, you can build, deploy, and quickly iterate on native Android, iOS, and web apps from the same JavaScript codebase.

    Access to device capabilities like camera, location, notifications, sensors, haptics, and much more, all with universal APIs.

    Build service gives you app-store ready binaries and handles certificates, no need for you to touch Xcode or Android Studio.

    Over-the-air updates let you update your app at any time without the hassle and delays of submitting to the store.

Quick Start

If you are already experienced with React and JavaScript tooling and want to dive right in and figure things out as you go, this is the quickest way to get started:

$ npm install -g expo-cli
$ expo init my-project
$ cd my-project
$ expo start