first commit

This commit is contained in:
2024-03-12 00:26:54 -04:00
commit 3d476f095c
222 changed files with 26485 additions and 0 deletions

View File

@@ -0,0 +1,312 @@
---
title: Claude 3 Opus's Performance in C Language Exam
subtitle:
date: 2024-03-11T20:17:44-04:00
slug: claude-3-opus-c-exam
draft: false
author:
name: James
link: https://www.jamesflare.com
email:
avatar: /site-logo.avif
description: This blog post presents a simulated C language programming exam, featuring question types such as fill-in-the-blanks, short answer questions, and application problems. The objective is to comprehensively assess students' mastery of C language knowledge, problem-solving abilities, and skills in writing efficient and elegant code. Through such a mock test, students can identify their weaknesses and make thorough preparations for the actual exam. At the same time, it provides readers with an intuitive understanding of the key points in C language assessment.
keywords: ["C Language", "Exam", "Programming Questions"]
license:
comment: true
weight: 0
tags:
- C
- Exam
- Claude
- LLM
- Benchmark
categories:
- Review
- Programming
- LLM
hiddenFromHomePage: false
hiddenFromSearch: false
hiddenFromRss: false
hiddenFromRelated: false
summary: This blog post presents a simulated C language programming exam, featuring question types such as fill-in-the-blanks, short answer questions, and application problems. The objective is to comprehensively assess students' mastery of C language knowledge, problem-solving abilities, and skills in writing efficient and elegant code. Through such a mock test, students can identify their weaknesses and make thorough preparations for the actual exam. At the same time, it provides readers with an intuitive understanding of the key points in C language assessment.
resources:
- name: featured-image
src: featured-image.jpg
- name: featured-image-preview
src: featured-image-preview.jpg
toc: true
math: true
lightgallery: false
password:
message:
repost:
enable: true
url:
# See details front matter: https://fixit.lruihao.cn/documentation/content-management/introduction/#front-matter
---
<!--more-->
{{< admonition type=note title="System Prompt" open=true >}}
You are playing the role of a student learning C language. Your current task is to take an exam on C language. In this exam, you need to perform your best and answer in as much detail as possible to obtain a high score. All examinees, good luck!
{{< /admonition >}}
## Fill-in-the-Blank Questions
1. The working principle of computers is (**A**).
**A** = stored program and program control
2. Integers are represented in memory using binary (**B**) code.
**B** = two's complement
3. There are (**C**) types of relational operators.
**C** = 6 (<, <=, >, >=, ==, !=)
4. There are (**D**) forms of loop statements.
**D** = 3 (while, do-while, for)
5. Using functions requires three steps: (**E**), definition, and calling.
**E** = declaration
6. Array elements are stored (**F**) in memory.
**F** = contiguously
7. The two elements of a pointer are address and (**G**).
**G** = data type
8. To use math library functions, the header file to be included is (**H**).
**H** = <math.h>
9. Variables defined outside of functions are called (**I**) variables.
**I** = global
10. The keyword for defining structure types is (**J**).
**J** = struct
## Short Answer Questions
1. **The roles of break and continue statements**:
The break statement is used to jump out of the current loop body and terminate the loop execution. When the break statement is encountered, the program immediately exits the loop it is in and starts executing the statement following the loop.
The continue statement is used to skip the remaining statements of the current iteration and directly proceed to the next iteration. When the continue statement is encountered, the program immediately jumps to the loop control expression and begins the next iteration.
2. **Solution for returning multiple values from a function**:
Pointers can be used as function parameters to pass the addresses of multiple variables. By modifying the values of these variables inside the function, the effect of returning multiple values can be achieved.
For example, write a function to calculate the sum and difference of two integers and return the results through pointers:
```c
void calc(int a, int b, int *sum, int *diff) {
*sum = a + b;
*diff = a - b;
}
```
Calling the function in main:
```c
int main() {
int x = 10, y = 5, sum, diff;
calc(x, y, &sum, &diff);
printf("Sum: %d, Diff: %d\n", sum, diff);
return 0;
}
```
3. **Situations that require dynamic memory allocation**:
When the required memory size can only be determined at runtime, or when memory needs to be frequently allocated and released, dynamic memory allocation should be used.
For example, reading a file and storing its content in memory. Since the file size is unknown in advance, memory needs to be dynamically allocated based on the actual number of bytes read:
```c
FILE *fp = fopen("data.txt", "r");
char *buffer = NULL;
int size = 0;
int capacity = 0;
char ch;
while ((ch = fgetc(fp)) != EOF) {
if (size + 1 > capacity) {
capacity = (capacity == 0) ? 1 : capacity * 2;
buffer = (char *)realloc(buffer, capacity);
}
buffer[size++] = ch;
}
buffer[size] = '\0';
fclose(fp);
```
4. **The basic idea of the exhaustive method**:
The exhaustive method is a fundamental algorithmic approach. Its basic idea is to enumerate all possible cases, check each case one by one to determine if it satisfies the problem requirements, and thus obtain the solution to the problem.
For example, to find all prime numbers between 1 and 100. The exhaustive method can be used to traverse each number from 1 to 100 and determine whether it is a prime number:
```c
for (int i = 2; i <= 100; i++) {
int isPrime = 1;
for (int j = 2; j < i; j++) {
if (i % j == 0) {
isPrime = 0;
break;
}
}
if (isPrime) {
printf("%d ", i);
}
}
```
5. **Practical problems suitable for storing data using arrays**:
(1) Student grade management system: Arrays can be used to store each student's scores in various subjects, which is convenient for score input, query, and statistics.
(2) Image processing: An image can be regarded as a two-dimensional array, where each element represents the pixel value at the corresponding position. Using arrays facilitates image reading, modification, and display operations.
## Application Questions
1. **A three-digit decimal integer is called a "narcissistic number" if the sum of the cubes of its three digits equals the number itself (for example, $153 = 1^3 + 5^3 + 3^3$). Please define a function to determine whether an integer is a narcissistic number, and use this function to print out all narcissistic numbers.**
```c
#include <stdio.h>
#include <math.h>
int isNarcissistic(int num) {
int sum = 0;
int temp = num;
while (temp > 0) {
int digit = temp % 10;
sum += pow(digit, 3);
temp /= 10;
}
return (sum == num);
}
int main() {
printf("All narcissistic numbers:\n");
for (int i = 100; i <= 999; i++) {
if (isNarcissistic(i)) {
printf("%d ", i);
}
}
return 0;
}
```
2. **Given the iterative relation $x_{k+1} = \frac{4}{3}x_{k} - \frac{a}{3x^{2}_{k}}$, where $a \in \mathbb{R}$, and $\\{ x_k \\}$ converges. Write a program to estimate the limit value of $x_k$.**
```c
#include <stdio.h>
#include <math.h>
#define EPSILON 1e-6
double iterate(double x, double a) {
return (4.0 / 3.0) * x - a / (3 * x * x);
}
int main() {
double a;
printf("Please enter the value of parameter a: ");
scanf("%lf", &a);
double x0 = 1.0; // Initial value
double x1 = iterate(x0, a);
while (fabs(x1 - x0) > EPSILON) {
x0 = x1;
x1 = iterate(x0, a);
}
printf("The estimated limit value of the iterative sequence is: %.6f\n", x1);
return 0;
}
```
3. **There are n students, and the information of each student includes name and score. Use dynamic memory allocation to store the data and complete the following operations:**
```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_NAME 20
typedef struct {
char name[MAX_NAME];
int score;
} Student;
void inputStudents(Student *students, int n) {
for (int i = 0; i < n; i++) {
printf("Please enter the name and score of student %d: ", i + 1);
scanf("%s %d", students[i].name, &students[i].score);
}
}
void printStudents(Student *students, int n) {
printf("Student information:\n");
for (int i = 0; i < n; i++) {
printf("Name: %s\tScore: %d\n", students[i].name, students[i].score);
}
}
void sortStudents(Student *students, int n) {
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (students[j].score < students[j + 1].score) {
Student temp = students[j];
students[j] = students[j + 1];
students[j + 1] = temp;
}
}
}
}
int main() {
int n;
printf("Please enter the number of students: ");
scanf("%d", &n);
Student *students = (Student *)malloc(n * sizeof(Student));
inputStudents(students, n);
printStudents(students, n);
sortStudents(students, n);
printf("Student information sorted by score in descending order:\n");
printStudents(students, n);
free(students);
return 0;
}
```
The above program implements the following functions:
1. Defined a student structure that includes name and score fields.
2. Created a student structure array of size n using dynamic memory allocation.
3. Provided functions for inputting student information, printing student information, and sorting student information by score in descending order.
4. In the main function, first input the number of students, then dynamically allocate memory to create a student array.
5. Call the corresponding functions to input student information, print student information, sort students by score in descending order, and print the sorted results.
6. Finally, free the dynamically allocated memory.

View File

@@ -0,0 +1,662 @@
---
title: Create MCQs with ChatGPT in Scales
subtitle:
date: 2023-03-04T16:45:19+08:00
slug: create-mcq-chatgpt-scales
draft: false
author:
name: James
link: https://www.jamesflare.com
email:
avatar: /site-logo.avif
description: This blog post demonstrates how to create multiple-choice question (MCQ) papers using ChatGPT, Python, and JSON files, covering the process from generating a question bank to formatting and building the final test papers, answer sheets, and marking schemes.
keywords: ["MCQ","ChatGPT","Python","JSON"]
license:
comment: true
weight: 0
tags:
- ChatGPT
- Python
categories:
- Tutorials
- LLM
hiddenFromHomePage: false
hiddenFromSearch: false
hiddenFromRss: false
hiddenFromRelated: false
summary: This blog post demonstrates how to create multiple-choice question (MCQ) papers using ChatGPT, Python, and JSON files, covering the process from generating a question bank to formatting and building the final test papers, answer sheets, and marking schemes.
resources:
- name: featured-image
src: featured-image.jpg
- name: featured-image-preview
src: featured-image-preview.jpg
toc: true
math: false
lightgallery: false
password:
message:
repost:
enable: true
url:
# See details front matter: https://fixit.lruihao.cn/documentation/content-management/introduction/#front-matter
---
<!--more-->
## Introduction
Hi, dear teachers!
Did you have difficulty on creating test paper for students?
In this post, I am going to show you how to create MCQs in scales and randomly pick a selected number of questions out, then make it into three formatted editable Word documents, includes test paper, answer sheet and marking scheme.
### Steps
1. Ask ChatGPT to make a .json format question bank.
2. Format the .json question bank through a Python Program.
3. Make another Python Program to create papers from the .json question bank.
## Prompt Engineering
Here is the first step. We want the MCQs fit for the topic. To do that, we need tell the ChatGPT what is should do, and where to do.
You may do your prompt like this format
> \[Instruction\] +
>
> \[Templates\] +
>
> \[Learning Objects\] +
>
> \[Topic Concepts\] +
>
> \[Additional Points\] +
>
> \[MCQ Command Words\] +
>
> \[Rules for ChatGPT\]
I made a non-perfect example on Astrophysics, which means not all objects were covered. So, the MCQs can be a bit boring under mass generation. But they will not repeat, at least in options.
Therefore, students who memorize options will be ended.
### Example
{{< admonition type=warning title="This is not The Raw Input" open=true >}}
To make it easier to read, I made the Raw Markdown input into this Web Page.
If you want check out the Raw input, check the end of this section. There is a dropdown box.
{{< /admonition >}}
> You are an AI-powered json file generator that never make mistakes, and you are going to imagine 1000 MCQs about Astrophysics first in mind, then randomly give me 15 of them in this json form:
>
> ```json
> [
> {
> "order_number": "[Order Number]",
> "question": "[Question]",
> "type": "mcq",
> "option_a": "[Option A]",
> "option_b": "[Option B]",
> "option_c": "[Option C]",
> "option_d": "[Option D]",
> "answer": "[Correct Option in ABCD]",
> "explanation": "[Explanation of Why This Answer]"
> },
> {
> "order_number": "[Order Number]",
> "question": "[Question]",
> "type": "mcq",
> "option_a": "[Option A]",
> "option_b": "[Option B]",
> "option_c": "[Option C]",
> "option_d": "[Option D]",
> "answer": "[Correct Option in ABCD]",
> "explanation": "[Explanation of Why This Answer]"
> }
> ]
> ```
>
> Please check the understanding of these Learning objectives in your generated MCQs:
>
> 1. Describe the main objects comprising the universe.
>
> 2. Describe the nature of stars.
>
> 3. Understand astronomical distances.
>
> 4. Work with the method of parallax.
>
> 5. Define luminosity and apparent brightness and solve problems with these quantities and distance.
>
> And these key concepts as well:
> |Term|Definition|
> |:----|:----|
> |Binary star|Two stars orbiting a common centre|
> |Black dwarf|The remnant of a white dwarf after it has cooled down. It has very low luminosity|
> |Black hole|A singularity in space time; the end result of the evolution of a very massive star|
> |Brown dwarf|Gas and dust that did not reach a high enough temperature to initiate fusion. These objects continue to compact and cool down|
> |Cepheid variable|A star of variable luminosity. The luminosity increases sharply and falls off gently with a well-defined period. The period is related to the absolute luminosity of the star and so can be used to estimate the distance to the star|
> |Cluster of galaxies|Galaxies close to one another and affecting one another gravitationally, behaving as one unit|
> |Comet|A small body (mainly ice and dust) orbiting the Sun in an elliptical orbit|
> |Constellation|A group of stars in a recognizable pattern that appear to be near each other in space|
> |Dark matter|Generic name for matter in galaxies and clusters of galaxies that is too cold to radiate. Its existence is inferred from techniques other than direct visual observation|
> |Galaxy|A collection of a very large number of stars mutually attracting one another through the gravitational force and staying together. The number of stars in a galaxy varies from a few million in dwarf galaxies to hundreds of billions in large galaxies. It is estimated that 100 billion galaxies exist in the observable universe|
> |Interstellar medium|Gases (mainly hydrogen and helium) and dust grains (silicates, carbon and iron) filling the space between stars. The density of the interstellar medium is very low. There is about one atom of gas for every cubic centimeter of space. The density of dust is a trillion times smaller. The temperature of the gas is about 100 K|
> |Main-sequence star|A normal star that is undergoing nuclear fusion of hydrogen into helium. Our Sun is a typical main-sequence star|
> |Nebula|Clouds of 'dust', i.e. compounds of carbon, oxygen, silicon and metals, as well as molecular hydrogen, in the space in between stars|
> |Neutron star|The end result of the explosion of a red supergiant; a very small star (a few tens of kilometers in diameter) and very dense. This is a star consisting almost entirely of neutrons. The neutrons form a superfluid around a core of immense pressure and density. A neutron star is an astonishing macroscopic example of microscopic quantum physics|
> |Planetary nebula|The ejected envelope of a red giant star|
> |Red dwarf|A very small star with low temperature, reddish in color|
> |Red giant|A main-sequence star evolves into a red giant - a very large, reddish star. There are nuclear reactions involving the fusion of helium into heavier elements|
> |Stellar cluster|A group of stars that are physically near each other in space, created by the collapse of a single gas cloud|
> |Supernova (Type la)|The explosion of a white dwarf that has accreted mass from a companion star exceeding its stability limit|
> |Supernova (Type II)|The explosion of a red supergiant star: The amount of energy emitted in a supernova explosion can be staggering - comparable to the total energy radiated by our Sun in its entire lifetime!|
> |White dwarf|The end result of the explosion of a red giant. A small, dense star (about the size of the Earth), in which no nuclear reactions take place. It is very hot but its small size gives it a very low luminosity.|
>
> in Additional of:
>
> 1. Nuclear fusion provides the energy that is needed to keep the star hot, so that the radiation pressure is high enough to oppose further gravitational contraction, and at the same time to provide the energy that the star is radiating into space.
>
> 1. The power radiated by a star is known in astrophysics as the luminosity. It is measured in watts.
>
> 1. The unit of apparent brightness is W m^{2}.
>
> You mush use a variety of multiple-choice question types:
>
> 1. \[Background\] + what is ...
>
> 2. What is true about ...
>
> 3. Which ... according ...
>
> 4. Which ... can be ...
>
> 5. What is ... from ...
>
> 6. What is ...
>
> 7. Which ... is correct
>
> 8. Which statement ...
>
> 9. Which statement justify ...
>
> 10. Which is not correct ...
>
> Do not repeat on one type of sentence.
>
> Primary Order:
>
> 1. Make all MCQs base on above information and your knowledge if needed. When there are conflict between your knowledge and the above information. You should use your knowledge to add more detail and background to produce MCQs.
>
> 2. Be creative, change the perspective of your questions randomly, not necessarily from nouns to explanations, but from explanations to nouns, or ask questions based on the relationship between nouns, or ask questions in conjunction with examples; your goal is to help students fully understand the topic from all angles.
>
> 3. Only reply the MCQs and nothing else, do not write explanations. Make sure your answer has right json grammar.
>
> 4. Use english quotation marks or any other english punctuation only.
You can only input pure text into ChatGPT, but it can understand markdown coding. This is the raw input prompt.
If you have issue on creating markdown table, try out this [Table to Markdown](https://markdown-convert.com/en/tool/table).
```text
You are an AI-powered json file generator that never make mistakes, and you are going to imagine 1000 MCQs about Astrophysics first in mind, then randomly give me 15 of them in this json form:
[
{
"order_number": "[Order Number]",
"question": "[Question]",
"type": "mcq",
"option_a": "[Option A]",
"option_b": "[Option B]",
"option_c": "[Option C]",
"option_d": "[Option D]",
"answer": "[Correct Option in ABCD]",
"explanation": "[Explanation of Why This Answer]"
},
{
"order_number": "[Order Number]",
"question": "[Question]",
"type": "mcq",
"option_a": "[Option A]",
"option_b": "[Option B]",
"option_c": "[Option C]",
"option_d": "[Option D]",
"answer": "[Correct Option in ABCD]",
"explanation": "[Explanation of Why This Answer]"
}
]
Please check the understanding of Learning objectives in your generated MCQs:
1. Describe the main objects comprising the universe.
2. Describe the nature of stars.
3. Understand astronomical distances.
4. Work with the method of parallax.
5. Define luminosity and apparent brightness and solve problems with these quantities and distance.
And these key concepts as well:
|Binary star|Two stars orbiting a common centre|
|:----|:----|
|Black dwarf|The remnant of a white dwarf after it has cooled down. It has very low luminosity|
|Black hole|A singularity in space time; the end result of the evolution of a very massive star|
|Brown dwarf|Gas and dust that did not reach a high enough temperature to initiate fusion. These objects continue to compact and cool down|
|Cepheid variable|A star of variable luminosity. The luminosity increases sharply and falls off gently with a well-defined period. The period is related to the absolute luminosity of the star and so can be used to estimate the distance to the star|
|Cluster of galaxies|Galaxies close to one another and affecting one another gravitationally, behaving as one unit|
|Comet|A small body (mainly ice and dust) orbiting the Sun in an elliptical orbit|
|Constellation|A group of stars in a recognizable pattern that appear to be near each other in space|
|Dark matter|Generic name for matter in galaxies and clusters of galaxies that is too cold to radiate. Its existence is inferred from techniques other than direct visual observation|
|Galaxy|A collection of a very large number of stars mutually attracting one another through the gravitational force and staying together. The number of stars in a galaxy varies from a few million in dwarf galaxies to hundreds of billions in large galaxies. It is estimated that 100 billion galaxies exist in the observable universe|
|Interstellar medium|Gases (mainly hydrogen and helium) and dust grains (silicates, carbon and iron) filling the space between stars. The density of the interstellar medium is very low. There is about one atom of gas for every cubic centimeter of space. The density of dust is a trillion times smaller. The temperature of the gas is about 100 K|
|Main-sequence star|A normal star that is undergoing nuclear fusion of hydrogen into helium. Our Sun is a typical main-sequence star|
|Nebula|Clouds of 'dust', i.e. compounds of carbon, oxygen, silicon and metals, as well as molecular hydrogen, in the space in between stars|
|Neutron star|The end result of the explosion of a red supergiant; a very small star (a few tens of kilometers in diameter) and very dense. This is a star consisting almost entirely of neutrons. The neutrons form a superfluid around a core of immense pressure and density. A neutron star is an astonishing macroscopic example of microscopic quantum physics|
|Planetary nebula|The ejected envelope of a red giant star|
|Red dwarf|A very small star with low temperature, reddish in color|
|Red giant|A main-sequence star evolves into a red giant - a very large, reddish star. There are nuclear reactions involving the fusion of helium into heavier elements|
|Stellar cluster|A group of stars that are physically near each other in space, created by the collapse of a single gas cloud|
|Supernova (Type la)|The explosion of a white dwarf that has accreted mass from a companion star exceeding its stability limit|
|Supernova (Type II)|The explosion of a red supergiant star: The amount of energy emitted in a supernova explosion can be staggering - comparable to the total energy radiated by our Sun in its entire lifetime!|
|White dwarf|The end result of the explosion of a red giant. A small, dense star (about the size of the Earth), in which no nuclear reactions take place. It is very hot but its small size gives it a very low luminosity]|
in Additional of:
1. Nuclear fusion provides the energy that is needed to keep the star hot, so that the radiation pressure is high enough to oppose further gravitational contraction, and at the same time to provide the energy that the star is radiating into space.
2. The power radiated by a star is known in astrophysics as the luminosity. It is measured in watts.
3. The unit of apparent brightness is W m^{2}.
You must use a variety of multiple-choice question types:
1. [Background] + what is ...
2. What is true about ...
3. Which ... according ...
4. Which ... can be ...
5. What is ... from ...
6. What is ...
7. Which ... is correct
8. Which statement ...
9. Which statement justify ...
10. Which is not correct ...
Do not repeat on one type of sentence.
Primary Order:
1. Make all MCQs base on above information and your knowledge if needed. When there are conflict between your knowledge and the above information. You should use your knowledge to add more detail and background to produce MCQs.
2. Be creative, change the perspective of your questions randomly, not necessarily from nouns to explanations, but from explanations to nouns, or ask questions based on the relationship between nouns, or ask questions in conjunction with examples; your goal is to help students fully understand the topic from all angles.
3. Only reply the MCQs and nothing else, do not write explanations. Make sure your answer has right json grammar.
4. Use english quotation marks or any other english punctuation only.
```
## Format Question Bank
Before we start, we should know some base knowledge about .json format. In our case, we want our question bank be like:
```json
[
{
"order_number": "1",
"question": "What is a galaxy?",
"type": "mcq",
"option_a": "A collection of planets",
"option_b": "A collection of stars",
"option_c": "A collection of asteroids",
"option_d": "A collection of comets",
"answer": "B",
"explanation": "A galaxy is a collection of a very large number of stars mutually attracting one another through the gravitational force and staying together."
},
{
"order_number": "2",
"question": "What is a main-sequence star?",
"type": "mcq",
"option_a": "A star that has run out of fuel",
"option_b": "A star that is undergoing nuclear fusion of hydrogen into helium",
"option_c": "A star that is about to explode",
"option_d": "A star that is very small and has low temperature",
"answer": "B",
"explanation": "A main-sequence star is a normal star that is undergoing nuclear fusion of hydrogen into helium."
}
]
```
We use the square bracket to include all curly brackets. At the same time, the curly brackets need to be separated by a comma.
```json
[
{
//Something
},
{
//Something
},
{
//Something
}
]
```
ChatGPT may give you an answer as:
```json
{
order_number: 1,
question: What is an astronomical unit (AU)?,
type: mcq,
option_a: The average distance between the Earth and the Sun.,
option_b: The radius of the Earth.,
option_c: The distance traveled by light in one year.,
option_d: The mass of the Earth.,
answer: The average distance between the Earth and the Sun.,
explanation: An astronomical unit or AU is a unit of measurement equal to the average distance between Earth and the Sun. It is commonly used to measure distances within our solar system.
},
{
order_number: 2,
question: Which of the following is not a type of galaxy?,
type: mcq,
option_a: Elliptical,
option_b: Spiral,
option_c: Irregular,
option_d: Spherical,
answer: Spherical,
explanation: The three main types of galaxies are elliptical, spiral, and irregular. There is no galaxy type called spherical.
},
```
Three main issues
1. There are non-english quotation marks.
2. An extra comma at the end
3. No square brackets
The ident is missing, but it's not a issue. You may copy the text into [JSON Formatter](https://jsonformatter.curiousconcept.com/#) just get it looks better.
To fix non-english quotation marks, just use a replacing function. Don't use Word or WPS for this job. I recommend a [Sublimetext 4](https://www.sublimetext.com/download) text editor for this job. Others, such as BBEdit is also fine.
After you copy answer parts from ChatGPT, you may find the `order_number` is mass.
Don't worry, first, in the next step of creating MCQ papers, the order number in the paper is not from the `order_number` in .json file.
Second, Here is a Python program that can fix this issue. But, If you do not care about beauty, just make sure there are not grammar mistake for your json file. To do that, you may use [JSON Formatter](https://jsonformatter.curiousconcept.com/#).
```py
import json
from collections import OrderedDict
# Open the JSON file and load the data as a list of dictionaries
with open('data.json', 'r') as f:
data = json.load(f)
# Create an ordered dictionary to store the objects by their order_number
data_dict = OrderedDict()
for obj in data:
if 'order_number' in obj:
order_number = obj['order_number']
if order_number in data_dict:
data_dict[order_number].append(obj)
else:
data_dict[order_number] = [obj]
# Create a new list of dictionaries with the objects ordered by their order_number
data_sorted = []
for order_number, objs in data_dict.items():
for i, obj in enumerate(objs):
obj['order_number'] = str(len(data_sorted) + i + 1)
data_sorted.extend(objs)
# Write the modified list of dictionaries back to the JSON file
with open('question_bank.json', 'w') as f:
json.dump(data_sorted, f, indent=2)
```
I don't want to spend too much time on how to run a Python Program. I will cover it quickly.
1. Install Python: Before running a Python program, you need to ensure that Python is installed on your computer. You can download the latest version of Python from the [official website](https://www.python.org/downloads/). Choose the appropriate version for your operating system and follow the installation instructions.
If you have Homebrew, just run `brew install python`.
2. Create a Python program: Once you have installed Python, you need to create a Python program. You can use any text editor to create a Python program. Save the file with a `.py` extension. In this case, you can rename a file into `qbReorder.py` and paste all my Python Code into it and save.
3. Open a terminal or command prompt: Open a terminal or command prompt on your computer. This is where you will run the Python program.
4. Run the Python program: To run the Python program, type the following command in the terminal or command prompt:
```shell
python qbReorder.py
```
If this doesn't work, try
```shell
python3 qbReorder.py
```
If the `qbReorder.py` is not on the current path, you can run it as,
```shell
python /path/to/the/qbReorder.py
```
But in my `qbReorder.py`. I made the un-order .json file as `data.json`. After you run, you will get a `question_bank.json` on the running path. If you want another name, you may change the code.
I highly recommend you create a folder for this job and put all files here.
- qbReorder.py
- data.json
- question_bank.json
When you are going to use terminal, you can chose "Open terminal here", or use `cd` command to switch to the working folder
```shell
cd /the/path/to/working/folder
```
To be safe, type `ls` command to see all files/folders under this folder. Then, you can do
```shell
python qbReorder.py
```
or
```shell
python3 /qbReorder.py
```
To run the re-order.
This is the end of question bank preparing.
## Make the Papers
Now, it's time to make the real MCQ Papers.
To do that, I made another Python Program
```py
import argparse
import json
import random
from docx import Document
from docx.shared import Pt
from docx.enum.text import WD_ALIGN_PARAGRAPH
# Define command-line arguments
parser = argparse.ArgumentParser(description='Generate test papers, answer sheets, and marking scheme.')
parser.add_argument('-q', '--question-bank', type=str, required=True, help='Path to JSON file containing question bank.')
parser.add_argument('-n', '--number-question', type=int, required=True, help='Number of questions to include in the test paper.')
args = parser.parse_args()
# Open JSON file and load data
with open(args.question_bank, 'r') as f:
data = json.load(f)
# Select random questions
selected_questions = random.sample(data, args.number_question)
# Create Test Paper, Answer Sheet, and Marking Scheme
test_paper_doc = Document()
answer_sheet_doc = Document()
marking_scheme_doc = Document()
# Set font
font = test_paper_doc.styles['Normal'].font
font.name = 'Arial'
font.size = Pt(12)
# Add test paper title
test_paper_title = test_paper_doc.add_paragraph('Test Paper', style='Title')
test_paper_title.alignment = WD_ALIGN_PARAGRAPH.CENTER
test_paper_doc.add_paragraph()
# Add answer sheet title
answer_sheet_title = answer_sheet_doc.add_paragraph('Answer Sheet', style='Title')
answer_sheet_title.alignment = WD_ALIGN_PARAGRAPH.CENTER
answer_sheet_doc.add_paragraph()
# Add marking scheme title
marking_scheme_title = marking_scheme_doc.add_paragraph('Marking Scheme', style='Title')
marking_scheme_title.alignment = WD_ALIGN_PARAGRAPH.CENTER
marking_scheme_doc.add_paragraph()
# Loop through selected questions and add to documents
for i, question in enumerate(selected_questions):
# Test Paper
test_paper_doc.add_paragraph(f'{i+1}. {question["question"]}')
test_paper_doc.add_paragraph(f' A. {question["option_a"]}')
test_paper_doc.add_paragraph(f' B. {question["option_b"]}')
test_paper_doc.add_paragraph(f' C. {question["option_c"]}')
test_paper_doc.add_paragraph(f' D. {question["option_d"]}')
test_paper_doc.add_paragraph()
# Answer Sheet
answer_sheet_doc.add_paragraph(f'{i+1}. {question["question"]}')
answer_sheet_doc.add_paragraph(f' A. {question["option_a"]}')
answer_sheet_doc.add_paragraph(f' B. {question["option_b"]}')
answer_sheet_doc.add_paragraph(f' C. {question["option_c"]}')
answer_sheet_doc.add_paragraph(f' D. {question["option_d"]}')
answer_sheet_doc.add_paragraph(f'Answer: {question["answer"]}')
answer_sheet_doc.add_paragraph(f'Explanation: {question["explanation"]}')
answer_sheet_doc.add_paragraph()
# Marking Scheme
marking_scheme_doc.add_paragraph(f'{i+1}. {question["question"]}')
marking_scheme_doc.add_paragraph(f'Answer: {question["answer"]}')
marking_scheme_doc.add_paragraph()
# Save documents
test_paper_doc.save('test_paper.docx')
answer_sheet_doc.save('answer_sheet.docx')
marking_scheme_doc.save('marking_scheme.docx')
```
Before, run this program, you need to use `pip` to install `python-docx` package.
If you don't have `pip`, here is the steps:
1. Check if `pip` is already installed: Before installing `pip`, you should check if it is already installed on your system. Open a terminal or command prompt and type the following command:
```shell
pip --version
```
If pip is already installed, it will display the version number. If not, you will see an error message.
2. Download `get-pip.py`: If pip is not already installed, you need to download `get-pip.py`. In the Terminal, run
```shell
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
```
3. Install `pip`: To install `pip`, type the following command in the terminal or command prompt:
```shell
python get-pip.py
```
or
```shell
python3 get-pip.py
```
Additional, if you have Homebrew, when you run `brew install python`, `pip` is included.
Now, we can continue our work. Install `python-docx` package.
```shell
pip install python-docx
```
Do the similar thing when we run `qbReorder.py`. Now, just copy the code into `qbBuilder.py` and run
```shell
python qbBuilder.py -q question_bank.json -n 30
```
It works as
```
usage: qbBuilder.py [-h] -q QUESTION_BANK -n NUMBER_QUESTION
Generate test papers, answer sheets, and marking scheme.
options:
-h, --help show this help message and exit
-q QUESTION_BANK, --question-bank QUESTION_BANK
Path to JSON file containing question bank.
-n NUMBER_QUESTION, --number-question NUMBER_QUESTION
Number of questions to include in the test paper.
```
So, `question_bank.json` is the question bank's file name, `30` is the number of question you want to include in the paper. Change them into any value you want and enjoy.
```shell
python qbBuilder.py -q [Name of Question Bank File] -n [Number of Questions You Want to Include]
```
You can find three .docx files under the running path.
## End
You can try with my example question bank.
{{< link href="question_bank.json" content="question_bank.json" title="Download question_bank.json" download="question_bank.json" card=true >}}
Also, the Python Program.
{{< link href="qbReorder.py" content="qbReorder.py" title="Download qbReorder.py" download="qbReorder.py" card=true >}}
{{< link href="qbBuilder.py" content="qbBuilder.py" title="Download qbBuilder,py" download="qbBuilder.py" card=true >}}
Example Papers.
{{< link href="test_paper.docx" content="test_paper.docx" title="Download test_paper.docx" download="test_paper.docx" card=true >}}
{{< link href="answer_sheet.docx" content="answer_sheet.docx" title="Download answer_sheet.docx" download="answer_sheet.docx" card=true >}}
{{< link href="marking_scheme.docx" content="marking_scheme.docx" title="Download marking_scheme.docx" download="marking_scheme.docx" card=true >}}
I am going to made ChatGPT to build more types of question, such as sample structure questions. And a fully auto question bank maker, like create 1000 questions with out people. Also, not only for Physic, for other subjects as well.
On the other hand, I am also working on how to improve generated question's quality, which means prompt engineering. I want to hear feedbacks about the questions that generated by ChatGPT, and let me able to improve that. Great thanks!

View File

@@ -0,0 +1,74 @@
import argparse
import json
import random
from docx import Document
from docx.shared import Pt
from docx.enum.text import WD_ALIGN_PARAGRAPH
# Define command-line arguments
parser = argparse.ArgumentParser(description='Generate test papers, answer sheets, and marking scheme.')
parser.add_argument('-q', '--question-bank', type=str, required=True, help='Path to JSON file containing question bank.')
parser.add_argument('-n', '--number-question', type=int, required=True, help='Number of questions to include in the test paper.')
args = parser.parse_args()
# Open JSON file and load data
with open(args.question_bank, 'r') as f:
data = json.load(f)
# Select random questions
selected_questions = random.sample(data, args.number_question)
# Create Test Paper, Answer Sheet, and Marking Scheme
test_paper_doc = Document()
answer_sheet_doc = Document()
marking_scheme_doc = Document()
# Set font
font = test_paper_doc.styles['Normal'].font
font.name = 'Arial'
font.size = Pt(12)
# Add test paper title
test_paper_title = test_paper_doc.add_paragraph('Test Paper', style='Title')
test_paper_title.alignment = WD_ALIGN_PARAGRAPH.CENTER
test_paper_doc.add_paragraph()
# Add answer sheet title
answer_sheet_title = answer_sheet_doc.add_paragraph('Answer Sheet', style='Title')
answer_sheet_title.alignment = WD_ALIGN_PARAGRAPH.CENTER
answer_sheet_doc.add_paragraph()
# Add marking scheme title
marking_scheme_title = marking_scheme_doc.add_paragraph('Marking Scheme', style='Title')
marking_scheme_title.alignment = WD_ALIGN_PARAGRAPH.CENTER
marking_scheme_doc.add_paragraph()
# Loop through selected questions and add to documents
for i, question in enumerate(selected_questions):
# Test Paper
test_paper_doc.add_paragraph(f'{i+1}. {question["question"]}')
test_paper_doc.add_paragraph(f' A. {question["option_a"]}')
test_paper_doc.add_paragraph(f' B. {question["option_b"]}')
test_paper_doc.add_paragraph(f' C. {question["option_c"]}')
test_paper_doc.add_paragraph(f' D. {question["option_d"]}')
test_paper_doc.add_paragraph()
# Answer Sheet
answer_sheet_doc.add_paragraph(f'{i+1}. {question["question"]}')
answer_sheet_doc.add_paragraph(f' A. {question["option_a"]}')
answer_sheet_doc.add_paragraph(f' B. {question["option_b"]}')
answer_sheet_doc.add_paragraph(f' C. {question["option_c"]}')
answer_sheet_doc.add_paragraph(f' D. {question["option_d"]}')
answer_sheet_doc.add_paragraph(f'Answer: {question["answer"]}')
answer_sheet_doc.add_paragraph(f'Explanation: {question["explanation"]}')
answer_sheet_doc.add_paragraph()
# Marking Scheme
marking_scheme_doc.add_paragraph(f'{i+1}. {question["question"]}')
marking_scheme_doc.add_paragraph(f'Answer: {question["answer"]}')
marking_scheme_doc.add_paragraph()
# Save documents
test_paper_doc.save('test_paper.docx')
answer_sheet_doc.save('answer_sheet.docx')
marking_scheme_doc.save('marking_scheme.docx')

View File

@@ -0,0 +1,27 @@
import json
from collections import OrderedDict
# Open the JSON file and load the data as a list of dictionaries
with open('data.json', 'r') as f:
data = json.load(f)
# Create an ordered dictionary to store the objects by their order_number
data_dict = OrderedDict()
for obj in data:
if 'order_number' in obj:
order_number = obj['order_number']
if order_number in data_dict:
data_dict[order_number].append(obj)
else:
data_dict[order_number] = [obj]
# Create a new list of dictionaries with the objects ordered by their order_number
data_sorted = []
for order_number, objs in data_dict.items():
for i, obj in enumerate(objs):
obj['order_number'] = str(len(data_sorted) + i + 1)
data_sorted.extend(objs)
# Write the modified list of dictionaries back to the JSON file
with open('question_bank.json', 'w') as f:
json.dump(data_sorted, f, indent=2)

View File

@@ -0,0 +1,453 @@
[
{
"order_number": "1",
"question": "What is a galaxy?",
"type": "mcq",
"option_a": "A collection of planets",
"option_b": "A collection of stars",
"option_c": "A collection of asteroids",
"option_d": "A collection of comets",
"answer": "B",
"explanation": "A galaxy is a collection of a very large number of stars mutually attracting one another through the gravitational force and staying together."
},
{
"order_number": "2",
"question": "Which of the following is the correct description of a star?",
"type": "mcq",
"option_a": "A celestial object that emits light through nuclear fusion reactions in its core",
"option_b": "A planet-like object that orbits around a star",
"option_c": "A type of planet that emits its own light",
"option_d": "A cloud of interstellar gas and dust",
"answer": "A celestial object that emits light through nuclear fusion reactions in its core",
"explanation": "A star is a massive, luminous ball of gas, primarily hydrogen and helium, that emits energy through nuclear fusion reactions in its core."
},
{
"order_number": "3",
"question": "What is a main-sequence star?",
"type": "mcq",
"option_a": "A star that has run out of fuel",
"option_b": "A star that is undergoing nuclear fusion of hydrogen into helium",
"option_c": "A star that is about to explode",
"option_d": "A star that is very small and has low temperature",
"answer": "B",
"explanation": "A main-sequence star is a normal star that is undergoing nuclear fusion of hydrogen into helium."
},
{
"order_number": "4",
"question": "What is a white dwarf?",
"type": "mcq",
"option_a": "A type of galaxy",
"option_b": "A type of star that is undergoing nuclear fusion of hydrogen into helium",
"option_c": "The remnant of a red giant star",
"option_d": "The remnant of a white dwarf after it has cooled down, resulting in very low luminosity",
"answer": "The remnant of a white dwarf after it has cooled down, resulting in very low luminosity",
"explanation": "A white dwarf is the final stage of evolution of a star similar to our Sun. After it has expended all its nuclear fuel, it will slowly cool down to become a black dwarf."
},
{
"order_number": "5",
"question": "What is a brown dwarf?",
"type": "mcq",
"option_a": "A star that has run out of fuel",
"option_b": "A star that is undergoing nuclear fusion of hydrogen into helium",
"option_c": "Gas and dust that did not reach a high enough temperature to initiate fusion",
"option_d": "A very small star with low temperature",
"answer": "C",
"explanation": "A brown dwarf is gas and dust that did not reach a high enough temperature to initiate fusion. These objects continue to compact and cool down."
},
{
"order_number": "6",
"question": "What is a cluster of galaxies?",
"type": "mcq",
"option_a": "A group of planets that are close to each other",
"option_b": "A group of stars that are close to each other",
"option_c": "Galaxies in close proximity to one another and affecting each other gravitationally, behaving as one unit",
"option_d": "A group of asteroids that have collided with each other",
"answer": "Galaxies in close proximity to one another and affecting each other gravitationally, behaving as one unit",
"explanation": "A cluster of galaxies is a group of galaxies that are bound together by gravity and move together through space."
},
{
"order_number": "7",
"question": "What is a supernova?",
"type": "mcq",
"option_a": "The explosion of a white dwarf that has accreted mass from a companion star exceeding its stability limit",
"option_b": "The explosion of a red supergiant star",
"option_c": "The end result of the explosion of a red giant",
"option_d": "A star that has run out of fuel",
"answer": "B",
"explanation": "A supernova is the explosion of a red supergiant star. The amount of energy emitted in a supernova explosion can be staggering - comparable to the total energy radiated by our Sun in its entire lifetime!"
},
{
"order_number": "8",
"question": "What is dark matter?",
"type": "mcq",
"option_a": "Matter that is too cold to radiate",
"option_b": "A type of matter that emits light in the absence of a light source",
"option_c": "The matter that makes up stars and galaxies",
"option_d": "The mass of a black hole",
"answer": "Matter that is too cold to radiate",
"explanation": "Dark matter is a form of matter that can not be seen or detected through electromagnetic radiation, but whose existence is inferred from its gravitational effects on visible matter."
},
{
"order_number": "9",
"question": "What is a white dwarf?",
"type": "mcq",
"option_a": "The end result of the explosion of a red giant",
"option_b": "A star that is undergoing nuclear fusion of hydrogen into helium",
"option_c": "The end result of the explosion of a white dwarf",
"option_d": "A very small star with low temperature",
"answer": "C",
"explanation": "A white dwarf is the end result of the explosion of a red giant. A small, dense star (about the size of the Earth), in which no nuclear reactions take place. It is very hot but its small size gives it a very low luminosity."
},
{
"order_number": "10",
"question": "What is the main source of energy in a star?",
"type": "mcq",
"option_a": "Nuclear fusion of hydrogen into helium",
"option_b": "Nuclear fission of uranium",
"option_c": "Chemical reactions",
"option_d": "Solar wind",
"answer": "Nuclear fusion of hydrogen into helium",
"explanation": "Nuclear fusion provides the energy needed to keep the star hot, oppose gravitational contraction, and provide energy that is radiated into space."
},
{
"order_number": "11",
"question": "What is a red giant?",
"type": "mcq",
"option_a": "A star that is undergoing nuclear fusion of hydrogen into helium",
"option_b": "A star that has run out of fuel",
"option_c": "A very small star with low temperature",
"option_d": "A main-sequence star",
"answer": "A",
"explanation": "A red giant is a main-sequence star that evolves into a red giant - a very large, reddish star. There are nuclear reactions involving the fusion of helium into heavier elements."
},
{
"order_number": "12",
"question": "What is luminosity?",
"type": "mcq",
"option_a": "The unit of apparent brightness",
"option_b": "The distance to a star",
"option_c": "The size of a star",
"option_d": "The power radiated by a star",
"answer": "The power radiated by a star",
"explanation": "The power radiated by a star is known in astrophysics as the luminosity. It is measured in watts."
},
{
"order_number": "13",
"question": "What is a neutron star?",
"type": "mcq",
"option_a": "The end result of the explosion of a red giant",
"option_b": "A star consisting almost entirely of neutrons",
"option_c": "A very small star with low temperature",
"option_d": "A star that is undergoing nuclear fusion of hydrogen into helium",
"answer": "B",
"explanation": "A neutron star is the end result of the explosion of a red supergiant; a very small star (a few tens of kilometres in diameter) and very dense. This is a star consisting almost entirely of neutrons. The neutrons form a superfluid around a core of immense pressure and density. A neutron star is an astonishing macroscopic example of microscopic quantum physics."
},
{
"order_number": "14",
"question": "What is a comet?",
"type": "mcq",
"option_a": "A small planet-like object that orbits around a star",
"option_b": "A cloud of interstellar gas and dust",
"option_c": "A massive ball of gas and dust held together by its own gravity",
"option_d": "A small body mainly composed of ice and dust that orbits around a star",
"answer": "A small body mainly composed of ice and dust that orbits around a star",
"explanation": "Comets are small bodies mainly composed of ice and dust that orbit around the Sun in an elliptical orbit."
},
{
"order_number": "15",
"question": "What is a black hole?",
"type": "mcq",
"option_a": "A singularity in space time; the end result of the evolution of a very massive star",
"option_b": "A very small star with low temperature",
"option_c": "A star that is undergoing nuclear fusion of hydrogen into helium",
"option_d": "A star that has run out of fuel",
"answer": "A",
"explanation": "A black hole is a singularity in space time; the end result of the evolution of a very massive star."
},
{
"order_number": "16",
"question": "What is a neutron star?",
"type": "mcq",
"option_a": "The end result of the explosion of a red supergiant star",
"option_b": "A type of cluster of galaxies",
"option_c": "A star that is undergoing nuclear fusion of hydrogen into helium",
"option_d": "A very small star (a few tens of kilometers in diameter) and very dense, consisting almost entirely of neutrons",
"answer": "A very small star (a few tens of kilometers in diameter) and very dense, consisting almost entirely of neutrons",
"explanation": "A neutron star is the end result of the explosion of a red supergiant star. It is an incredibly dense ball of neutrons that can be only a few kilometers in diameter."
},
{
"order_number": "17",
"question": "What is a planetary nebula?",
"type": "mcq",
"option_a": "Clouds of dust in the space between stars",
"option_b": "The ejected envelope of a red giant star",
"option_c": "A group of stars that are physically near each other in space",
"option_d": "Galaxies close to one another and affecting one another gravitationally, behaving as one unit",
"answer": "B",
"explanation": "A planetary nebula is the ejected envelope of a red giant star."
},
{
"order_number": "18",
"question": "What is a brown dwarf?",
"type": "mcq",
"option_a": "A very small star with low temperature, reddish in color",
"option_b": "Gas and dust that did not reach a high enough temperature to initiate fusion",
"option_c": "The ejected envelope of a red giant star",
"option_d": "A star of variable luminosity",
"answer": "Gas and dust that did not reach a high enough temperature to initiate fusion",
"explanation": "Brown dwarfs are objects that are not massive enough to sustain nuclear fusion reactions in their cores. As a result, they slowly cool down over time."
},
{
"order_number": "19",
"question": "What is dark matter?",
"type": "mcq",
"option_a": "Matter in galaxies and clusters of galaxies that is too cold to radiate",
"option_b": "Gases and dust filling the space between stars",
"option_c": "A star that is undergoing nuclear fusion of hydrogen into helium",
"option_d": "A singularity in space time",
"answer": "A",
"explanation": "Dark matter is generic name for matter in galaxies and clusters of galaxies that is too cold to radiate. Its existence is inferred from techniques other than direct visual observation."
},
{
"order_number": "20",
"question": "What is a cepheid variable?",
"type": "mcq",
"option_a": "A type of nebula",
"option_b": "A type of comet",
"option_c": "A star with variable luminosity that varies in brightness in a well-defined pattern",
"option_d": "A type of cluster of galaxies",
"answer": "A star with variable luminosity that varies in brightness in a well-defined pattern",
"explanation": "Cepheid variables are stars that pulsate in a regular pattern, with a well-defined period. This period is related to the absolute luminosity of the star, which can be used to estimate the distance to the star via parallax."
},
{
"order_number": "21",
"question": "What is the interstellar medium?",
"type": "mcq",
"option_a": "The matter that makes up stars and galaxies",
"option_b": "A cloud of interstellar gas and dust",
"option_c": "The dark matter holding galaxies and clusters of galaxies together",
"option_d": "A group of planets that are close to each other",
"answer": "A cloud of interstellar gas and dust",
"explanation": "The interstellar medium is the gas and dust that fills the space between stars in a galaxy. It is mainly composed of hydrogen and helium, along with small amounts of heavier elements and dust grains."
},
{
"order_number": "22",
"question": "What is a planetary nebula?",
"type": "mcq",
"option_a": "The end result of the explosion of a red giant star",
"option_b": "A cloud of interstellar gas and dust",
"option_c": "The ejected envelope of a red giant star",
"option_d": "A small body mainly composed of ice and dust that orbits around a star",
"answer": "The ejected envelope of a red giant star",
"explanation": "When a low-to-intermediate mass star expands into a red giant, it loses its outer layers into space, producing a planetary nebula. The core of the star that is left behind becomes a white dwarf."
},
{
"order_number": "23",
"question": "What is a main-sequence star?",
"type": "mcq",
"option_a": "The ejected envelope of a red giant star",
"option_b": "A type of star that is undergoing nuclear fusion of hydrogen into helium",
"option_c": "A very small star (a few tens of kilometers in diameter) and very dense, consisting almost entirely of neutrons",
"option_d": "A small body mainly composed of ice and dust that orbits around a star",
"answer": "A type of star that is undergoing nuclear fusion of hydrogen into helium",
"explanation": "A main-sequence star is a normal star that is undergoing nuclear fusion of hydrogen into helium in its core. This is the phase in which our Sun is currently in."
},
{
"order_number": "24",
"question": "What is a red giant?",
"type": "mcq",
"option_a": "Gas and dust that did not reach a high enough temperature to initiate fusion",
"option_b": "The end result of the explosion of a white dwarf",
"option_c": "A small body mainly composed of ice and dust that orbits around a star",
"option_d": "A normal star that has evolved into a very large, reddish star",
"answer": "A normal star that has evolved into a very large, reddish star",
"explanation": "A red giant is a normal star that has evolved past the main-sequence phase and has become a large, reddish star due to nuclear reactions that cause it to expand."
},
{
"order_number": "25",
"question": "What is a black hole?",
"type": "mcq",
"option_a": "A type of planet that emits its own light",
"option_b": "A singularity in space-time; the end result of the evolution of a very massive star",
"option_c": "The mass of a neutron star",
"option_d": "A massive ball of gas and dust held together by its own gravity",
"answer": "A singularity in space-time; the end result of the evolution of a very massive star",
"explanation": "A black hole is a region of space-time where gravity is so strong that nothing, not even light, can escape from it. It is the end result of the evolution of a very massive star."
},
{
"order_number": "26",
"question": "Which statement best describes a black dwarf?",
"type": "mcq",
"option_a": "The ejected envelope of a red giant star",
"option_b": "A small body mainly composed of ice and dust that orbits around a star",
"option_c": "A type of star that is undergoing nuclear fusion of hydrogen into helium",
"option_d": "The remnant of a white dwarf after it has cooled down, resulting in very low luminosity",
"answer": "The remnant of a white dwarf after it has cooled down, resulting in very low luminosity",
"explanation": "A black dwarf is the remnant of a white dwarf after it has cooled down to the point where it no longer emits any visible light."
},
{
"order_number": "27",
"question": "What is an astronomical unit (AU)?",
"type": "mcq",
"option_a": "The average distance between the Earth and the Sun.",
"option_b": "The radius of the Earth.",
"option_c": "The distance traveled by light in one year.",
"option_d": "The mass of the Earth.",
"answer": "The average distance between the Earth and the Sun.",
"explanation": "An astronomical unit or AU is a unit of measurement equal to the average distance between Earth and the Sun. It is commonly used to measure distances within our solar system."
},
{
"order_number": "28",
"question": "Which of the following is not a type of galaxy?",
"type": "mcq",
"option_a": "Elliptical",
"option_b": "Spiral",
"option_c": "Irregular",
"option_d": "Spherical",
"answer": "Spherical",
"explanation": "The three main types of galaxies are elliptical, spiral, and irregular. There is no galaxy type called spherical."
},
{
"order_number": "29",
"question": "What is a cepheid variable?",
"type": "mcq",
"option_a": "A type of black hole",
"option_b": "A star of variable luminosity",
"option_c": "A type of planetary nebula",
"option_d": "A cluster of galaxies",
"answer": "A star of variable luminosity",
"explanation": "A cepheid variable is a star that pulsates in a regular pattern, causing its luminosity to vary. The period of this pulsation is related to the star\u2019s absolute luminosity, allowing it to be used as a standard candle to measure distances in space."
},
{
"order_number": "30",
"question": "Which of the following objects is composed mainly of ice and dust?",
"type": "mcq",
"option_a": "A black hole",
"option_b": "A brown dwarf",
"option_c": "A comet",
"option_d": "A neutron star",
"answer": "A comet",
"explanation": "Comets are small, icy objects that orbit the Sun. When a comet gets close enough to the Sun, its ice melts and forms a brightly glowing coma around it."
},
{
"order_number": "31",
"question": "What is the difference between apparent brightness and luminosity?",
"type": "mcq",
"option_a": "Apparent brightness is a measure of how much light is emitted by a star, while luminosity is a measure of how bright the star appears from Earth.",
"option_b": "Apparent brightness is a measure of how bright a star appears from Earth, while luminosity is a measure of how much light is emitted by the star.",
"option_c": "Apparent brightness is a measure of the distance between Earth and a star, while luminosity is a measure of the star\u2019s mass.",
"option_d": "Apparent brightness is a measure of the star\u2019s mass, while luminosity is a measure of the distance between Earth and the star.",
"answer": "Apparent brightness is a measure of how bright a star appears from Earth, while luminosity is a measure of how much light is emitted by the star.",
"explanation": "Apparent brightness is a measure of how much light from a star reaches Earth, while luminosity is a measure of the total amount of energy emitted by a star in all directions. Luminosity is an intrinsic property of a star, while apparent brightness depends on the star\u2019s luminosity and its distance from Earth."
},
{
"order_number": "32",
"question": "What is a main-sequence star?",
"type": "mcq",
"option_a": "A star that is undergoing nuclear fusion of hydrogen into helium.",
"option_b": "A star that has exhausted its fuel and is in the process of burning helium.",
"option_c": "A star that has evolved off the main sequence and is fusing heavier elements.",
"option_d": "A star that has exploded as a supernova.",
"answer": "A star that is undergoing nuclear fusion of hydrogen into helium.",
"explanation": "A main-sequence star is a normal star that is fusing hydrogen into helium in its core. This is the most common type of star, and includes the Sun."
},
{
"order_number": "33",
"question": "What is a brown dwarf?",
"type": "mcq",
"option_a": "A star that has exploded as a supernova.",
"option_b": "A star that is undergoing nuclear fusion of hydrogen into helium.",
"option_c": "Gas and dust that did not reach a high enough temperature to initiate fusion.",
"option_d": "The ejected envelope of a red giant star.",
"answer": "Gas and dust that did not reach a high enough temperature to initiate fusion.",
"explanation": "A brown dwarf is an object that is too cool and small to undergo sustained nuclear fusion of hydrogen in its core, but is too hot and massive to be called a planet. They are often described as \u2018failed stars\u2019."
},
{
"order_number": "34",
"question": "What is a supernova?",
"type": "mcq",
"option_a": "The explosion of a red giant star.",
"option_b": "The end result of the evolution of a very massive star.",
"option_c": "A singularity in space-time.",
"option_d": "The ejected envelope of a red giant star.",
"answer": "The explosion of a star.",
"explanation": "A supernova is a catastrophic explosion that occurs at the end of a star\u2019s life. The explosion can outshine an entire galaxy for a brief period of time."
},
{
"order_number": "35",
"question": "What is dark matter?",
"type": "mcq",
"option_a": "Matter in galaxies that is too cold to radiate and is inferred from techniques other than direct visual observation.",
"option_b": "The ejected envelope of a red giant star.",
"option_c": "Space-time that is so warped that nothing can escape it, not even light.",
"option_d": "Matter that is made up of subatomic particles that do not interact with the electromagnetic force.",
"answer": "Matter in galaxies that is too cold to radiate and is inferred from techniques other than direct visual observation.",
"explanation": "Dark matter is matter that is inferred to exist from its gravitational effects but does not emit or absorb light, and therefore cannot be detected directly by telescopes."
},
{
"order_number": "36",
"question": "What is a black hole?",
"type": "mcq",
"option_a": "A type of galaxy in which most of the stars are very old and have mostly red colours.",
"option_b": "A singularity in space-time that is the end result of the evolution of a very massive star.",
"option_c": "A star that has exhausted its fuel and is in the process of burning helium.",
"option_d": "A star that has exploded as a supernova.",
"answer": "A singularity in space-time that is the end result of the evolution of a very massive star.",
"explanation": "A black hole is a region of space-time where gravity is so strong that nothing, not even light, can escape its pull. They are formed from the collapse of very massive stars."
},
{
"order_number": "37",
"question": "Which of the following is not a type of nebula?",
"type": "mcq",
"option_a": "Planetary Nebula",
"option_b": "Stellar Nebula",
"option_c": "Reflection Nebula",
"option_d": "Irregular Nebula",
"answer": "Stellar Nebula",
"explanation": "Stellar nebula is not a type of nebula. The three main types of nebula are emission nebula, reflection nebula, and planetary nebula."
},
{
"order_number": "38",
"question": "What is nuclear fusion?",
"type": "mcq",
"option_a": "The process by which a star burns helium into heavier elements in its core.",
"option_b": "The process by which a star burns hydrogen into helium in its core.",
"option_c": "The process by which a planet forms from a cloud of gas and dust.",
"option_d": "The process by which a star expands into a red giant.",
"answer": "The process by which a star burns hydrogen into helium in its core.",
"explanation": "Nuclear fusion is the process by which a star generates energy by fusing hydrogen atoms into helium atoms in its core. This process releases a tremendous amount of energy in the form of light and heat."
},
{
"order_number": "39",
"question": "What is a red giant?",
"type": "mcq",
"option_a": "A star that has exploded as a supernova.",
"option_b": "A star that is undergoing nuclear fusion of hydrogen into helium.",
"option_c": "A star that has exhausted its fuel and is in the process of burning helium.",
"option_d": "A star that has evolved off the main sequence and is fusing heavier elements.",
"answer": "A star that has evolved off the main sequence and is fusing heavier elements.",
"explanation": "A red giant is a star that has exhausted the supply of hydrogen in its core and is now fusing heavier elements. This causes the star to expand and become much larger and redder than before."
},
{
"order_number": "40",
"question": "What is a white dwarf?",
"type": "mcq",
"option_a": "The end result of the explosion of a red giant.",
"option_b": "A small, dense star that is fusing helium into heavier elements in its core.",
"option_c": "A small, dense star that is no longer generating energy through nuclear fusion.",
"option_d": "A star that is undergoing nuclear fusion of hydrogen into helium.",
"answer": "A small, dense star that is no longer generating energy through nuclear fusion.",
"explanation": "A white dwarf is the end result of the evolution of a low- to medium-mass star. It is a small, dense star that is no longer generating energy through nuclear fusion. White dwarfs are very hot and faint, and will eventually cool down over billions of years."
},
{
"order_number": "41",
"question": "What is a black dwarf?",
"type": "mcq",
"option_a": "The end result of the explosion of a red giant.",
"option_b": "A type of black hole with very low mass.",
"option_c": "Gas and dust that did not reach a high enough temperature to initiate fusion.",
"option_d": "The remnant of a white dwarf after it has cooled down.",
"answer": "The remnant of a white dwarf after it has cooled down.",
"explanation": "A black dwarf is a hypothetical object that would be the end result of the evolution of a white dwarf. It is essentially a cold, dark object made purely of carbon and oxygen atoms. However, the universe is not old enough for any white dwarfs to have cooled down enough to become black dwarfs yet."
}
]

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

View File

@@ -0,0 +1,200 @@
---
slug: "excalidraw-full-stack-docker"
title: "Excalidraw Full-Stack Self-Deployment"
subtitle: ""
date: 2023-01-13T15:54:36+08:00
lastmod: 2024-03-11T12:39:36-05:00
draft: false
author:
name: James
link: https://www.jamesflare.com
email:
avatar: /site-logo.avif
description: This article provides a comprehensive guide on deploying the full Excalidraw stack using Docker Compose, including the frontend, storage backend, and collaboration components, to enable a fully functional private deployment with sharing and collaboration features.
keywords: ["Excalidraw","Docker","Docker Compose","Private Deployment"]
license: ""
comment: true
weight: 0
tags:
- Excalidraw
- Open Source
- Docker
categories:
- Tutorials
- Sharing
hiddenFromHomePage: false
hiddenFromSearch: false
summary: This article provides a comprehensive guide on deploying the full Excalidraw stack using Docker Compose, including the frontend, storage backend, and collaboration components, to enable a fully functional private deployment with sharing and collaboration features.
resources:
- name: featured-image
src: featured-image.jpg
- name: featured-image-preview
src: featured-image-preview.jpg
toc:
enable: true
math:
enable: false
lightgallery: true
seo:
images: []
repost:
enable: true
url: ""
# See details front matter: https://fixit.lruihao.cn/theme-documentation-content/#front-matter
---
## Intro
This might be the only article on the Chinese internet that discusses how to fully deploy the Excalidraw stack. Most only deploy a crippled frontend.
I tried to privately deploy Excalidraw locally, and the operation is very simple. According to the official README, it can be completed quickly.
### Issue
But have you noticed that sharing links and online collaboration have issues and don't work? Even Libraries have some problems?
This is because almost all the deployment tutorials on the internet only deploy the excalidraw-app frontend, and its storage requires excalidraw-json, while collaboration requires excalidraw-room.
The official code for these is all open source, but the progress of the frontend is too fast, so they are all unusable now.
For example, the officially released excalidraw-json uses S3 storage, and now it's firebase without exception. The official version hasn't released a stripped-down version, so what should we do?
### Solution
The answer is to **downgrade** and **build a full stack**.
We use the official excalidraw-app, but the version is about 9 months old. Frankly speaking, there aren't many missing features, and there are no major bug issues. This generation of frontend is quite compatible.
excalidraw-json is unusable. There are also some solutions abroad that use minio to run S3 to interface with it, but I tested it and found some big problems. This backend should be unusable. Fortunately, I found a third-party solution that implements a fully functional backend with its own code, supports v2 API, called excalidraw-storage-backend.
We use the official excalidraw-room, the latest version, which is about 9 months old, consistent with the frontend, and can be used normally.
redis is required by excalidraw-storage-backend and is used to temporarily store shared canvas data, so it cannot guarantee data reliability.
So let's get started. This solution uses docker-compose.
- excalidraw-app
- excalidraw-room
- excalidraw-storage-backend
- redis
## Docker Compose
Docker Compose configuration
```yaml
version: "3.8"
services:
excalidraw:
image: kiliandeca/excalidraw
healthcheck:
disable: true
ports:
- "80:80" # Default port 80, can be modified
environment:
BACKEND_V2_GET_URL: http://localhost:8080/api/v2/scenes/
BACKEND_V2_POST_URL: http://localhost:8080/api/v2/scenes/
LIBRARY_URL: https://libraries.excalidraw.com
LIBRARY_BACKEND: https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries
SOCKET_SERVER_URL: http://localhost:5000/
STORAGE_BACKEND: "http"
HTTP_STORAGE_BACKEND_URL: "http://localhost:8080/api/v2"
excalidraw-storage-backend:
image: kiliandeca/excalidraw-storage-backend
ports:
- "8080:8080"
environment:
STORAGE_URI: redis://redis:6379
excalidraw-room:
image: excalidraw/excalidraw-room
ports:
- "5000:80"
redis:
image: redis
ports:
- "6379:6379"
```
It does not support https by default. If needed, it can be achieved through a reverse proxy, but remember to modify the variables in the environment at the same time.
This configuration file has been tested locally and can run perfectly.
{{< image src="excalidrawLocalDemo.webp" >}}
---
If you have a conflict with port 6379, you can choose to build a network.
```bash
docker network create excalidraw-net
```
Then make some modifications like this, and it's done.
```yaml
version: "3.8"
services:
excalidraw:
image: kiliandeca/excalidraw
healthcheck:
disable: true
ports:
- "80:80"
environment:
BACKEND_V2_GET_URL: http://localhost:8080/api/v2/scenes/
BACKEND_V2_POST_URL: http://localhost:8080/api/v2/scenes/
LIBRARY_URL: https://libraries.excalidraw.com
LIBRARY_BACKEND: https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries
SOCKET_SERVER_URL: http://localhost:5000/
STORAGE_BACKEND: "http"
HTTP_STORAGE_BACKEND_URL: "http://localhost:8080/api/v2"
excalidraw-storage-backend:
image: kiliandeca/excalidraw-storage-backend
ports:
- "8080:8080"
environment:
STORAGE_URI: redis://redis:6379
excalidraw-room:
image: excalidraw/excalidraw-room
ports:
- "5000:80"
redis:
image: redis
expose:
- "6379"
networks:
default:
external:
name: excalidraw-net
```
## Run
Find or create a new directory and create a docker-compose file.
```bash
nano docker-compose.yml
```
Fill in the docker-compose configuration, and remember to modify it according to your actual situation.
After that, we need to configure the reverse proxy. Remember to configure WebSocket support. I'll skip it here.
The idea is like this. You can refer to the configuration below:
{{< image src="stackDrawing.webp" caption="Stack" width="600px" >}}

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 KiB

View File

@@ -0,0 +1,189 @@
---
title: Migrate Umami Docker From One Server to Another
subtitle:
date: 2024-03-11T18:03:39-04:00
slug: umami-docker-migration
draft: false
author:
name: James
link: https://www.jamesflare.com
email:
avatar: /site-logo.avif
description: This blog post provides a step-by-step guide on migrating an Umami server running on Docker from one machine to another by exporting and importing the PostgreSQL database, ensuring a smooth transition while preserving all the essential data.
keywords: ["Docker", "PostgreSQL", "Umami", "Migration"]
license:
comment: true
weight: 0
tags:
- PostgreSQL
- Open Source
- Docker
- Umami
categories:
- Tutorials
hiddenFromHomePage: false
hiddenFromSearch: false
hiddenFromRss: false
hiddenFromRelated: false
summary: This blog post provides a step-by-step guide on migrating an Umami server running on Docker from one machine to another by exporting and importing the PostgreSQL database, ensuring a smooth transition while preserving all the essential data.
resources:
- name: featured-image
src: featured-image.jpg
- name: featured-image-preview
src: featured-image-preview.jpg
toc: true
math: false
lightgallery: false
password:
message:
repost:
enable: true
url:
# See details front matter: https://fixit.lruihao.cn/documentation/content-management/introduction/#front-matter
---
<!--more-->
## Introduction
Nearly, I bought a new ARM server from netcup GmbH, and I need to migrate my umami server from the old server to the new one. But I installed umami with Docker.
```yaml
version: '3'
services:
umami:
image: ghcr.io/umami-software/umami:postgresql-latest
ports:
- "3000:3000"
environment:
DATABASE_URL: postgresql://umami:umami@db:5432/umami
DATABASE_TYPE: postgresql
APP_SECRET: replace-me-with-a-random-string
depends_on:
db:
condition: service_healthy
restart: always
db:
image: postgres:15-alpine
environment:
POSTGRES_DB: umami
POSTGRES_USER: umami
POSTGRES_PASSWORD: umami
volumes:
- umami-db-data:/var/lib/postgresql/data
restart: always
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
interval: 5s
timeout: 5s
retries: 5
volumes:
umami-db-data:
```
The most difficult and important part is exporting data in umami. To do that, we have several methods:
- Export the Docker volume (Very complex)
- Export the database (My choice)
- Copy the whole path (Not recommend)
## Compare Methods
First, we need to know that umami's data is in the volume. Since `docker-compose.yml` specify that:
```yaml
services:
db:
volumes:
- umami-db-data:/var/lib/postgresql/data
volumes:
umami-db-data:
```
If I mounted a path into the container instead of a volume, I can simply copy the path to my new machine. For example,
```yaml
services:
db:
volumes:
- /root/umami/data:/var/lib/postgresql/data
```
Sadly I used a volume and made things complex. How to migrated Docker volume (in a right way) is welled discussed over the internet. For example, [Move a Docker volume to another host](https://4sysops.com/archives/move-a-docker-volume-to-another-host/). This is too complex for me. You may ask, the Docker volumes are stored in a fixed path like `/var/lib/docker/volumes/*`. Why not just copy the folder to another machine and start as normal? Well, this is applicable and I have done this before. But it may cause some potential issues, especially for different Docker container version.
Finally, I choice to just export the database and import to the new instance. Let's do it step by step.
## Migrate Database
FIrst, let's attach to the old container.
```bash
docker exec -it umami-db-1 /bin/sh
```
Export the database as a `.sql` file.
```bash
cd /
pg_dump --username=umami umami > umami.sql
```
Now the database is in `umami.sql`, but it's inside the container, so press `Ctrl + D` to disconnect from the container shell. Then, copy the file into host machine.
```bash
docker cp umami-db-1:/umami.sql /root
```
Then, you need transfer this backup file to your new host machine. After you `docker compose up -d` the `umami-db-1` container will be created. Then, you can copy the database backup file into the container by:
```bash
docker cp /root/umami.sql umami-db-1:/
```
Then, we can attach to the `umami-db-1` by:
```bash
docker exec -it umami-db-1 /bin/sh
```
To import the backup into the PostgreSQL, we need login `psql` as `umami`:
```bash
psql --username=umami -d postgres
```
In `psql` shell, we will drop the original database and create a blank one for preparing import.
```bash
DROP DATABASE umami;
CREATE DATABASE umami;
```
Then, quit `psql` shell and run:
```bash
cd /
psql --username=umami -f umami.sql umami
```
to import backup file. Finally, restart the umami instance:
```bash
cd /path/to/umami/docker-compose.yaml/
docker compose down
docker compose up -d
```
## Check
Now, you may have a check to see the database is migrated or not. Open the URL of your new umami location and try to login with your original credentials. If you can login, the database is very likely migrated (credentials is stored in database).
To further confirm, you can go to the dashboard and check if all data is displaying properly.
If not, which mean the database didn't migrated successfully. You may check the exported backup file (does it contain the right data?) and the way you import (see if the backup file is successfully imported to the new PostgreSQL).
## Reference
- [How To Migrate Umami From One Server To Another](https://www.programonaut.com/how-to-migrate-umami-from-one-server-to-another/)
- [How to Backup and Restore a PostgreSQL Database in Linux](https://www.tecmint.com/backup-and-restore-postgresql-database/)

View File

@@ -0,0 +1,270 @@
---
title: netcup vServer (ARM64) Benchmark and Review
subtitle:
date: 2024-03-09T22:33:19-05:00
slug: netcup-arm-review
draft: false
author:
name: James
link: https://www.jamesflare.com
email:
avatar: /site-logo.avif
description: This blog post reviews the performance of the netcup VPS 8000 ARM G11 server, featuring 18 vCore ARM64 CPUs based on Ampere Altra Max. It includes benchmark results from various testing scripts and compares the CPU performance with well-known processors.
keywords: ["netcup","VPS","ARM server","benchmark","Ampere Altra Max"]
license:
comment: true
weight: 0
tags:
- VPS
- Benchmark
- netcup
- ARM
categories:
- VPS
- Review
hiddenFromHomePage: false
hiddenFromSearch: false
hiddenFromRss: false
hiddenFromRelated: false
summary: This blog post reviews the performance of the netcup VPS 8000 ARM G11 server, featuring 18 vCore ARM64 CPUs based on Ampere Altra Max. It includes benchmark results from various testing scripts and compares the CPU performance with well-known processors.
resources:
- name: featured-image
src: featured-image.jpg
- name: featured-image-preview
src: featured-image-preview.jpg
toc: true
math: false
lightgallery: false
password:
message:
repost:
enable: true
url:
# See details front matter: https://fixit.lruihao.cn/documentation/content-management/introduction/#front-matter
---
<!--more-->
## Introduction
[netcup GmbH](https://www.netcup.eu) sells interesting ARM servers. I bought the [VPS 8000 ARM G11](https://www.netcup.eu/vserver/arm-server) version recently. It has 18 vCore (ARM64), offical website said it's based on Ampere Altra Max CPUs.
|Products|VPS 8000 ARM G11|
|---|---|
|Virtualisation technology|KVM|
|Processor|18 vCore (ARM64)|
|RAM|64GB DDR4 ECC|
|Storage space|2048 GB SSD|
|Network card|2500 Mbit/s|
|Traffic|inclusive|
## General Testing
Testing script from [Teddysun](https://teddysun.com/444.html) provides an idea of over all performance
```bash
wget -qO- bench.sh | bash
```
The result is here:
```text
-------------------- A Bench.sh Script By Teddysun -------------------
Version : v2023-10-15
Usage : wget -qO- bench.sh | bash
----------------------------------------------------------------------
CPU Model : CPU model not detected
CPU Cores : 18
AES-NI : ✓ Enabled
VM-x/AMD-V : ✗ Disabled
Total Disk : 2.0 TB (20.7 GB Used)
Total Mem : 62.7 GB (3.1 GB Used)
System uptime : 1 days, 14 hour 48 min
Load average : 0.25, 0.14, 0.10
OS : Debian GNU/Linux 12
Arch : aarch64 (64 Bit)
Kernel : 6.6.8
TCP CC : bbr
Virtualization : KVM
IPv4/IPv6 : ✓ Online / ✓ Online
Organization : AS197540 netcup GmbH
Location : Nürnberg / DE
Region : Bavaria
----------------------------------------------------------------------
I/O Speed(1st run) : 470 MB/s
I/O Speed(2nd run) : 673 MB/s
I/O Speed(3rd run) : 676 MB/s
I/O Speed(average) : 606.3 MB/s
----------------------------------------------------------------------
Node Name Upload Speed Download Speed Latency
Speedtest.net 174.35 Mbps 147.69 Mbps 0.29 ms
Los Angeles, US 626.82 Mbps 1950.34 Mbps 147.10 ms
Dallas, US 697.90 Mbps 2109.19 Mbps 133.37 ms
Montreal, CA 554.36 Mbps 904.78 Mbps 94.53 ms
Paris, FR 2108.91 Mbps 2321.03 Mbps 21.98 ms
Shanghai, CN 640.20 Mbps 1484.39 Mbps 255.22 ms
Hongkong, CN 5.00 Mbps 0.55 Mbps 301.56 ms
Mumbai, IN 1685.98 Mbps 2417.37 Mbps 116.27 ms
Singapore, SG 1592.12 Mbps 2572.71 Mbps 179.95 ms
Tokyo, JP 423.71 Mbps 1122.09 Mbps 217.83 ms
----------------------------------------------------------------------
Finished in : 5 min 15 sec
Timestamp : 2023-12-30 03:55:03 CET
----------------------------------------------------------------------
```
## Yet-Another-Bench-Script
```bash
curl -sL yabs.sh | bash
```
The result is very detailed and long, I split the result into parts. First, let's check the script information:
```text
# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #
# Yet-Another-Bench-Script #
# v2023-11-30 #
# https://github.com/masonr/yet-another-bench-script #
# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #
Sat Dec 30 04:16:48 AM CET 2023
ARM compatibility is considered *experimental*
```
Then, the basic OS information:
```text
Basic System Information:
---------------------------------
Uptime : 1 days, 15 hours, 15 minutes
Processor : Neoverse-N1
BIOS virt-5.2 CPU @ 2.0GHz
CPU cores : 18 @ ??? MHz
AES-NI : ✔ Enabled
VM-x/AMD-V : ❌ Disabled
RAM : 62.7 GiB
Swap : 0.0 KiB
Disk : 2.0 TiB
Distro : Debian GNU/Linux 12 (bookworm)
Kernel : 6.6.8
VM Type : KVM
IPv4/IPv6 : ✔ Online / ✔ Online
IPv6 Network Information:
---------------------------------
ISP : netcup GmbH
ASN : AS197540 netcup GmbH
Host : NETCUP-GMBH
Location : Karlsruhe, Baden-Wurttemberg (BW)
Country : Germany
```
Then, the Disk IO Test:
```text
fio Disk Speed Tests (Mixed R/W 50/50) (Partition /dev/vda4):
---------------------------------
Block Size | 4k (IOPS) | 64k (IOPS)
------ | --- ---- | ---- ----
Read | 138.63 MB/s (34.6k) | 261.70 MB/s (4.0k)
Write | 138.54 MB/s (34.6k) | 269.48 MB/s (4.2k)
Total | 277.18 MB/s (69.2k) | 531.19 MB/s (8.2k)
| |
Block Size | 512k (IOPS) | 1m (IOPS)
------ | --- ---- | ---- ----
Read | 298.21 MB/s (582) | 442.51 MB/s (432)
Write | 323.72 MB/s (632) | 493.71 MB/s (482)
Total | 621.93 MB/s (1.2k) | 936.22 MB/s (914)
```
Then, the Network Speed Test:
```text
iperf3 Network Speed Tests (IPv4):
---------------------------------
Provider | Location (Link) | Send Speed | Recv Speed | Ping
----- | ----- | ---- | ---- | ----
Clouvider | London, UK (10G) | 2.45 Gbits/sec | 2.37 Gbits/sec | 20.5 ms
Scaleway | Paris, FR (10G) | 2.46 Gbits/sec | busy | 20.1 ms
NovoServe | North Holland, NL (40G) | 2.47 Gbits/sec | 2.38 Gbits/sec | 9.96 ms
Uztelecom | Tashkent, UZ (10G) | 1.99 Gbits/sec | 996 Mbits/sec | 84.2 ms
Clouvider | NYC, NY, US (10G) | 2.00 Gbits/sec | 542 Mbits/sec | 91.6 ms
Clouvider | Dallas, TX, US (10G) | 1.44 Gbits/sec | 648 Mbits/sec | 128 ms
Clouvider | Los Angeles, CA, US (10G) | 1.16 Gbits/sec | 1.04 Gbits/sec | 147 ms
iperf3 Network Speed Tests (IPv6):
---------------------------------
Provider | Location (Link) | Send Speed | Recv Speed | Ping
----- | ----- | ---- | ---- | ----
Clouvider | London, UK (10G) | 2.44 Gbits/sec | 2.33 Gbits/sec | 20.5 ms
Scaleway | Paris, FR (10G) | busy | busy | 32.2 ms
NovoServe | North Holland, NL (40G) | 2.48 Gbits/sec | 2.35 Gbits/sec | 9.97 ms
Uztelecom | Tashkent, UZ (10G) | 2.10 Gbits/sec | 875 Mbits/sec | 84.4 ms
Clouvider | NYC, NY, US (10G) | 1.78 Gbits/sec | 893 Mbits/sec | 91.6 ms
Clouvider | Dallas, TX, US (10G) | 1.39 Gbits/sec | 852 Mbits/sec | 128 ms
Clouvider | Los Angeles, CA, US (10G) | 1.16 Gbits/sec | 549 Mbits/sec | 147 ms
```
Then, Geekbench 6 Result:
```text
Geekbench 6 Benchmark Test:
---------------------------------
Test | Value
|
Single Core | 1072
Multi Core | 8650
Full Test | https://browser.geekbench.com/v6/cpu/4192622
```
Finally, I tested Geekbench 5 only, with following script:
```bash
curl -sL yabs.sh | bash -s -- -i -f -n -5
```
Here is Geekbench 6 Result:
```text
Geekbench 5 Benchmark Test:
---------------------------------
Test | Value
|
Single Core | 798
Multi Core | 10975
Full Test | https://browser.geekbench.com/v5/cpu/22091599
```
## Review
Now, let's discuss the result.
### CPU Performance
VPS 8000 ARM G11's Geekbench 6 Multi-Core Score is around 8650, to help you get an idea od its level, I choiced some well known CPUs for comparing.
|CPU|Single-Core|Multi-Core Score|
|---|---|---|
|Intel Core i9-13900K|2970|20095|
|AMD Ryzen 9 7950X|2930|19224|
|Intel Core i9-12900K|2610|15428|
|AMD Ryzen 9 7940HS|2481|11741|
|AMD Ryzen 7 5800X3D|2085|10922|
|AMD Ryzen Z1 Extreme|2252|9689|
|AMD Ryzen 7 7840U|2099|8718|
|Intel Core i9-9900K|1664|7977|
My **Framework Laptop 13** with **AMD Ryzen 7 7840U** has a score of
|CPU|Single-Core|Multi-Core Score|
|---|---|---|
|AMD Ryzen 7 7840U|2256|12127|
This difference is because modern CPUs have dynamic booster mechanism, it can run above the base clock.
One more thing, I though a few records of Ampere [Altra Max 2800 MHz (96 cores)](https://browser.geekbench.com/v6/cpu/1590435) on the Geekbench 6 website. The Single-Core Score is 958 and Multi-Core Score is 11149.
This is odd, my 18 vCore server has a Multi-Core Score of 8650, the Altra Max 2800 MHz (96 cores) got only 11149. I guess the [Altra Max 2800 MHz (96 cores)](https://browser.geekbench.com/v6/cpu/1590435) records on the Geekbench 6 website is under performanced, since it's ADLINK Ampere Altra Developer Platform. It may be not tuned to optimized perfermance.

View File

@@ -0,0 +1,66 @@
---
title: Choice a Ideal Quantization Type for llama.cpp
subtitle:
date: 2024-03-09T20:59:27-05:00
slug: quantization-llama-cpp
draft: true
author:
name: James
link: https://www.jamesflare.com
email:
avatar: /site-logo.avif
description:
keywords:
license:
comment: true
weight: 0
tags:
- LLM
- Ollama
- llama.cpp
categories:
- AI
hiddenFromHomePage: false
hiddenFromSearch: false
hiddenFromRss: false
hiddenFromRelated: false
summary:
resources:
- name: featured-image
src: featured-image.jpg
- name: featured-image-preview
src: featured-image-preview.jpg
toc: true
math: false
lightgallery: false
password:
message:
repost:
enable: true
url:
# See details front matter: https://fixit.lruihao.cn/documentation/content-management/introduction/#front-matter
---
<!--more-->
| Q Type | Size | ppl Change | Note |
|:---:|:---:|:---:|:---:|
| Q2\_K\_S | 2.16G | +9.0634 | @ LLaMA-v1-7B |
| Q2\_K | 2.63G | +0.6717 | @ LLaMA-v1-7B |
| Q3\_K\_S | 2.75G | +0.5551 | @ LLaMA-v1-7B |
| Q3\_K | - | - | alias for Q3\_K\_M |
| Q3\_K\_M | 3.07G | +0.2496 | @ LLaMA-v1-7B |
| Q3\_K\_L | 3.35G | +0.1764 | @ LLaMA-v1-7B |
| Q4\_0 | 3.56G | +0.2166 | @ LLaMA-v1-7B |
| Q4\_K\_S | 3.59G | +0.0992 | @ LLaMA-v1-7B |
| Q4\_K | - | - | alias for Q4\_K\_M |
| Q4\_K\_M | 3.80G | +0.0532 | @ LLaMA-v1-7B |
| Q4\_1 | 3.90G | +0.1585 | @ LLaMA-v1-7B |
| Q5\_0 | 4.33G | +0.0683 | @ LLaMA-v1-7B |
| Q5\_K\_S | 4.33G | +0.0400 | @ LLaMA-v1-7B |
| Q5\_1 | 4.70G | +0.0349 | @ LLaMA-v1-7B |
| Q5\_K | - | - | alias for Q5\_K\_M |
| Q5\_K\_M | 4.45G | +0.0122 | @ LLaMA-v1-7B |
| Q6\_K | 5.15G | +0.0008 | @ LLaMA-v1-7B |
| Q8\_0 | 6.70G | +0.0004 | @ LLaMA-v1-7B |

View File

@@ -0,0 +1,372 @@
---
title: Config VLESS Protocol with Advance Feature in sing-box
subtitle:
date: 2024-03-09T22:44:42-05:00
slug: vless-tcp-reality-xtls-utls-xudp
draft: false
author:
name: James
link: https://www.jamesflare.com
email:
avatar: /site-logo.avif
description: This blog post provides a step-by-step guide on setting up a VLESS + TCP + REALITY + XTLS + uTLS + XUDP configuration using sing-box, covering server and client-side setup, installation, and running sing-box for a secure and efficient proxy solution.
license:
comment: true
weight: 0
tags:
- sing-box
- Proxy
- Security
- Networking
categories:
- Tutorials
- Proxy
hiddenFromHomePage: false
hiddenFromSearch: false
hiddenFromRss: false
hiddenFromRelated: false
summary: This blog post provides a step-by-step guide on setting up a VLESS + TCP + REALITY + XTLS + uTLS + XUDP configuration using sing-box, covering server and client-side setup, installation, and running sing-box for a secure and efficient proxy solution.
resources:
- name: featured-image
src: featured-image.jpg
- name: featured-image-preview
src: featured-image-preview.jpg
toc: true
math: false
lightgallery: false
password:
message:
repost:
enable: true
url:
# See details front matter: https://fixit.lruihao.cn/documentation/content-management/introduction/#front-matter
---
<!--more-->
## Introduction
VLESS + TCP + REALITY + XTLS + uTLS + XUDP is a very good combination. [XUDP](https://github.com/XTLS/Xray-core/discussions/252) let VLESS supports FullCone NAT. Using [REALITY](https://github.com/XTLS/REALITY#vless-xtls-utls-reality-example-for-xray-core-%E4%B8%AD%E6%96%87) instead of TLS can eliminate server-side TLS fingerprint characteristics, while still providing forward secrecy and rendering certificate chain attacks ineffective. Its security surpasses conventional TLS. It can point to other websites without the need to purchase a domain or configure a TLS server, making it more convenient. It achieves end-to-end genuine TLS presentation with a specified SNI to the middleman.
## Get sing-box
## sing-box Basic
sing-box uses JSON for configuration files.
```json
// Structure
{
"log": {},
"dns": {},
"ntp": {},
"inbounds": [],
"outbounds": [],
"route": {},
"experimental": {}
}
```
You can get detailed documents [here](https://sing-box.sagernet.org/configuration). I will not go through too much of them.
## Server Side
Before start we need to generate a x25519 key pair for REALITY. To do that in sing-box just run:
```bash
sing-box generate reality-keypair
```
You should get something like this:
```text
PrivateKey: 0H5tYLhpDT_r675UC93iWAS2LqN6mPZoDcVDqsff018
PublicKey: SeIw41mp1LFEd6CEGArmnSoaIXzNlwnkIbduoEY-OXk
```
Optionally, you can generate a short id for REALITY as well. By running this, you should get a 8 digit hex number:
```bash
sing-box generate rand 8 --hex
```
You should get something like this:
```text
26079ba8291ff0fc
```
Finally, you need to generate a UUID:
```bash
sing-box generate uuid
```
You should get something like this:
```text
11391936-7544-4af5-ad02-e9f3970b1f64
```
Now, let's fill them into the right place and finish the config. If you want to save some time and do not want to dive too deep, you can refer this config:
```json
{
"log":{
"level":"info"
},
"inbounds":[
{
"type":"vless",
"tag":"vless-in",
"listen":"0.0.0.0",
"listen_port":443,
"users":[
{
"name":"jamesflare",
"uuid":"11391936-7544-4af5-ad02-e9f3970b1f64",
"flow":"xtls-rprx-vision"
}
],
"tls":{
"enabled":true,
"server_name":"www.rpi.edu",
"reality":{
"enabled":true,
"handshake":{
"server":"www.rpi.edu",
"server_port":443
},
"private_key":"0H5tYLhpDT_r675UC93iWAS2LqN6mPZoDcVDqsff018",
"short_id":[
"26079ba8291ff0fc"
]
}
},
"multiplex":{
"enabled":false
}
}
],
"outbounds":[
{
"type":"direct",
"tag":"direct"
}
]
}
```
I highly recommand you change:
- `name`
- `uuid`
- `server_name`
- `server`
- `server_port`
- `private_key`
- `short_id`
to your own value, base on your own case.
## Client Side
I want sing-box use `TUN` as inbound, so we can archive global proxy. But you may run it as http/socks proxy as well. Anyhow, I will use `TUN` as example.
You need to change these following filed into your own value:
- `server`
- `server_port`
- `uuid`
- `server_name`
- `public_key`
- `short_id`
make sure your value match the server-side information. Here is an example:
```json
{
"log":{
"level":"info",
"timestamp":true
},
"dns":{
"servers":[
{
"tag":"cloudflare",
"address":"1.1.1.1"
}
],
"rules":[
{
"outbound":"any",
"server":"cloudflare"
}
],
"strategy":"ipv4_only"
},
"inbounds":[
{
"type":"tun",
"tag":"tun-in",
"interface_name":"tun0",
"inet4_address":"172.28.0.1/30",
"auto_route":true,
"strict_route":true,
"stack":"system",
"sniff":true
}
],
"outbounds":[
{
"type":"vless",
"tag":"vless-out",
"server":"your.server.ip.or.domain",
"server_port":443,
"uuid":"11391936-7544-4af5-ad02-e9f3970b1f64",
"flow":"xtls-rprx-vision",
"tls":{
"enabled":true,
"server_name":"www.rpi.edu",
"utls":{
"enabled":true,
"fingerprint":"chrome"
},
"reality":{
"enabled":true,
"public_key":"SeIw41mp1LFEd6CEGArmnSoaIXzNlwnkIbduoEY-OXk",
"short_id":"26079ba8291ff0fc"
}
},
"packet_encoding":"xudp",
"multiplex":{
"enabled":false
}
},
{
"type":"direct",
"tag":"direct"
},
{
"type":"dns",
"tag":"dns"
}
],
"route":{
"geoip":{
"download_url":"https://github.com/SagerNet/sing-geoip/releases/latest/download/geoip.db",
"download_detour":"vless-out"
},
"geosite":{
"download_url":"https://github.com/SagerNet/sing-geosite/releases/latest/download/geosite.db",
"download_detour":"vless-out"
},
"rules":[
{
"protocol":"dns",
"outbound":"dns"
},
{
"geoip":[
"private"
],
"outbound":"direct"
}
],
"auto_detect_interface":true
}
}
```
## Install sing-box
You may ask "how can I run sing-box with aboving config?". Well, you need install sing-box at first. You can find more information in the [offical document](https://sing-box.sagernet.org/installation/package-manager/).
### In Debian 12
I run sing-box server side on a Linux server, the OS is Debian 12. I this way, I used the offical installing script for debian:
```bash
bash <(curl -fsSL https://sing-box.app/deb-install.sh)
```
You can check installation by running:
```bash
sing-box help
```
It should return something like:
```text
Usage:
sing-box [command]
Available Commands:
check Check configuration
completion Generate the autocompletion script for the specified shell
format Format configuration
generate Generate things
help Help about any command
merge Merge configurations
run Run service
tools Experimental tools
version Print current version of sing-box
Flags:
-c, --config stringArray set configuration file path
-C, --config-directory stringArray set configuration directory path
-D, --directory string set working directory
--disable-color disable color output
-h, --help help for sing-box
Use "sing-box [command] --help" for more information about a command.
```
For Linux systems with systemd, usually the installation already includes a sing-box service, you can manage the service using the following command:
### In Windows 11
My client is Windows 11, I choice managed installation with [Chocolatey](https://chocolatey.org/install#individual). To install Chocolatey, you need run an Administrator PowerShell with:
```bash
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
```
If you don't see any errors, you are ready to use Chocolatey! Type `choco` or `choco -?` to check installation. Remember, this is a very simple instraction of Chocolatey, there are many other installation methods and options, please check offical site for more information.
Now, we can use Chocolatey to install sing-box:
```bash
choco install sing-box
```
You can check installation by running:
```bash
sing-box help
```
## Run sing-box
There are no different between server-side and client-side sing-box program. Only different is the config file.
Before start, you should save your config into a JSON file. I will name them like: `client.json`, `server.json`. Then specify the config in your command, like:
```bash
sing-box run -c client.json
```
You need to run sing-box both in client and server side. The output should be like:
```text
C:\Users\James\Desktop\Softwares\sing-box>sing-box run -c xray-ny-a-client.json
-0500 2023-12-27 23:23:32 INFO router: updated default interface Wi-Fi, index 18
-0500 2023-12-27 23:23:32 INFO inbound/tun[tun-in]: started at tun0
-0500 2023-12-27 23:23:32 INFO sing-box started (0.288s)
-0500 2023-12-27 23:23:32 INFO [832064929 0ms] inbound/tun[tun-in]: inbound packet connection from 172.28.0.1:55770
-0500 2023-12-27 23:23:32 INFO [1067986987 0ms] inbound/tun[tun-in]: inbound packet connection from 172.28.0.1:58423
-0500 2023-12-27 23:23:32 INFO [2253360887 0ms] inbound/tun[tun-in]: inbound connection from 172.28.0.1:60610
-0500 2023-12-27 23:23:32 INFO outbound/vless[vless-out]: outbound packet connection to 1.1.1.1:53
```

View File

@@ -0,0 +1,312 @@
---
title: Claude 3 Opus 在 C 语言考试中的表现
subtitle:
date: 2024-03-11T20:17:44-04:00
slug: claude-3-opus-c-exam
draft: false
author:
name: James
link: https://www.jamesflare.com
email:
avatar: /site-logo.avif
description: 这篇博文展示了一场模拟的 C 语言编程考试,题型包括填空题、简答题和应用题等,目的是全方位测试学生对 C 语言知识的掌握程度、分析问题解决问题的能力,以及编写高效优雅代码的水平。通过这样一场模拟测试,可以帮助学生查漏补缺,为真正的考试做好充分准备。同时,也能让读者对 C 语言的考察重点有一个直观的认识。
keywords: ["C语言","考试","编程题"]
license:
comment: true
weight: 0
tags:
- C语言
- 考试
- Claude
- LLM
- 基准测试
categories:
- 测评
- 编程语言
- 大语言模型
hiddenFromHomePage: false
hiddenFromSearch: false
hiddenFromRss: false
hiddenFromRelated: false
summary: 这篇博文展示了一场模拟的 C 语言编程考试,题型包括填空题、简答题和应用题等,目的是全方位测试学生对 C 语言知识的掌握程度、分析问题解决问题的能力,以及编写高效优雅代码的水平。通过这样一场模拟测试,可以帮助学生查漏补缺,为真正的考试做好充分准备。同时,也能让读者对 C 语言的考察重点有一个直观的认识。
resources:
- name: featured-image
src: featured-image.jpg
- name: featured-image-preview
src: featured-image-preview.jpg
toc: true
math: true
lightgallery: false
password:
message:
repost:
enable: true
url:
# See details front matter: https://fixit.lruihao.cn/documentation/content-management/introduction/#front-matter
---
<!--more-->
{{< admonition type=note title="System Prompt" open=true >}}
你在扮演一位学习C语言的学生你现在的任务是接受一场关于C语言的考试。在这次考试里你需要发挥你的最佳水平尽可能详细地作答以便取得高分。各位考生加油
{{< /admonition >}}
## 填空题
1. 计算机的工作原理是(**A**)。
**A** = 存储程序和程序控制
2. 整数在内存中用二进制(**B**)码表示。
**B** = 补码
3. 关系运算符有(**C**6种。
**C** = <、<=、>、>=、==、!=
4. 循环语句的形式有(**D**3种。
**D** = while、do-while、for
5. 使用函数要经过三个步骤(**E**)、定义和调用。
**E** = 声明
6. 数组元素在内存中是(**F**)存放的。
**F** = 连续
7. 指针的两个要素是地址和(**G**)。
**G** = 类型
8. 使用数学库函数,要包含的头文件为(**H**)。
**H** = <math.h>
9. 在函数外部定义的变量称为(**I**)变量。
**I** = 全局
10. 定义结构类型的关键字是(**J**)。
**J** = struct
## 简答题
1. **break和continue语句的作用**
break语句用于跳出当前循环体结束循环的执行。当执行到break语句时程序将立即跳出所在的循环开始执行循环后面的语句。
continue语句用于跳过本次循环的剩余语句直接进入下一次循环。当执行到continue语句时程序将立即跳到循环控制表达式处开始下一次循环。
2. **函数返回多个值的解决办法**
可以使用指针作为函数参数,通过指针传递多个变量的地址,在函数内部修改这些变量的值,从而实现返回多个值的效果。
例如,编写一个函数,用于计算两个整数的和与差,并通过指针返回结果:
```c
void calc(int a, int b, int *sum, int *diff) {
*sum = a + b;
*diff = a - b;
}
```
在主函数中调用:
```c
int main() {
int x = 10, y = 5, sum, diff;
calc(x, y, &sum, &diff);
printf("Sum: %d, Diff: %d\n", sum, diff);
return 0;
}
```
3. **需要使用动态内存分配的情况**
当程序运行时才能确定所需内存大小,或者需要频繁地申请和释放内存时,就需要使用动态内存分配。
例如,读取一个文件,将文件内容存储到内存中。由于文件大小事先未知,需要根据实际读取的字节数动态分配内存:
```c
FILE *fp = fopen("data.txt", "r");
char *buffer = NULL;
int size = 0;
int capacity = 0;
char ch;
while ((ch = fgetc(fp)) != EOF) {
if (size + 1 > capacity) {
capacity = (capacity == 0) ? 1 : capacity * 2;
buffer = (char *)realloc(buffer, capacity);
}
buffer[size++] = ch;
}
buffer[size] = '\0';
fclose(fp);
```
4. **穷举法的基本思想**
穷举法是一种基本的算法思想,它的基本思路是:列举出所有可能的情况,逐一判断每种情况是否满足题目要求,从而得到问题的解。
例如求解1~100之间所有的素数。可以使用穷举法遍历1~100的每个数判断它是否为素数
```c
for (int i = 2; i <= 100; i++) {
int isPrime = 1;
for (int j = 2; j < i; j++) {
if (i % j == 0) {
isPrime = 0;
break;
}
}
if (isPrime) {
printf("%d ", i);
}
}
```
5. **适宜用数组存储数据的实际问题**
(1) 学生成绩管理系统:可以使用数组存储每个学生的各科成绩,方便进行成绩的录入、查询和统计。
(2) 图像处理:图像可以看作是一个二维数组,数组的每个元素表示图像上对应位置的像素值。使用数组可以方便地进行图像的读取、修改和显示。
## 应用题
1. **一个三位的十进制整数,如果它的三个数位数字的立方和等于这个数的数值,那么它就被称为一个“水仙花数”(例如:$153 = 1^3 + 5^3 + 3^3$)。请定义函数,判断一个整数是否为水仙花数,并利用这个函数打印出所有的水仙花数。**
```c
#include <stdio.h>
#include <math.h>
int isNarcissistic(int num) {
int sum = 0;
int temp = num;
while (temp > 0) {
int digit = temp % 10;
sum += pow(digit, 3);
temp /= 10;
}
return (sum == num);
}
int main() {
printf("所有的水仙花数:\n");
for (int i = 100; i <= 999; i++) {
if (isNarcissistic(i)) {
printf("%d ", i);
}
}
return 0;
}
```
2. **已知有迭代关系 $x_{k+1} = \frac{4}{3}x_{k} - \frac{a}{3x^{2}_{k}}$,其中 $\alpha \isin \Reals$, 且 $\\{ x_k \\}$ 收敛。写程序估算 $x_k$ 的极限值。**
```c
#include <stdio.h>
#include <math.h>
#define EPSILON 1e-6
double iterate(double x, double a) {
return (4.0 / 3.0) * x - a / (3 * x * x);
}
int main() {
double a;
printf("请输入参数a的值");
scanf("%lf", &a);
double x0 = 1.0; // 初始值
double x1 = iterate(x0, a);
while (fabs(x1 - x0) > EPSILON) {
x0 = x1;
x1 = iterate(x0, a);
}
printf("迭代序列的极限值估计为:%.6f\n", x1);
return 0;
}
```
3. **有 n 个学生,每个学生的信息为:姓名,成绩。用动态存储分配方式存储数据,完成以下操作:**
```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_NAME 20
typedef struct {
char name[MAX_NAME];
int score;
} Student;
void inputStudents(Student *students, int n) {
for (int i = 0; i < n; i++) {
printf("请输入第%d个学生的姓名和成绩", i + 1);
scanf("%s %d", students[i].name, &students[i].score);
}
}
void printStudents(Student *students, int n) {
printf("学生信息:\n");
for (int i = 0; i < n; i++) {
printf("姓名:%s\t成绩%d\n", students[i].name, students[i].score);
}
}
void sortStudents(Student *students, int n) {
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (students[j].score < students[j + 1].score) {
Student temp = students[j];
students[j] = students[j + 1];
students[j + 1] = temp;
}
}
}
}
int main() {
int n;
printf("请输入学生人数:");
scanf("%d", &n);
Student *students = (Student *)malloc(n * sizeof(Student));
inputStudents(students, n);
printStudents(students, n);
sortStudents(students, n);
printf("按成绩降序排列后的学生信息:\n");
printStudents(students, n);
free(students);
return 0;
}
```
以上程序实现了以下功能:
1. 定义了学生结构体,包含姓名和成绩两个字段。
3. 使用动态内存分配创建了一个学生结构体数组大小为n。
4. 提供了输入学生信息、打印学生信息和按成绩降序排序学生信息的函数。
5. 在主函数中,先输入学生人数,然后动态分配内存创建学生数组。
6. 调用相应函数输入学生信息、打印学生信息、对学生按成绩降序排序并打印排序后的结果。
7. 最后释放动态分配的内存。

View File

@@ -0,0 +1,664 @@
---
title: 使用 ChatGPT 轻松创建选择题
subtitle:
date: 2023-03-04T16:45:19+08:00
slug: create-mcq-chatgpt-scales
draft: false
author:
name: James
link: https://www.jamesflare.com
email:
avatar: /site-logo.avif
description: 本文将手把手教你如何利用 ChatGPT、Python 和 JSON 文件高效创建选择题试卷。从自动生成题库,到格式化试题、答题纸和评分标准,一应俱全。跟着教程学习,你也能轻松搞定选择题卷子。
keywords: ["选择题","ChatGPT","Python","JSON"]
license:
comment: true
weight: 0
tags:
- ChatGPT
- Python
categories:
- 教程
- 大语言模型
hiddenFromHomePage: false
hiddenFromSearch: false
hiddenFromRss: false
hiddenFromRelated: false
summary: 本文将手把手教你如何利用 ChatGPT、Python 和 JSON 文件高效创建选择题试卷。从自动生成题库,到格式化试题、答题纸和评分标准,一应俱全。跟着教程学习,你也能轻松搞定选择题卷子。
resources:
- name: featured-image
src: featured-image.jpg
- name: featured-image-preview
src: featured-image-preview.jpg
toc: true
math: false
lightgallery: false
password:
message:
repost:
enable: true
url:
# 更多 front matter 设置详见: https://fixit.lruihao.cn/zh-cn/documentation/content-management/introduction/#front-matter
---
<!--more-->
意译:
## 简介
亲爱的老师们,大家好!
出选择题卷子是不是让你们头疼?
这篇文章将手把手教你如何在 Scales 中高效创建选择题卷子。从自动生成题库,到随机抽题组卷,再到格式化输出试卷、答题纸和评分标准,一应俱全。跟着教程学习,相信你也能轻松搞定选择题卷子。
### 步骤
1. 让 ChatGPT 制作 .json 格式的题库。
2. 用 Python 程序格式化 .json 题库。
3. 再写一个 Python 程序,从 .json 题库中随机抽题组卷。
## 提示工程
首先,我们希望选择题的内容要契合教学主题。为此,需要明确告诉 ChatGPT 要做什么,以及给它哪些素材。
你可以参考这个提示模板:
> \[指令\] +
>
> \[题目模板\] +
>
> \[学习目标\] +
>
> \[主题概念\] +
>
> \[补充要点\] +
>
> \[题干用词\] +
>
> \[ChatGPT 须知\]
我做了一个关于天体物理学的示例,虽然不够完美,没有涵盖所有知识点。所以批量生成的选择题可能有点单调。但至少在选项上不会重复。
这样一来,靠死记硬背选项的学生就没辙了。
### 示例
{{< admonition type=warning title="这不是原始输入" open=true >}}
为了方便阅读,我把原始的 Markdown 格式转成了网页版。
如果你想看原始的输入,可以在本节末尾找到一个下拉框。
{{< /admonition >}}
> 你是一个从不出错的 AI 驱动的 json 文件生成器。请你先在脑海中想象 1000 个关于天体物理学的选择题,然后随机给我 15 个,要求如下格式:
>
> ```json
> [
> {
> "order_number": "[题号]",
> "question": "[题干]",
> "type": "mcq",
> "option_a": "[选项 A]",
> "option_b": "[选项 B]",
> "option_c": "[选项 C]",
> "option_d": "[选项 D]",
> "answer": "[正确选项,ABCD 之一]",
> "explanation": "[答案解析]"
> },
> {
> "order_number": "[题号]",
> "question": "[题干]",
> "type": "mcq",
> "option_a": "[选项 A]",
> "option_b": "[选项 B]",
> "option_c": "[选项 C]",
> "option_d": "[选项 D]",
> "answer": "[正确选项,ABCD 之一]",
> "explanation": "[答案解析]"
> }
> ]
> ```
>
> 请检查你生成的选择题是否覆盖了以下学习目标:
>
> 1. 描述构成宇宙的主要天体。
>
> 2. 描述恒星的性质。
>
> 3. 理解天文距离。
>
> 4. 掌握视差法。
>
> 5. 定义光度和视星等,并用它们解决有关距离的问题。
>
> 以及这些关键概念:
> |术语|定义|
> |:----|:----|
> |双星|绕共同中心运转的两颗恒星|
> |黑矮星|白矮星冷却后的残骸,光度极低|
> |黑洞|时空奇点,大质量恒星演化的终点|
> |褐矮星|未达到引发聚变的温度的气体和尘埃天体,持续收缩冷却|
> |造父变星|光度周期性变化的恒星,光度先急剧增加再缓慢下降。周期与其绝对光度相关,可用于估算距离|
> |星系团|引力相互作用的星系集团|
> |彗星|主要由冰和尘埃组成,绕太阳椭圆轨道运行的小天体|
> |星座|在空间中看似彼此靠近、形成可辨认图案的一组恒星|
> |暗物质|星系和星系团中太冷而无法辐射的物质,其存在通过非直接观测推断|
> |星系|引力束缚在一起的大量恒星集合,从矮星系的数百万到大星系的数千亿颗恒星不等。估计可观测宇宙中有 1000 亿个星系|
> |星际介质|弥漫于恒星之间的稀薄气体(主要是氢和氦)和尘埃(硅酸盐、碳和铁),密度极低,每立方厘米约一个原子,尘埃密度更低万亿倍,温度约 100K|
> |主序星|正在进行氢聚变成氦的正常恒星,如太阳|
> |星云|恒星之间的尘埃云,含碳、氧、硅、金属化合物及分子氢|
> |中子星|红超巨星爆炸的产物,直径数十公里,密度极高,主要由中子组成,中子围绕高压高密度核形成超流体。微观量子物理的宏观奇观|
> |行星状星云|红巨星喷出的气壳|
> |红矮星|体积小、温度低的红色恒星|
> |红巨星|主序星演化的下一阶段,体积膨胀、表面温度下降的红色巨星,内部发生氦聚变|
> |星团|在空间中物理位置靠近,由单个气体云坍缩形成的恒星群|
> |超新星(Ia 型)|从伴星吸积物质超过稳定性极限的白矮星爆炸|
> |超新星(II 型)|红超巨星爆炸,瞬间释放的能量惊人,相当于太阳一生的总辐射量!|
> |白矮星|红巨星爆炸的残骸,体积如地球但密度极大,无核反应发生但温度极高,体积小导致光度很低|
>
> 补充要点:
>
> 1. 核聚变提供恒星保持高温所需的能量,使辐射压抵消引力收缩,同时供给恒星向外辐射的能量。
>
> 2. 恒星辐射的功率在天文学中称为光度,单位是瓦特。
>
> 3. 视星等的单位是每平方米瓦特,即 W/m^2。
>
> 题干要用多种句式:
>
> 1. \[背景\] + 什么是...
>
> 2. 关于...哪项正确
>
> 3. 根据...哪个...
>
> 4. 哪个...可能是...
>
> 5. 从...可知...是什么
>
> 6. ...是什么
>
> 7. 哪个...正确
>
> 8. 哪项陈述...
>
> 9. 哪项陈述支持...
>
> 10. 哪项不正确...
>
> 不要反复用同一句式。
>
> 注意事项:
>
> 1. 根据以上信息和你的知识(如有需要)编写所有选择题。如有冲突,以你的知识为准,添加细节和背景信息丰富题目。
>
> 2. 发挥创意,经常变换问题角度,不拘泥于从名词到解释,可以从解释问名词,问名词间关系,或结合例子提问。目标是帮助学生全面、透彻地理解主题。
>
> 3. 只给出选择题,不要写解析。确保 json 格式正确。
>
> 4. 只用英文引号和标点。
ChatGPT 只能输入纯文本,但它能理解 Markdown 语法。以下是原始的输入提示。
如果你不会写 Markdown 表格,可以试试这个工具:[Table to Markdown](https://markdown-convert.com/en/tool/table)。
```text
You are an AI-powered json file generator that never make mistakes, and you are going to imagine 1000 MCQs about Astrophysics first in mind, then randomly give me 15 of them in this json form:
[
{
"order_number": "[Order Number]",
"question": "[Question]",
"type": "mcq",
"option_a": "[Option A]",
"option_b": "[Option B]",
"option_c": "[Option C]",
"option_d": "[Option D]",
"answer": "[Correct Option in ABCD]",
"explanation": "[Explanation of Why This Answer]"
},
{
"order_number": "[Order Number]",
"question": "[Question]",
"type": "mcq",
"option_a": "[Option A]",
"option_b": "[Option B]",
"option_c": "[Option C]",
"option_d": "[Option D]",
"answer": "[Correct Option in ABCD]",
"explanation": "[Explanation of Why This Answer]"
}
]
Please check the understanding of Learning objectives in your generated MCQs:
1. Describe the main objects comprising the universe.
2. Describe the nature of stars.
3. Understand astronomical distances.
4. Work with the method of parallax.
5. Define luminosity and apparent brightness and solve problems with these quantities and distance.
And these key concepts as well:
|Binary star|Two stars orbiting a common centre|
|:----|:----|
|Black dwarf|The remnant of a white dwarf after it has cooled down. It has very low luminosity|
|Black hole|A singularity in space time; the end result of the evolution of a very massive star|
|Brown dwarf|Gas and dust that did not reach a high enough temperature to initiate fusion. These objects continue to compact and cool down|
|Cepheid variable|A star of variable luminosity. The luminosity increases sharply and falls off gently with a well-defined period. The period is related to the absolute luminosity of the star and so can be used to estimate the distance to the star|
|Cluster of galaxies|Galaxies close to one another and affecting one another gravitationally, behaving as one unit|
|Comet|A small body (mainly ice and dust) orbiting the Sun in an elliptical orbit|
|Constellation|A group of stars in a recognizable pattern that appear to be near each other in space|
|Dark matter|Generic name for matter in galaxies and clusters of galaxies that is too cold to radiate. Its existence is inferred from techniques other than direct visual observation|
|Galaxy|A collection of a very large number of stars mutually attracting one another through the gravitational force and staying together. The number of stars in a galaxy varies from a few million in dwarf galaxies to hundreds of billions in large galaxies. It is estimated that 100 billion galaxies exist in the observable universe|
|Interstellar medium|Gases (mainly hydrogen and helium) and dust grains (silicates, carbon and iron) filling the space between stars. The density of the interstellar medium is very low. There is about one atom of gas for every cubic centimeter of space. The density of dust is a trillion times smaller. The temperature of the gas is about 100 K|
|Main-sequence star|A normal star that is undergoing nuclear fusion of hydrogen into helium. Our Sun is a typical main-sequence star|
|Nebula|Clouds of 'dust', i.e. compounds of carbon, oxygen, silicon and metals, as well as molecular hydrogen, in the space in between stars|
|Neutron star|The end result of the explosion of a red supergiant; a very small star (a few tens of kilometers in diameter) and very dense. This is a star consisting almost entirely of neutrons. The neutrons form a superfluid around a core of immense pressure and density. A neutron star is an astonishing macroscopic example of microscopic quantum physics|
|Planetary nebula|The ejected envelope of a red giant star|
|Red dwarf|A very small star with low temperature, reddish in color|
|Red giant|A main-sequence star evolves into a red giant - a very large, reddish star. There are nuclear reactions involving the fusion of helium into heavier elements|
|Stellar cluster|A group of stars that are physically near each other in space, created by the collapse of a single gas cloud|
|Supernova (Type la)|The explosion of a white dwarf that has accreted mass from a companion star exceeding its stability limit|
|Supernova (Type II)|The explosion of a red supergiant star: The amount of energy emitted in a supernova explosion can be staggering - comparable to the total energy radiated by our Sun in its entire lifetime!|
|White dwarf|The end result of the explosion of a red giant. A small, dense star (about the size of the Earth), in which no nuclear reactions take place. It is very hot but its small size gives it a very low luminosity]|
in Additional of:
1. Nuclear fusion provides the energy that is needed to keep the star hot, so that the radiation pressure is high enough to oppose further gravitational contraction, and at the same time to provide the energy that the star is radiating into space.
2. The power radiated by a star is known in astrophysics as the luminosity. It is measured in watts.
3. The unit of apparent brightness is W m^{2}.
You must use a variety of multiple-choice question types:
1. [Background] + what is ...
2. What is true about ...
3. Which ... according ...
4. Which ... can be ...
5. What is ... from ...
6. What is ...
7. Which ... is correct
8. Which statement ...
9. Which statement justify ...
10. Which is not correct ...
Do not repeat on one type of sentence.
Primary Order:
1. Make all MCQs base on above information and your knowledge if needed. When there are conflict between your knowledge and the above information. You should use your knowledge to add more detail and background to produce MCQs.
2. Be creative, change the perspective of your questions randomly, not necessarily from nouns to explanations, but from explanations to nouns, or ask questions based on the relationship between nouns, or ask questions in conjunction with examples; your goal is to help students fully understand the topic from all angles.
3. Only reply the MCQs and nothing else, do not write explanations. Make sure your answer has right json grammar.
4. Use english quotation marks or any other english punctuation only.
```
## 格式化题库
在我们开始之前,我们应该了解一些关于.json格式的基础知识。在我们的情况下我们希望我们的问题库如下
```json
[
{
"order_number": "1",
"question": "What is a galaxy?",
"type": "mcq",
"option_a": "A collection of planets",
"option_b": "A collection of stars",
"option_c": "A collection of asteroids",
"option_d": "A collection of comets",
"answer": "B",
"explanation": "A galaxy is a collection of a very large number of stars mutually attracting one another through the gravitational force and staying together."
},
{
"order_number": "2",
"question": "What is a main-sequence star?",
"type": "mcq",
"option_a": "A star that has run out of fuel",
"option_b": "A star that is undergoing nuclear fusion of hydrogen into helium",
"option_c": "A star that is about to explode",
"option_d": "A star that is very small and has low temperature",
"answer": "B",
"explanation": "A main-sequence star is a normal star that is undergoing nuclear fusion of hydrogen into helium."
}
]
```
我们使用方括号来包含所有的花括号。同时,花括号之间需要用逗号分隔。
```json
[
{
//Something
},
{
//Something
},
{
//Something
}
]
```
ChatGPT可能会给你一个答案如下
```json
{
order_number: 1,
question: What is an astronomical unit (AU)?,
type: mcq,
option_a: The average distance between the Earth and the Sun.,
option_b: The radius of the Earth.,
option_c: The distance traveled by light in one year.,
option_d: The mass of the Earth.,
answer: The average distance between the Earth and the Sun.,
explanation: An astronomical unit or AU is a unit of measurement equal to the average distance between Earth and the Sun. It is commonly used to measure distances within our solar system.
},
{
order_number: 2,
question: Which of the following is not a type of galaxy?,
type: mcq,
option_a: Elliptical,
option_b: Spiral,
option_c: Irregular,
option_d: Spherical,
answer: Spherical,
explanation: The three main types of galaxies are elliptical, spiral, and irregular. There is no galaxy type called spherical.
},
```
三个主要问题
1. 存在非英文引号。
2. 末尾多了一个逗号。
3. 缺少方括号。
虽然缩进丢失了,但这不是问题。你可以将文本复制到 [JSON Formatter](https://jsonformatter.curiousconcept.com/#) 中,让它看起来更整洁。
要修复非英文引号,只需使用替换函数即可。不建议使用 Word 或 WPS 来完成这项工作。我推荐使用 [Sublimetext 4](https://www.sublimetext.com/download) 文本编辑器,其他编辑器如 BBEdit 也可以。
从 ChatGPT 复制答案片段后,你可能会发现 `order_number` 是混乱的。
不用担心,首先,在下一步创建选择题试卷时,试卷中的题号不是来自 .json 文件中的 `order_number`
其次,这里有一个 Python 程序可以解决这个问题。但是,如果你不在意美观,只需确保你的 json 文件没有语法错误即可。要做到这一点,可以使用 [JSON Formatter](https://jsonformatter.curiousconcept.com/#) 进行检查。
```py
import json
from collections import OrderedDict
# 打开 JSON 文件,将数据加载为字典列表
with open('data.json', 'r') as f:
data = json.load(f)
# 创建有序字典,按照题目编号存储题目
data_dict = OrderedDict()
for obj in data:
if 'order_number' in obj:
order_number = obj['order_number']
if order_number in data_dict:
data_dict[order_number].append(obj)
else:
data_dict[order_number] = [obj]
# 创建新的字典列表,按照题目编号排序题目
data_sorted = []
for order_number, objs in data_dict.items():
for i, obj in enumerate(objs):
obj['order_number'] = str(len(data_sorted) + i + 1)
data_sorted.extend(objs)
# 将修改后的字典列表写回 JSON 文件
with open('question_bank.json', 'w') as f:
json.dump(data_sorted, f, indent=2)
```
我不想在如何运行 Python 程序上花太多时间,所以我会快速介绍一下。
1. 安装 Python在运行 Python 程序之前,需要确保电脑上已经安装了 Python。可以从 [官网](https://www.python.org/downloads/) 下载最新版本的 Python选择适合自己操作系统的版本按照安装说明进行操作。
如果你有 Homebrew只需运行 `brew install python` 即可。
2. 创建 Python 程序:安装好 Python 后,需要创建一个 Python 程序。可以使用任意文本编辑器创建 Python 程序,将文件以 `.py` 为扩展名保存。在这里,你可以将文件重命名为 `qbReorder.py`,将上面的 Python 代码粘贴进去并保存。
3. 打开终端或命令提示符:在电脑上打开终端或命令提示符,这是你运行 Python 程序的地方。
4. 运行 Python 程序:在终端或命令提示符中输入以下命令,即可运行 Python 程序:
```shell
python qbReorder.py
```
如果不起作用,可以试试:
```shell
python3 qbReorder.py
```
如果 `qbReorder.py` 不在当前路径下,可以这样运行:
```shell
python /path/to/the/qbReorder.py
```
在我的 `qbReorder.py` 中,我将未排序的 JSON 文件设为 `data.json`。运行程序后,你会在运行路径下得到一个 `question_bank.json` 文件。如果你想要其他名字,可以修改代码。
我强烈建议你为这个任务创建一个文件夹,将所有文件都放在里面:
- qbReorder.py
- data.json
- question_bank.json
使用终端时,可以选择"在此处打开终端",或使用 `cd` 命令切换到工作文件夹:
```shell
cd /the/path/to/working/folder
```
为了安全起见,可以输入 `ls` 命令查看该文件夹下的所有文件/文件夹。然后,运行以下命令:
```shell
python qbReorder.py
```
```shell
python3 /qbReorder.py
```
来执行题库重排序。
这就是题库准备的全部内容了。
## 制作试卷
现在,我们来制作真正的选择题试卷。
为此,我编写了另一个 Python 程序:
```py
import argparse
import json
import random
from docx import Document
from docx.shared import Pt
from docx.enum.text import WD_ALIGN_PARAGRAPH
# 定义命令行参数
parser = argparse.ArgumentParser(description='生成试卷、答题纸和评分方案。')
parser.add_argument('-q', '--question-bank', type=str, required=True, help='题库 JSON 文件路径。')
parser.add_argument('-n', '--number-question', type=int, required=True, help='试卷中的题目数量。')
args = parser.parse_args()
# 打开 JSON 文件,加载数据
with open(args.question_bank, 'r') as f:
data = json.load(f)
# 随机选择题目
selected_questions = random.sample(data, args.number_question)
# 创建试卷、答题纸和评分方案文档
test_paper_doc = Document()
answer_sheet_doc = Document()
marking_scheme_doc = Document()
# 设置字体
font = test_paper_doc.styles['Normal'].font
font.name = 'Arial'
font.size = Pt(12)
# 添加试卷标题
test_paper_title = test_paper_doc.add_paragraph('试卷', style='Title')
test_paper_title.alignment = WD_ALIGN_PARAGRAPH.CENTER
test_paper_doc.add_paragraph()
# 添加答题纸标题
answer_sheet_title = answer_sheet_doc.add_paragraph('答题纸', style='Title')
answer_sheet_title.alignment = WD_ALIGN_PARAGRAPH.CENTER
answer_sheet_doc.add_paragraph()
# 添加评分方案标题
marking_scheme_title = marking_scheme_doc.add_paragraph('评分方案', style='Title')
marking_scheme_title.alignment = WD_ALIGN_PARAGRAPH.CENTER
marking_scheme_doc.add_paragraph()
# 循环选定的题目,添加到文档中
for i, question in enumerate(selected_questions):
# 试卷
test_paper_doc.add_paragraph(f'{i+1}. {question["question"]}')
test_paper_doc.add_paragraph(f' A. {question["option_a"]}')
test_paper_doc.add_paragraph(f' B. {question["option_b"]}')
test_paper_doc.add_paragraph(f' C. {question["option_c"]}')
test_paper_doc.add_paragraph(f' D. {question["option_d"]}')
test_paper_doc.add_paragraph()
# 答题纸
answer_sheet_doc.add_paragraph(f'{i+1}. {question["question"]}')
answer_sheet_doc.add_paragraph(f' A. {question["option_a"]}')
answer_sheet_doc.add_paragraph(f' B. {question["option_b"]}')
answer_sheet_doc.add_paragraph(f' C. {question["option_c"]}')
answer_sheet_doc.add_paragraph(f' D. {question["option_d"]}')
answer_sheet_doc.add_paragraph(f'答案:{question["answer"]}')
answer_sheet_doc.add_paragraph(f'解析:{question["explanation"]}')
answer_sheet_doc.add_paragraph()
# 评分方案
marking_scheme_doc.add_paragraph(f'{i+1}. {question["question"]}')
marking_scheme_doc.add_paragraph(f'答案:{question["answer"]}')
marking_scheme_doc.add_paragraph()
# 保存文档
test_paper_doc.save('test_paper.docx')
answer_sheet_doc.save('answer_sheet.docx')
marking_scheme_doc.save('marking_scheme.docx')
```
在运行这个程序之前,需要使用 `pip` 安装 `python-docx` 包。
如果你没有 `pip`,可以按照以下步骤安装:
1. 检查是否已安装 `pip`:在安装 `pip` 之前,应该先检查系统中是否已经安装了它。打开终端或命令提示符,输入以下命令:
```shell
pip --version
```
如果已安装 pip会显示版本号。如果没有会看到一个错误消息。
2. 下载 `get-pip.py`:如果还没有安装 `pip`,需要下载 `get-pip.py`。在终端中运行:
```shell
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
```
3. 安装 `pip`:在终端或命令提示符中输入以下命令,即可安装 `pip`
```shell
python get-pip.py
```
```shell
python3 get-pip.py
```
另外,如果你有 Homebrew运行 `brew install python` 时会自带 `pip`。
现在,我们可以继续工作了。安装 `python-docx` 包:
```shell
pip install python-docx
```
与运行 `qbReorder.py` 类似,现在只需将代码复制到 `qbBuilder.py` 中,并运行:
```shell
python qbBuilder.py -q question_bank.json -n 30
```
它的用法如下:
```
usage: qbBuilder.py [-h] -q QUESTION_BANK -n NUMBER_QUESTION
生成试卷、答题纸和评分方案。
options:
-h, --help 显示此帮助信息并退出
-q QUESTION_BANK, --question-bank QUESTION_BANK
题库 JSON 文件路径。
-n NUMBER_QUESTION, --number-question NUMBER_QUESTION
试卷中的题目数量。
```
因此,`question_bank.json` 是题库文件名,`30` 是你想在试卷中包含的题目数量。可以将它们更改为任意你想要的值。
```shell
python qbBuilder.py -q [题库文件名] -n [你想包含的题目数量]
```
运行后,你可以在运行路径下找到三个 .docx 文件。
## 结语
你可以试试我的示例题库。
{{< link href="question_bank.json" content="question_bank.json" title="下载 question_bank.json" download="question_bank.json" card=true >}}
以及 Python 程序。
{{< link href="qbReorder.py" content="qbReorder.py" title="下载 qbReorder.py" download="qbReorder.py" card=true >}}
{{< link href="qbBuilder.py" content="qbBuilder.py" title="下载 qbBuilder,py" download="qbBuilder.py" card=true >}}
示例试卷:
{{< link href="test_paper.docx" content="test_paper.docx" title="下载 test_paper.docx" download="test_paper.docx" card=true >}}
{{< link href="answer_sheet.docx" content="answer_sheet.docx" title="下载 answer_sheet.docx" download="answer_sheet.docx" card=true >}}
{{< link href="marking_scheme.docx" content="marking_scheme.docx" title="下载 marking_scheme.docx" download="marking_scheme.docx" card=true >}}
我打算让 ChatGPT 构建更多类型的题目,例如结构化样题。还打算做一个全自动的题库制作器,无需人工干预就能创建上千道题目。而且不仅适用于物理,也适用于其他学科。
另一方面,我也在研究如何提高生成题目的质量,这就涉及到提示工程了。我希望能听到大家对 ChatGPT 生成题目的反馈,以便我能够不断改进。非常感谢!

View File

@@ -0,0 +1,74 @@
import argparse
import json
import random
from docx import Document
from docx.shared import Pt
from docx.enum.text import WD_ALIGN_PARAGRAPH
# Define command-line arguments
parser = argparse.ArgumentParser(description='Generate test papers, answer sheets, and marking scheme.')
parser.add_argument('-q', '--question-bank', type=str, required=True, help='Path to JSON file containing question bank.')
parser.add_argument('-n', '--number-question', type=int, required=True, help='Number of questions to include in the test paper.')
args = parser.parse_args()
# Open JSON file and load data
with open(args.question_bank, 'r') as f:
data = json.load(f)
# Select random questions
selected_questions = random.sample(data, args.number_question)
# Create Test Paper, Answer Sheet, and Marking Scheme
test_paper_doc = Document()
answer_sheet_doc = Document()
marking_scheme_doc = Document()
# Set font
font = test_paper_doc.styles['Normal'].font
font.name = 'Arial'
font.size = Pt(12)
# Add test paper title
test_paper_title = test_paper_doc.add_paragraph('Test Paper', style='Title')
test_paper_title.alignment = WD_ALIGN_PARAGRAPH.CENTER
test_paper_doc.add_paragraph()
# Add answer sheet title
answer_sheet_title = answer_sheet_doc.add_paragraph('Answer Sheet', style='Title')
answer_sheet_title.alignment = WD_ALIGN_PARAGRAPH.CENTER
answer_sheet_doc.add_paragraph()
# Add marking scheme title
marking_scheme_title = marking_scheme_doc.add_paragraph('Marking Scheme', style='Title')
marking_scheme_title.alignment = WD_ALIGN_PARAGRAPH.CENTER
marking_scheme_doc.add_paragraph()
# Loop through selected questions and add to documents
for i, question in enumerate(selected_questions):
# Test Paper
test_paper_doc.add_paragraph(f'{i+1}. {question["question"]}')
test_paper_doc.add_paragraph(f' A. {question["option_a"]}')
test_paper_doc.add_paragraph(f' B. {question["option_b"]}')
test_paper_doc.add_paragraph(f' C. {question["option_c"]}')
test_paper_doc.add_paragraph(f' D. {question["option_d"]}')
test_paper_doc.add_paragraph()
# Answer Sheet
answer_sheet_doc.add_paragraph(f'{i+1}. {question["question"]}')
answer_sheet_doc.add_paragraph(f' A. {question["option_a"]}')
answer_sheet_doc.add_paragraph(f' B. {question["option_b"]}')
answer_sheet_doc.add_paragraph(f' C. {question["option_c"]}')
answer_sheet_doc.add_paragraph(f' D. {question["option_d"]}')
answer_sheet_doc.add_paragraph(f'Answer: {question["answer"]}')
answer_sheet_doc.add_paragraph(f'Explanation: {question["explanation"]}')
answer_sheet_doc.add_paragraph()
# Marking Scheme
marking_scheme_doc.add_paragraph(f'{i+1}. {question["question"]}')
marking_scheme_doc.add_paragraph(f'Answer: {question["answer"]}')
marking_scheme_doc.add_paragraph()
# Save documents
test_paper_doc.save('test_paper.docx')
answer_sheet_doc.save('answer_sheet.docx')
marking_scheme_doc.save('marking_scheme.docx')

View File

@@ -0,0 +1,27 @@
import json
from collections import OrderedDict
# Open the JSON file and load the data as a list of dictionaries
with open('data.json', 'r') as f:
data = json.load(f)
# Create an ordered dictionary to store the objects by their order_number
data_dict = OrderedDict()
for obj in data:
if 'order_number' in obj:
order_number = obj['order_number']
if order_number in data_dict:
data_dict[order_number].append(obj)
else:
data_dict[order_number] = [obj]
# Create a new list of dictionaries with the objects ordered by their order_number
data_sorted = []
for order_number, objs in data_dict.items():
for i, obj in enumerate(objs):
obj['order_number'] = str(len(data_sorted) + i + 1)
data_sorted.extend(objs)
# Write the modified list of dictionaries back to the JSON file
with open('question_bank.json', 'w') as f:
json.dump(data_sorted, f, indent=2)

View File

@@ -0,0 +1,453 @@
[
{
"order_number": "1",
"question": "What is a galaxy?",
"type": "mcq",
"option_a": "A collection of planets",
"option_b": "A collection of stars",
"option_c": "A collection of asteroids",
"option_d": "A collection of comets",
"answer": "B",
"explanation": "A galaxy is a collection of a very large number of stars mutually attracting one another through the gravitational force and staying together."
},
{
"order_number": "2",
"question": "Which of the following is the correct description of a star?",
"type": "mcq",
"option_a": "A celestial object that emits light through nuclear fusion reactions in its core",
"option_b": "A planet-like object that orbits around a star",
"option_c": "A type of planet that emits its own light",
"option_d": "A cloud of interstellar gas and dust",
"answer": "A celestial object that emits light through nuclear fusion reactions in its core",
"explanation": "A star is a massive, luminous ball of gas, primarily hydrogen and helium, that emits energy through nuclear fusion reactions in its core."
},
{
"order_number": "3",
"question": "What is a main-sequence star?",
"type": "mcq",
"option_a": "A star that has run out of fuel",
"option_b": "A star that is undergoing nuclear fusion of hydrogen into helium",
"option_c": "A star that is about to explode",
"option_d": "A star that is very small and has low temperature",
"answer": "B",
"explanation": "A main-sequence star is a normal star that is undergoing nuclear fusion of hydrogen into helium."
},
{
"order_number": "4",
"question": "What is a white dwarf?",
"type": "mcq",
"option_a": "A type of galaxy",
"option_b": "A type of star that is undergoing nuclear fusion of hydrogen into helium",
"option_c": "The remnant of a red giant star",
"option_d": "The remnant of a white dwarf after it has cooled down, resulting in very low luminosity",
"answer": "The remnant of a white dwarf after it has cooled down, resulting in very low luminosity",
"explanation": "A white dwarf is the final stage of evolution of a star similar to our Sun. After it has expended all its nuclear fuel, it will slowly cool down to become a black dwarf."
},
{
"order_number": "5",
"question": "What is a brown dwarf?",
"type": "mcq",
"option_a": "A star that has run out of fuel",
"option_b": "A star that is undergoing nuclear fusion of hydrogen into helium",
"option_c": "Gas and dust that did not reach a high enough temperature to initiate fusion",
"option_d": "A very small star with low temperature",
"answer": "C",
"explanation": "A brown dwarf is gas and dust that did not reach a high enough temperature to initiate fusion. These objects continue to compact and cool down."
},
{
"order_number": "6",
"question": "What is a cluster of galaxies?",
"type": "mcq",
"option_a": "A group of planets that are close to each other",
"option_b": "A group of stars that are close to each other",
"option_c": "Galaxies in close proximity to one another and affecting each other gravitationally, behaving as one unit",
"option_d": "A group of asteroids that have collided with each other",
"answer": "Galaxies in close proximity to one another and affecting each other gravitationally, behaving as one unit",
"explanation": "A cluster of galaxies is a group of galaxies that are bound together by gravity and move together through space."
},
{
"order_number": "7",
"question": "What is a supernova?",
"type": "mcq",
"option_a": "The explosion of a white dwarf that has accreted mass from a companion star exceeding its stability limit",
"option_b": "The explosion of a red supergiant star",
"option_c": "The end result of the explosion of a red giant",
"option_d": "A star that has run out of fuel",
"answer": "B",
"explanation": "A supernova is the explosion of a red supergiant star. The amount of energy emitted in a supernova explosion can be staggering - comparable to the total energy radiated by our Sun in its entire lifetime!"
},
{
"order_number": "8",
"question": "What is dark matter?",
"type": "mcq",
"option_a": "Matter that is too cold to radiate",
"option_b": "A type of matter that emits light in the absence of a light source",
"option_c": "The matter that makes up stars and galaxies",
"option_d": "The mass of a black hole",
"answer": "Matter that is too cold to radiate",
"explanation": "Dark matter is a form of matter that can not be seen or detected through electromagnetic radiation, but whose existence is inferred from its gravitational effects on visible matter."
},
{
"order_number": "9",
"question": "What is a white dwarf?",
"type": "mcq",
"option_a": "The end result of the explosion of a red giant",
"option_b": "A star that is undergoing nuclear fusion of hydrogen into helium",
"option_c": "The end result of the explosion of a white dwarf",
"option_d": "A very small star with low temperature",
"answer": "C",
"explanation": "A white dwarf is the end result of the explosion of a red giant. A small, dense star (about the size of the Earth), in which no nuclear reactions take place. It is very hot but its small size gives it a very low luminosity."
},
{
"order_number": "10",
"question": "What is the main source of energy in a star?",
"type": "mcq",
"option_a": "Nuclear fusion of hydrogen into helium",
"option_b": "Nuclear fission of uranium",
"option_c": "Chemical reactions",
"option_d": "Solar wind",
"answer": "Nuclear fusion of hydrogen into helium",
"explanation": "Nuclear fusion provides the energy needed to keep the star hot, oppose gravitational contraction, and provide energy that is radiated into space."
},
{
"order_number": "11",
"question": "What is a red giant?",
"type": "mcq",
"option_a": "A star that is undergoing nuclear fusion of hydrogen into helium",
"option_b": "A star that has run out of fuel",
"option_c": "A very small star with low temperature",
"option_d": "A main-sequence star",
"answer": "A",
"explanation": "A red giant is a main-sequence star that evolves into a red giant - a very large, reddish star. There are nuclear reactions involving the fusion of helium into heavier elements."
},
{
"order_number": "12",
"question": "What is luminosity?",
"type": "mcq",
"option_a": "The unit of apparent brightness",
"option_b": "The distance to a star",
"option_c": "The size of a star",
"option_d": "The power radiated by a star",
"answer": "The power radiated by a star",
"explanation": "The power radiated by a star is known in astrophysics as the luminosity. It is measured in watts."
},
{
"order_number": "13",
"question": "What is a neutron star?",
"type": "mcq",
"option_a": "The end result of the explosion of a red giant",
"option_b": "A star consisting almost entirely of neutrons",
"option_c": "A very small star with low temperature",
"option_d": "A star that is undergoing nuclear fusion of hydrogen into helium",
"answer": "B",
"explanation": "A neutron star is the end result of the explosion of a red supergiant; a very small star (a few tens of kilometres in diameter) and very dense. This is a star consisting almost entirely of neutrons. The neutrons form a superfluid around a core of immense pressure and density. A neutron star is an astonishing macroscopic example of microscopic quantum physics."
},
{
"order_number": "14",
"question": "What is a comet?",
"type": "mcq",
"option_a": "A small planet-like object that orbits around a star",
"option_b": "A cloud of interstellar gas and dust",
"option_c": "A massive ball of gas and dust held together by its own gravity",
"option_d": "A small body mainly composed of ice and dust that orbits around a star",
"answer": "A small body mainly composed of ice and dust that orbits around a star",
"explanation": "Comets are small bodies mainly composed of ice and dust that orbit around the Sun in an elliptical orbit."
},
{
"order_number": "15",
"question": "What is a black hole?",
"type": "mcq",
"option_a": "A singularity in space time; the end result of the evolution of a very massive star",
"option_b": "A very small star with low temperature",
"option_c": "A star that is undergoing nuclear fusion of hydrogen into helium",
"option_d": "A star that has run out of fuel",
"answer": "A",
"explanation": "A black hole is a singularity in space time; the end result of the evolution of a very massive star."
},
{
"order_number": "16",
"question": "What is a neutron star?",
"type": "mcq",
"option_a": "The end result of the explosion of a red supergiant star",
"option_b": "A type of cluster of galaxies",
"option_c": "A star that is undergoing nuclear fusion of hydrogen into helium",
"option_d": "A very small star (a few tens of kilometers in diameter) and very dense, consisting almost entirely of neutrons",
"answer": "A very small star (a few tens of kilometers in diameter) and very dense, consisting almost entirely of neutrons",
"explanation": "A neutron star is the end result of the explosion of a red supergiant star. It is an incredibly dense ball of neutrons that can be only a few kilometers in diameter."
},
{
"order_number": "17",
"question": "What is a planetary nebula?",
"type": "mcq",
"option_a": "Clouds of dust in the space between stars",
"option_b": "The ejected envelope of a red giant star",
"option_c": "A group of stars that are physically near each other in space",
"option_d": "Galaxies close to one another and affecting one another gravitationally, behaving as one unit",
"answer": "B",
"explanation": "A planetary nebula is the ejected envelope of a red giant star."
},
{
"order_number": "18",
"question": "What is a brown dwarf?",
"type": "mcq",
"option_a": "A very small star with low temperature, reddish in color",
"option_b": "Gas and dust that did not reach a high enough temperature to initiate fusion",
"option_c": "The ejected envelope of a red giant star",
"option_d": "A star of variable luminosity",
"answer": "Gas and dust that did not reach a high enough temperature to initiate fusion",
"explanation": "Brown dwarfs are objects that are not massive enough to sustain nuclear fusion reactions in their cores. As a result, they slowly cool down over time."
},
{
"order_number": "19",
"question": "What is dark matter?",
"type": "mcq",
"option_a": "Matter in galaxies and clusters of galaxies that is too cold to radiate",
"option_b": "Gases and dust filling the space between stars",
"option_c": "A star that is undergoing nuclear fusion of hydrogen into helium",
"option_d": "A singularity in space time",
"answer": "A",
"explanation": "Dark matter is generic name for matter in galaxies and clusters of galaxies that is too cold to radiate. Its existence is inferred from techniques other than direct visual observation."
},
{
"order_number": "20",
"question": "What is a cepheid variable?",
"type": "mcq",
"option_a": "A type of nebula",
"option_b": "A type of comet",
"option_c": "A star with variable luminosity that varies in brightness in a well-defined pattern",
"option_d": "A type of cluster of galaxies",
"answer": "A star with variable luminosity that varies in brightness in a well-defined pattern",
"explanation": "Cepheid variables are stars that pulsate in a regular pattern, with a well-defined period. This period is related to the absolute luminosity of the star, which can be used to estimate the distance to the star via parallax."
},
{
"order_number": "21",
"question": "What is the interstellar medium?",
"type": "mcq",
"option_a": "The matter that makes up stars and galaxies",
"option_b": "A cloud of interstellar gas and dust",
"option_c": "The dark matter holding galaxies and clusters of galaxies together",
"option_d": "A group of planets that are close to each other",
"answer": "A cloud of interstellar gas and dust",
"explanation": "The interstellar medium is the gas and dust that fills the space between stars in a galaxy. It is mainly composed of hydrogen and helium, along with small amounts of heavier elements and dust grains."
},
{
"order_number": "22",
"question": "What is a planetary nebula?",
"type": "mcq",
"option_a": "The end result of the explosion of a red giant star",
"option_b": "A cloud of interstellar gas and dust",
"option_c": "The ejected envelope of a red giant star",
"option_d": "A small body mainly composed of ice and dust that orbits around a star",
"answer": "The ejected envelope of a red giant star",
"explanation": "When a low-to-intermediate mass star expands into a red giant, it loses its outer layers into space, producing a planetary nebula. The core of the star that is left behind becomes a white dwarf."
},
{
"order_number": "23",
"question": "What is a main-sequence star?",
"type": "mcq",
"option_a": "The ejected envelope of a red giant star",
"option_b": "A type of star that is undergoing nuclear fusion of hydrogen into helium",
"option_c": "A very small star (a few tens of kilometers in diameter) and very dense, consisting almost entirely of neutrons",
"option_d": "A small body mainly composed of ice and dust that orbits around a star",
"answer": "A type of star that is undergoing nuclear fusion of hydrogen into helium",
"explanation": "A main-sequence star is a normal star that is undergoing nuclear fusion of hydrogen into helium in its core. This is the phase in which our Sun is currently in."
},
{
"order_number": "24",
"question": "What is a red giant?",
"type": "mcq",
"option_a": "Gas and dust that did not reach a high enough temperature to initiate fusion",
"option_b": "The end result of the explosion of a white dwarf",
"option_c": "A small body mainly composed of ice and dust that orbits around a star",
"option_d": "A normal star that has evolved into a very large, reddish star",
"answer": "A normal star that has evolved into a very large, reddish star",
"explanation": "A red giant is a normal star that has evolved past the main-sequence phase and has become a large, reddish star due to nuclear reactions that cause it to expand."
},
{
"order_number": "25",
"question": "What is a black hole?",
"type": "mcq",
"option_a": "A type of planet that emits its own light",
"option_b": "A singularity in space-time; the end result of the evolution of a very massive star",
"option_c": "The mass of a neutron star",
"option_d": "A massive ball of gas and dust held together by its own gravity",
"answer": "A singularity in space-time; the end result of the evolution of a very massive star",
"explanation": "A black hole is a region of space-time where gravity is so strong that nothing, not even light, can escape from it. It is the end result of the evolution of a very massive star."
},
{
"order_number": "26",
"question": "Which statement best describes a black dwarf?",
"type": "mcq",
"option_a": "The ejected envelope of a red giant star",
"option_b": "A small body mainly composed of ice and dust that orbits around a star",
"option_c": "A type of star that is undergoing nuclear fusion of hydrogen into helium",
"option_d": "The remnant of a white dwarf after it has cooled down, resulting in very low luminosity",
"answer": "The remnant of a white dwarf after it has cooled down, resulting in very low luminosity",
"explanation": "A black dwarf is the remnant of a white dwarf after it has cooled down to the point where it no longer emits any visible light."
},
{
"order_number": "27",
"question": "What is an astronomical unit (AU)?",
"type": "mcq",
"option_a": "The average distance between the Earth and the Sun.",
"option_b": "The radius of the Earth.",
"option_c": "The distance traveled by light in one year.",
"option_d": "The mass of the Earth.",
"answer": "The average distance between the Earth and the Sun.",
"explanation": "An astronomical unit or AU is a unit of measurement equal to the average distance between Earth and the Sun. It is commonly used to measure distances within our solar system."
},
{
"order_number": "28",
"question": "Which of the following is not a type of galaxy?",
"type": "mcq",
"option_a": "Elliptical",
"option_b": "Spiral",
"option_c": "Irregular",
"option_d": "Spherical",
"answer": "Spherical",
"explanation": "The three main types of galaxies are elliptical, spiral, and irregular. There is no galaxy type called spherical."
},
{
"order_number": "29",
"question": "What is a cepheid variable?",
"type": "mcq",
"option_a": "A type of black hole",
"option_b": "A star of variable luminosity",
"option_c": "A type of planetary nebula",
"option_d": "A cluster of galaxies",
"answer": "A star of variable luminosity",
"explanation": "A cepheid variable is a star that pulsates in a regular pattern, causing its luminosity to vary. The period of this pulsation is related to the star\u2019s absolute luminosity, allowing it to be used as a standard candle to measure distances in space."
},
{
"order_number": "30",
"question": "Which of the following objects is composed mainly of ice and dust?",
"type": "mcq",
"option_a": "A black hole",
"option_b": "A brown dwarf",
"option_c": "A comet",
"option_d": "A neutron star",
"answer": "A comet",
"explanation": "Comets are small, icy objects that orbit the Sun. When a comet gets close enough to the Sun, its ice melts and forms a brightly glowing coma around it."
},
{
"order_number": "31",
"question": "What is the difference between apparent brightness and luminosity?",
"type": "mcq",
"option_a": "Apparent brightness is a measure of how much light is emitted by a star, while luminosity is a measure of how bright the star appears from Earth.",
"option_b": "Apparent brightness is a measure of how bright a star appears from Earth, while luminosity is a measure of how much light is emitted by the star.",
"option_c": "Apparent brightness is a measure of the distance between Earth and a star, while luminosity is a measure of the star\u2019s mass.",
"option_d": "Apparent brightness is a measure of the star\u2019s mass, while luminosity is a measure of the distance between Earth and the star.",
"answer": "Apparent brightness is a measure of how bright a star appears from Earth, while luminosity is a measure of how much light is emitted by the star.",
"explanation": "Apparent brightness is a measure of how much light from a star reaches Earth, while luminosity is a measure of the total amount of energy emitted by a star in all directions. Luminosity is an intrinsic property of a star, while apparent brightness depends on the star\u2019s luminosity and its distance from Earth."
},
{
"order_number": "32",
"question": "What is a main-sequence star?",
"type": "mcq",
"option_a": "A star that is undergoing nuclear fusion of hydrogen into helium.",
"option_b": "A star that has exhausted its fuel and is in the process of burning helium.",
"option_c": "A star that has evolved off the main sequence and is fusing heavier elements.",
"option_d": "A star that has exploded as a supernova.",
"answer": "A star that is undergoing nuclear fusion of hydrogen into helium.",
"explanation": "A main-sequence star is a normal star that is fusing hydrogen into helium in its core. This is the most common type of star, and includes the Sun."
},
{
"order_number": "33",
"question": "What is a brown dwarf?",
"type": "mcq",
"option_a": "A star that has exploded as a supernova.",
"option_b": "A star that is undergoing nuclear fusion of hydrogen into helium.",
"option_c": "Gas and dust that did not reach a high enough temperature to initiate fusion.",
"option_d": "The ejected envelope of a red giant star.",
"answer": "Gas and dust that did not reach a high enough temperature to initiate fusion.",
"explanation": "A brown dwarf is an object that is too cool and small to undergo sustained nuclear fusion of hydrogen in its core, but is too hot and massive to be called a planet. They are often described as \u2018failed stars\u2019."
},
{
"order_number": "34",
"question": "What is a supernova?",
"type": "mcq",
"option_a": "The explosion of a red giant star.",
"option_b": "The end result of the evolution of a very massive star.",
"option_c": "A singularity in space-time.",
"option_d": "The ejected envelope of a red giant star.",
"answer": "The explosion of a star.",
"explanation": "A supernova is a catastrophic explosion that occurs at the end of a star\u2019s life. The explosion can outshine an entire galaxy for a brief period of time."
},
{
"order_number": "35",
"question": "What is dark matter?",
"type": "mcq",
"option_a": "Matter in galaxies that is too cold to radiate and is inferred from techniques other than direct visual observation.",
"option_b": "The ejected envelope of a red giant star.",
"option_c": "Space-time that is so warped that nothing can escape it, not even light.",
"option_d": "Matter that is made up of subatomic particles that do not interact with the electromagnetic force.",
"answer": "Matter in galaxies that is too cold to radiate and is inferred from techniques other than direct visual observation.",
"explanation": "Dark matter is matter that is inferred to exist from its gravitational effects but does not emit or absorb light, and therefore cannot be detected directly by telescopes."
},
{
"order_number": "36",
"question": "What is a black hole?",
"type": "mcq",
"option_a": "A type of galaxy in which most of the stars are very old and have mostly red colours.",
"option_b": "A singularity in space-time that is the end result of the evolution of a very massive star.",
"option_c": "A star that has exhausted its fuel and is in the process of burning helium.",
"option_d": "A star that has exploded as a supernova.",
"answer": "A singularity in space-time that is the end result of the evolution of a very massive star.",
"explanation": "A black hole is a region of space-time where gravity is so strong that nothing, not even light, can escape its pull. They are formed from the collapse of very massive stars."
},
{
"order_number": "37",
"question": "Which of the following is not a type of nebula?",
"type": "mcq",
"option_a": "Planetary Nebula",
"option_b": "Stellar Nebula",
"option_c": "Reflection Nebula",
"option_d": "Irregular Nebula",
"answer": "Stellar Nebula",
"explanation": "Stellar nebula is not a type of nebula. The three main types of nebula are emission nebula, reflection nebula, and planetary nebula."
},
{
"order_number": "38",
"question": "What is nuclear fusion?",
"type": "mcq",
"option_a": "The process by which a star burns helium into heavier elements in its core.",
"option_b": "The process by which a star burns hydrogen into helium in its core.",
"option_c": "The process by which a planet forms from a cloud of gas and dust.",
"option_d": "The process by which a star expands into a red giant.",
"answer": "The process by which a star burns hydrogen into helium in its core.",
"explanation": "Nuclear fusion is the process by which a star generates energy by fusing hydrogen atoms into helium atoms in its core. This process releases a tremendous amount of energy in the form of light and heat."
},
{
"order_number": "39",
"question": "What is a red giant?",
"type": "mcq",
"option_a": "A star that has exploded as a supernova.",
"option_b": "A star that is undergoing nuclear fusion of hydrogen into helium.",
"option_c": "A star that has exhausted its fuel and is in the process of burning helium.",
"option_d": "A star that has evolved off the main sequence and is fusing heavier elements.",
"answer": "A star that has evolved off the main sequence and is fusing heavier elements.",
"explanation": "A red giant is a star that has exhausted the supply of hydrogen in its core and is now fusing heavier elements. This causes the star to expand and become much larger and redder than before."
},
{
"order_number": "40",
"question": "What is a white dwarf?",
"type": "mcq",
"option_a": "The end result of the explosion of a red giant.",
"option_b": "A small, dense star that is fusing helium into heavier elements in its core.",
"option_c": "A small, dense star that is no longer generating energy through nuclear fusion.",
"option_d": "A star that is undergoing nuclear fusion of hydrogen into helium.",
"answer": "A small, dense star that is no longer generating energy through nuclear fusion.",
"explanation": "A white dwarf is the end result of the evolution of a low- to medium-mass star. It is a small, dense star that is no longer generating energy through nuclear fusion. White dwarfs are very hot and faint, and will eventually cool down over billions of years."
},
{
"order_number": "41",
"question": "What is a black dwarf?",
"type": "mcq",
"option_a": "The end result of the explosion of a red giant.",
"option_b": "A type of black hole with very low mass.",
"option_c": "Gas and dust that did not reach a high enough temperature to initiate fusion.",
"option_d": "The remnant of a white dwarf after it has cooled down.",
"answer": "The remnant of a white dwarf after it has cooled down.",
"explanation": "A black dwarf is a hypothetical object that would be the end result of the evolution of a white dwarf. It is essentially a cold, dark object made purely of carbon and oxygen atoms. However, the universe is not old enough for any white dwarfs to have cooled down enough to become black dwarfs yet."
}
]

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

View File

@@ -0,0 +1,199 @@
---
slug: "excalidraw-full-stack-docker"
title: "Excalidraw 全栈自部署教程"
subtitle: ""
date: 2023-01-13T15:54:36+08:00
lastmod: 2024-03-11T12:39:36-05:00
draft: false
author:
name: James
link: https://www.jamesflare.com
email:
avatar: /site-logo.avif
description: 本文为你提供了一份使用 Docker Compose 部署完整 Excalidraw 技术栈的详细指南,包括前端界面、数据存储后端以及协作组件,让你能够快速搭建一个功能完备、支持分享和多人协作的 Excalidraw 私有部署。
license: ""
comment: true
weight: 0
tags:
- Excalidraw
- 开源软件
- Docker
categories:
- 教程
- 资源分享
hiddenFromHomePage: false
hiddenFromSearch: false
summary: 通过本文,你将学会使用 Docker Compose 一键部署拥有前端界面、数据存储和多人协作等全部功能的 Excalidraw 技术栈,快速搭建一个可以私有使用、分享协作的 Excalidraw 部署。
resources:
- name: featured-image
src: featured-image.jpg
- name: featured-image-preview
src: featured-image-preview.jpg
toc:
enable: true
math:
enable: false
lightgallery: true
seo:
images: []
repost:
enable: true
url: ""
# 查看 Front Matter 的详细配置说明https://fixit.lruihao.cn/theme-documentation-content/#front-matter
---
## Intro
这可能是中文互联网上唯一一篇讲如何全栈部署 Excalidraw 的,绝大多数只是部署了一个残血的前端。
本人试图在本地私有化部署 Excalidraw操作是很简单根据官方的 README一会就完成了是吧。
### Issue
但是有没有发现,分享链接和在线协作有问题,用不了?甚至 Libraries 还有点问题?
这是因为,几乎全网的搭建教程都只是搭建了 excalidraw-app 这个前端,它的存储需要 excalidraw-json协作需要 excalidraw-room。
这些代码官方都开源了,不过前端的进度实在是太快了,于是乎这些就都用不了了。
比如官方开放的 excalidraw-json 是 S3 的存储,现在不出意外是 firebase官方也没出个剥离的版本那我们怎么办呢
### Solution
答,**降级****构建全栈**。
excalidraw-app 我们用官方的,不过版本差不多是 9 个月前的讲道理功能也没少多少bug 也没什么问题,这一代前端可以很好兼容。
excalidraw-json 是用不得了,国外也有一些方案用 minio 来跑 S3 对接它,但是我测试了,问题有些大,这个后端应该是用不得了,所幸的是,我找到了一个第三方,用自己代码实现的全功能后端,支持 v2 的 apiexcalidraw-storage-backend。
excalidraw-room 我们用官方的,最新一版,差不多是 9 个月前的,和前端一致,可以正常使用。
redis这个是 excalidraw-storage-backend 所需要的,用于临时存储分享画板的数据,所以它不能保证数据可靠性。
那我们开始吧,本方案使用 docker-compose。
- excalidraw-app
- excalidraw-room
- excalidraw-storage-backend
- redis
## Docker Compose
Docker Compose 配置
```yaml
version: "3.8"
services:
excalidraw:
image: kiliandeca/excalidraw
healthcheck:
disable: true
ports:
- "80:80" # 默认端口80可以修改
environment:
BACKEND_V2_GET_URL: http://localhost:8080/api/v2/scenes/
BACKEND_V2_POST_URL: http://localhost:8080/api/v2/scenes/
LIBRARY_URL: https://libraries.excalidraw.com
LIBRARY_BACKEND: https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries
SOCKET_SERVER_URL: http://localhost:5000/
STORAGE_BACKEND: "http"
HTTP_STORAGE_BACKEND_URL: "http://localhost:8080/api/v2"
excalidraw-storage-backend:
image: kiliandeca/excalidraw-storage-backend
ports:
- "8080:8080"
environment:
STORAGE_URI: redis://redis:6379
excalidraw-room:
image: excalidraw/excalidraw-room
ports:
- "5000:80"
redis:
image: redis
ports:
- "6379:6379"
```
本身不支持 https如有需要可以通过反向代理实现不过记得同时修改 environment 中的变量
此配置文件经本地测试通过,可完美运行。
{{< image src="excalidrawLocalDemo.webp" >}}
---
如果你 6379 端口有冲突,那可以选择构建一个 network
```bash
docker network create excalidraw-net
```
然后像这样对其进行一些修改,就完成了
```yaml
version: "3.8"
services:
excalidraw:
image: kiliandeca/excalidraw
healthcheck:
disable: true
ports:
- "80:80"
environment:
BACKEND_V2_GET_URL: http://localhost:8080/api/v2/scenes/
BACKEND_V2_POST_URL: http://localhost:8080/api/v2/scenes/
LIBRARY_URL: https://libraries.excalidraw.com
LIBRARY_BACKEND: https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries
SOCKET_SERVER_URL: http://localhost:5000/
STORAGE_BACKEND: "http"
HTTP_STORAGE_BACKEND_URL: "http://localhost:8080/api/v2"
excalidraw-storage-backend:
image: kiliandeca/excalidraw-storage-backend
ports:
- "8080:8080"
environment:
STORAGE_URI: redis://redis:6379
excalidraw-room:
image: excalidraw/excalidraw-room
ports:
- "5000:80"
redis:
image: redis
expose:
- "6379"
networks:
default:
external:
name: excalidraw-net
```
## Run
找一个,或者新建一个目录,创建 docker-compose 文件。
```bash
nano docker-compose.yml
```
填入 docker-compose 配置,记得按你的实际情况修改。
随后我们要配置一下反向代理,记得配置 WebSocket 支持,我这里就跳过了。
思路是这样的,参考下面配置即可:
{{< image src="stackDrawing.webp" caption="Stack" width="600px" >}}

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 KiB

View File

@@ -0,0 +1,188 @@
---
title: 将 Umami Docker 从一台服务器迁移到另一台服务器
subtitle:
date: 2024-03-11T18:03:39-04:00
slug: umami-docker-migration
draft: false
author:
name: James
link: https://www.jamesflare.com
email:
avatar: /site-logo.avif
description: 本文将介绍如何通过导出和导入 PostgreSQL 数据库,将 Docker 上运行的 Umami 服务器从一台机器迁移到另一台机器,确保在保留所有关键数据的同时实现平稳过渡。
license:
comment: true
weight: 0
tags:
- PostgreSQL
- 开源
- Docker
- Umami
categories:
- 教程
hiddenFromHomePage: false
hiddenFromSearch: false
hiddenFromRss: false
hiddenFromRelated: false
summary: 本文将介绍如何通过导出和导入 PostgreSQL 数据库,将 Docker 上运行的 Umami 服务器从一台机器迁移到另一台机器,确保在保留所有关键数据的同时实现平稳过渡。
resources:
- name: featured-image
src: featured-image.jpg
- name: featured-image-preview
src: featured-image-preview.jpg
toc: true
math: false
lightgallery: false
password:
message:
repost:
enable: true
url:
# 查看前言详细信息https://fixit.lruihao.cn/documentation/content-management/introduction/#front-matter
---
<!--more-->
## 简介
最近我从 netcup GmbH 购买了一台新的 ARM 服务器,需要把 Umami 服务器从旧服务器迁移到新服务器上。但我是用 Docker 安装的 Umami。
```yaml
version: '3'
services:
umami:
image: ghcr.io/umami-software/umami:postgresql-latest
ports:
- "3000:3000"
environment:
DATABASE_URL: postgresql://umami:umami@db:5432/umami
DATABASE_TYPE: postgresql
APP_SECRET: replace-me-with-a-random-string
depends_on:
db:
condition: service_healthy
restart: always
db:
image: postgres:15-alpine
environment:
POSTGRES_DB: umami
POSTGRES_USER: umami
POSTGRES_PASSWORD: umami
volumes:
- umami-db-data:/var/lib/postgresql/data
restart: always
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
interval: 5s
timeout: 5s
retries: 5
volumes:
umami-db-data:
```
迁移中最困难和重要的部分就是导出 Umami 的数据。我们有几种方法可以实现:
- 导出 Docker 卷(非常复杂)
- 导出数据库(我的选择)
- 复制整个路径(不推荐)
## 比较方法
首先,我们要知道 Umami 的数据是存储在卷Volume中的。因为 `docker-compose.yml` 指定了:
```yaml
services:
db:
volumes:
- umami-db-data:/var/lib/postgresql/data
volumes:
umami-db-data:
```
如果我把路径挂载到容器里而不是卷,那就可以直接把路径复制到新机器上。比如:
```yaml
services:
db:
volumes:
- /root/umami/data:/var/lib/postgresql/data
```
可惜我用了卷,导致事情变得复杂。如何正确迁移 Docker 卷在网上有很多讨论,比如 [将 Docker 卷移动到另一台主机](https://4sysops.com/archives/move-a-docker-volume-to-another-host/)。但对我来说太复杂了。你可能会问Docker 卷不是存储在固定路径如 `/var/lib/docker/volumes/*` 吗?为什么不直接把文件夹复制到另一台机器并正常启动呢?这确实可行,我以前也这么干过。但它可能会导致一些潜在问题,尤其是对于不同的 Docker 容器版本。
最后,我决定只导出数据库并导入到新实例中。让我们一步一步来。
## 迁移数据库
首先,让我们进入旧容器的 Shell。
```bash
docker exec -it umami-db-1 /bin/sh
```
将数据库导出为 `.sql` 文件。
```bash
cd /
pg_dump --username=umami umami > umami.sql
```
现在数据库备份在 `umami.sql` 文件中,但它在容器内部。按 `Ctrl + D` 退出容器 Shell然后把文件复制到宿主机。
```bash
docker cp umami-db-1:/umami.sql /root
```
接着,你需要把这个备份文件传输到新主机上。在新主机上 `docker compose up -d` 后,`umami-db-1` 容器就会被创建。然后你可以通过以下命令把数据库备份文件复制到容器中:
```bash
docker cp /root/umami.sql umami-db-1:/
```
进入新的 `umami-db-1` 容器:
```bash
docker exec -it umami-db-1 /bin/sh
```
要把备份导入 Postgres我们需要以 `umami` 用户登录 `psql`
```bash
psql --username=umami -d postgres
```
`psql` Shell 中,我们先删除原有数据库,再创建一个空白数据库以准备导入。
```bash
DROP DATABASE umami;
CREATE DATABASE umami;
```
然后退出 `psql` Shell运行以下命令导入备份文件
```bash
cd /
psql --username=umami -f umami.sql umami
```
最后,重启 Umami 实例:
```bash
cd /path/to/umami/docker-compose.yaml/
docker compose down
docker compose up -d
```
## 检查
现在可以检查数据库是否迁移成功了。打开新 Umami 的 URL尝试用原来的账号登录。如果能登录那数据库很可能迁移成功了账号信息是存在数据库里的
为了进一步确认,你可以进入仪表盘,看看所有数据是否正常显示。
如果不正常,说明数据库没有成功迁移。你可以检查导出的备份文件(里面是否包含正确的数据?),以及导入的方式(看看备份文件是否成功导入到新的 Postgres
## 参考
- [如何将 Umami 从一台服务器迁移到另一台服务器](https://www.programonaut.com/how-to-migrate-umami-from-one-server-to-another/)
- [如何在 Linux 中备份和恢复 PostgreSQL 数据库](https://www.tecmint.com/backup-and-restore-postgresql-database/)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 197 KiB

View File

@@ -0,0 +1,126 @@
---
title: "For 杨文雅 - 祝你学业顺利"
subtitle:
date: 2023-01-13T19:45:45+08:00
lastmod: 2024-03-10T1:36:05-05:00
slug: cards-wen-welcome-university
draft: false
author:
name: James
link: https://www.jamesflare.com
email:
avatar: /site-logo.avif
description: "给杨文雅的贺卡,恭喜你上大学了,很高兴认识你!本页是一份现代化的贺卡,不出意外你将通过二维码扫描获得。不同于普通的文本,这是富文本,当然我个人还是喜欢戏称其为肥文本。"
keywords:
license: ""
comment: true
weight: 0
tags:
- 贺卡
- 数学
- 知识论
categories:
- 贺卡
hiddenFromHomePage: false
hiddenFromSearch: false
summary: "给杨文雅的贺卡,恭喜你上大学了,很高兴认识你!本页是一份现代化的贺卡,不出意外你将通过二维码扫描获得。不同于普通的文本,这是富文本,当然我个人还是喜欢戏称其为肥文本。"
resources:
- name: featured-image
src: featured-image.jpg
- name: featured-image-preview
src: featured-image-preview.jpg
toc:
enable: true
math:
enable: false
lightgallery: true
seo:
images: []
repost:
enable: true
url: ""
# See details front matter: https://fixit.lruihao.cn/theme-documentation-content/#front-matter
---
> **Change Log**
>
> - 2024/3/10
> - 优化正文语法
> - 优化并备份 bilibili 视频
> - 修正二维码 URL
> - 将资源文件嵌入 Adobe Illustrator 项目
> - 优化贺卡布局
## Card
{{< image src="for杨文雅.svg" caption="贺卡" width="600px" >}}
## Introduction
本页是一份现代化的贺卡,不出意外你将通过二维码扫描获得。
不同于普通的文本也就是富文本Rich Text我个人还是喜欢戏称其为肥文本。
## Before the Story
我想我认识你很久,很久了,属于空前绝后了,以至于我都忘了什么时候认识的了,至少在我可以肯定在四年级以前。我确实没想到转眼到了要上大学的时候了,高情商的说法是时光飞逝,低情商一些就是不知道时间怎么过的,一觉醒来发现时代变了。
本人的学术生涯不幸被两个城市和数个学校切得稀碎,现在流行毕业了后,发个自己从小到大,学校的定位。一个经典的案例也就三四个位置,我来整一个怕是要来个七个。有个老师当时说,她真佩服那些转学的人。我当时觉得,这算什么,就这?后来我理解了,她指的是当你转学离开的时候,那就意味着你和你的朋友们基本上说再见了,而从零重新开始一段新的关系需要勇气,特别是我这样不在同一个城市生活的人。
每当我离开,身后总有一群人表达不舍,有老师也有学生。我当时并不在意,而且本人对那些学校也不是特别满意的样子(不然为什么跑路),现在回想起来确实有一丝难过。不过讲道理,我从逻辑上是肯定没后悔的,事实也应该如此。至于为什么变 emo 的原因,那是人脑的特性。我们回忆过往时总会选择性地加强那些美好的部分,而选择性淡化不快乐的内容。
就比如我后来去参加了我当时那个中学,初三的毕业典礼,毕竟曾经一个班的,转学了回去捧个场也是应该的。讲道理,去之前我感觉很快乐,有一丝兴奋。但是真进了教室感觉和自己想象中有些不同,那天 50 几人搞得满地都是残骸,地上有油,有可乐,有水,还有礼花的彩色碎片,全部混合粘在地上。结果他们一波全跑了,我和几个倒霉蛋爬在地上清理了 3 个多小时,搞到下午五点,简直无情。
扩展内容,[高铁是怎样破坏回家“形式感”的?【懂点儿啥】.mp4](https://minio-lv-a.jamesflare.com/public/bilibili/%E9%AB%98%E9%93%81%E6%98%AF%E6%80%8E%E6%A0%B7%E7%A0%B4%E5%9D%8F%E5%9B%9E%E5%AE%B6%E2%80%9C%E5%BD%A2%E5%BC%8F%E6%84%9F%E2%80%9D%E7%9A%84%EF%BC%9F%E3%80%90%E6%87%82%E7%82%B9%E5%84%BF%E5%95%A5%E3%80%91.mp4)
{{< bilibili id=BV1mZ4y1D7G2 >}}
在写这 posts 的时候有有些 emo 了,想到和我有 3 年以上联系的同学屈指可数(暂时数出来一个),和杨小姐你以前玩的时候多快乐,之后又不知何时相见了,见面时又会干些什么。
### 开始数学之旅
你选了数学作为你的专业,那不出意外你很快会开始探索当代生活的底层逻辑。典中典的就是我开头的二维码,六十年前一篇不到五页的论文,如今成为当代现代生活底层无数的基石之一。
有兴趣可以看看Paper 的名字叫 POLYNOMIAL CODES OVER CERTAIN FINITE FIELDS基于特定有限域的多项式编码。文件如下
{{< link href="RS-1960.pdf" content="RS-1960.pdf" title="Download RS-1960.pdf" download="RS-1960.pdf" card=true >}}
***
下面算是一些扩展内容(正文)了,你想过,什么是数学吗。我是说,数学到底是什么?
根据我仅学的一点 ToKTheory of Knowledge知识来讲它很特别。和其它的学科比如物理化学等都不一样这里的不一样不是说内容不一样而是知识论方面不一样可以从**完备****自洽****可判定性**方面思考),他是一门精确语言。
1. 完备性:
- 数学是一个完备的体系,任何数学命题都可以在公理系统内被证明或证伪。
- 物理、化学等学科依赖于实验和观察,其理论体系可能存在未知的因素和局限性。
2. 自洽性:
- 数学是建立在公理基础上的,整个体系是自洽的,不存在内部矛盾。
- 物理、化学等学科的理论可能会随着新的实验结果而修正或推翻,其自洽性相对较弱。
3. 可判定性:
- 在数学中,一个命题要么为真,要么为假,不存在模糊或不确定的情况(排除不可判定命题)。
- 物理、化学等学科的理论和结论可能具有一定的不确定性,需要通过概率和统计方法来描述。
我推荐几个好视频,我看了也不是很明白,不过都是很有意思的内容(和上面的常识唱反调的)。首先是这个 [数学并不完备,数学有一个致命缺陷.mp4](https://minio-lv-a.jamesflare.com/public/bilibili/%E6%95%B0%E5%AD%A6%E5%B9%B6%E4%B8%8D%E5%AE%8C%E5%A4%87%EF%BC%8C%E6%95%B0%E5%AD%A6%E6%9C%89%E4%B8%80%E4%B8%AA%E8%87%B4%E5%91%BD%E7%BC%BA%E9%99%B7.mp4)
{{< bilibili id=BV1464y1k7Ya p=1 >}}
然后是这个 [数学决斗,虚数的来源.mp4](https://minio-lv-a.jamesflare.com/public/bilibili/%E6%95%B0%E5%AD%A6%E5%86%B3%E6%96%97%EF%BC%8C%E8%99%9A%E6%95%B0%E7%9A%84%E6%9D%A5%E6%BA%90.mp4)
{{< bilibili id=BV11h411x7z5 p=1 >}}
## Sources
最后,考虑到这是本人建的第 n 个网站了(搞没好几个),所以有兴趣的话还是离线保存本页吧,不然哪天没了就,整活了。`Ctrl + P``Comand + P` 以打印网页为 PDF或右键网页另存为。
Adobe Illustrator 项目原文件
{{< link href="for杨文雅.ai" content="for杨文雅.ai" title="Download for杨文雅.ai" download="for杨文雅.ai" card=true >}}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,270 @@
---
title: netcup vServer (ARM64) 基准测试和评测
subtitle:
date: 2024-03-09T22:33:19-05:00
slug: netcup-arm-review
draft: false
author:
name: James
link: https://www.jamesflare.com
email:
avatar: /site-logo.avif
description: 这篇博文评测了 netcup VPS 8000 ARM G11 服务器的性能表现。该服务器采用了基于 Ampere Altra Max 的 18 核 ARM64 CPU。文章包含了使用多种测试脚本得出的基准测试结果并将 CPU 性能与市面上知名的处理器进行了对比。
keywords: ["netcup","VPS","ARM服务器","基准测试","Ampere Altra Max"]
license:
comment: true
weight: 0
tags:
- VPS
- 基准测试
- netcup
- ARM
categories:
- VPS
- 评测
hiddenFromHomePage: false
hiddenFromSearch: false
hiddenFromRss: false
hiddenFromRelated: false
summary: 这篇博文评测了 netcup VPS 8000 ARM G11 服务器的性能表现。该服务器采用了基于 Ampere Altra Max 的 18 核 ARM64 CPU。文章包含了使用多种测试脚本得出的基准测试结果并将 CPU 性能与市面上知名的处理器进行了对比。
resources:
- name: featured-image
src: featured-image.jpg
- name: featured-image-preview
src: featured-image-preview.jpg
toc: true
math: false
lightgallery: false
password:
message:
repost:
enable: true
url:
# 更多 front matter 配置详见https://fixit.lruihao.cn/documentation/content-management/introduction/#front-matter
---
<!--more-->
## 简介
[netcup GmbH](https://www.netcup.eu) 出售一些有趣的 ARM 服务器。我最近购买了 [VPS 8000 ARM G11](https://www.netcup.eu/vserver/arm-server) 版本。它配备了 18 核 ARM64 CPU官网称其基于 Ampere Altra Max 处理器。
|产品|VPS 8000 ARM G11|
|---|---|
|虚拟化技术|KVM|
|处理器|18 核 ARM64|
|内存|64GB DDR4 ECC|
|存储空间|2048 GB SSD|
|网卡|2500 Mbit/s|
|流量|不限|
## 常规测试
[Teddysun](https://teddysun.com/444.html) 的测试脚本可以给出整体性能的概览:
```bash
wget -qO- bench.sh | bash
```
结果如下:
```text
-------------------- A Bench.sh Script By Teddysun -------------------
Version : v2023-10-15
Usage : wget -qO- bench.sh | bash
----------------------------------------------------------------------
CPU Model : CPU model not detected
CPU Cores : 18
AES-NI : ✓ Enabled
VM-x/AMD-V : ✗ Disabled
Total Disk : 2.0 TB (20.7 GB Used)
Total Mem : 62.7 GB (3.1 GB Used)
System uptime : 1 days, 14 hour 48 min
Load average : 0.25, 0.14, 0.10
OS : Debian GNU/Linux 12
Arch : aarch64 (64 Bit)
Kernel : 6.6.8
TCP CC : bbr
Virtualization : KVM
IPv4/IPv6 : ✓ Online / ✓ Online
Organization : AS197540 netcup GmbH
Location : Nürnberg / DE
Region : Bavaria
----------------------------------------------------------------------
I/O Speed(1st run) : 470 MB/s
I/O Speed(2nd run) : 673 MB/s
I/O Speed(3rd run) : 676 MB/s
I/O Speed(average) : 606.3 MB/s
----------------------------------------------------------------------
Node Name Upload Speed Download Speed Latency
Speedtest.net 174.35 Mbps 147.69 Mbps 0.29 ms
Los Angeles, US 626.82 Mbps 1950.34 Mbps 147.10 ms
Dallas, US 697.90 Mbps 2109.19 Mbps 133.37 ms
Montreal, CA 554.36 Mbps 904.78 Mbps 94.53 ms
Paris, FR 2108.91 Mbps 2321.03 Mbps 21.98 ms
Shanghai, CN 640.20 Mbps 1484.39 Mbps 255.22 ms
Hongkong, CN 5.00 Mbps 0.55 Mbps 301.56 ms
Mumbai, IN 1685.98 Mbps 2417.37 Mbps 116.27 ms
Singapore, SG 1592.12 Mbps 2572.71 Mbps 179.95 ms
Tokyo, JP 423.71 Mbps 1122.09 Mbps 217.83 ms
----------------------------------------------------------------------
Finished in : 5 min 15 sec
Timestamp : 2023-12-30 03:55:03 CET
----------------------------------------------------------------------
```
## Yet-Another-Bench-Script
```bash
curl -sL yabs.sh | bash
```
结果非常详细和冗长,我把结果分成几个部分。首先,让我们看看脚本的基本信息:
```text
# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #
# Yet-Another-Bench-Script #
# v2023-11-30 #
# https://github.com/masonr/yet-another-bench-script #
# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #
Sat Dec 30 04:16:48 AM CET 2023
ARM compatibility is considered *experimental*
```
然后是系统的基本信息:
```text
Basic System Information:
---------------------------------
Uptime : 1 days, 15 hours, 15 minutes
Processor : Neoverse-N1
BIOS virt-5.2 CPU @ 2.0GHz
CPU cores : 18 @ ??? MHz
AES-NI : ✔ Enabled
VM-x/AMD-V : ❌ Disabled
RAM : 62.7 GiB
Swap : 0.0 KiB
Disk : 2.0 TiB
Distro : Debian GNU/Linux 12 (bookworm)
Kernel : 6.6.8
VM Type : KVM
IPv4/IPv6 : ✔ Online / ✔ Online
IPv6 Network Information:
---------------------------------
ISP : netcup GmbH
ASN : AS197540 netcup GmbH
Host : NETCUP-GMBH
Location : Karlsruhe, Baden-Wurttemberg (BW)
Country : Germany
```
接下来是磁盘 IO 性能测试:
```text
fio Disk Speed Tests (Mixed R/W 50/50) (Partition /dev/vda4):
---------------------------------
Block Size | 4k (IOPS) | 64k (IOPS)
------ | --- ---- | ---- ----
Read | 138.63 MB/s (34.6k) | 261.70 MB/s (4.0k)
Write | 138.54 MB/s (34.6k) | 269.48 MB/s (4.2k)
Total | 277.18 MB/s (69.2k) | 531.19 MB/s (8.2k)
| |
Block Size | 512k (IOPS) | 1m (IOPS)
------ | --- ---- | ---- ----
Read | 298.21 MB/s (582) | 442.51 MB/s (432)
Write | 323.72 MB/s (632) | 493.71 MB/s (482)
Total | 621.93 MB/s (1.2k) | 936.22 MB/s (914)
```
然后是网络速度测试:
```text
iperf3 Network Speed Tests (IPv4):
---------------------------------
Provider | Location (Link) | Send Speed | Recv Speed | Ping
----- | ----- | ---- | ---- | ----
Clouvider | London, UK (10G) | 2.45 Gbits/sec | 2.37 Gbits/sec | 20.5 ms
Scaleway | Paris, FR (10G) | 2.46 Gbits/sec | busy | 20.1 ms
NovoServe | North Holland, NL (40G) | 2.47 Gbits/sec | 2.38 Gbits/sec | 9.96 ms
Uztelecom | Tashkent, UZ (10G) | 1.99 Gbits/sec | 996 Mbits/sec | 84.2 ms
Clouvider | NYC, NY, US (10G) | 2.00 Gbits/sec | 542 Mbits/sec | 91.6 ms
Clouvider | Dallas, TX, US (10G) | 1.44 Gbits/sec | 648 Mbits/sec | 128 ms
Clouvider | Los Angeles, CA, US (10G) | 1.16 Gbits/sec | 1.04 Gbits/sec | 147 ms
iperf3 Network Speed Tests (IPv6):
---------------------------------
Provider | Location (Link) | Send Speed | Recv Speed | Ping
----- | ----- | ---- | ---- | ----
Clouvider | London, UK (10G) | 2.44 Gbits/sec | 2.33 Gbits/sec | 20.5 ms
Scaleway | Paris, FR (10G) | busy | busy | 32.2 ms
NovoServe | North Holland, NL (40G) | 2.48 Gbits/sec | 2.35 Gbits/sec | 9.97 ms
Uztelecom | Tashkent, UZ (10G) | 2.10 Gbits/sec | 875 Mbits/sec | 84.4 ms
Clouvider | NYC, NY, US (10G) | 1.78 Gbits/sec | 893 Mbits/sec | 91.6 ms
Clouvider | Dallas, TX, US (10G) | 1.39 Gbits/sec | 852 Mbits/sec | 128 ms
Clouvider | Los Angeles, CA, US (10G) | 1.16 Gbits/sec | 549 Mbits/sec | 147 ms
```
接下来是 Geekbench 6 的测试结果:
```text
Geekbench 6 Benchmark Test:
---------------------------------
Test | Value
|
Single Core | 1072
Multi Core | 8650
Full Test | https://browser.geekbench.com/v6/cpu/4192622
```
最后,我只测试了 Geekbench 5使用以下脚本
```bash
curl -sL yabs.sh | bash -s -- -i -f -n -5
```
以下是 Geekbench 5 的结果:
```text
Geekbench 5 Benchmark Test:
---------------------------------
Test | Value
|
Single Core | 798
Multi Core | 10975
Full Test | https://browser.geekbench.com/v5/cpu/22091599
```
## 评测
现在,让我们来讨论一下测试结果。
### CPU 性能
VPS 8000 ARM G11 在 Geekbench 6 的多核得分大约为 8650 分。为了让你对这个分数有个概念,我选取了一些知名的 CPU 做对比。
|CPU|单核得分|多核得分|
|---|---|---|
|Intel Core i9-13900K|2970|20095|
|AMD Ryzen 9 7950X|2930|19224|
|Intel Core i9-12900K|2610|15428|
|AMD Ryzen 9 7940HS|2481|11741|
|AMD Ryzen 7 5800X3D|2085|10922|
|AMD Ryzen Z1 Extreme|2252|9689|
|AMD Ryzen 7 7840U|2099|8718|
|Intel Core i9-9900K|1664|7977|
我的 **Framework Laptop 13** 搭载了 **AMD Ryzen 7 7840U**,它的得分是
|CPU|单核得分|多核得分|
|---|---|---|
|AMD Ryzen 7 7840U|2256|12127|
这个差异是因为现代 CPU 有动态提升机制,可以超出基础时钟频率运行。
还有一点,我在 Geekbench 6 网站上看到了几条 [Ampere Altra Max 2800 MHz (96 核)](https://browser.geekbench.com/v6/cpu/1590435) 的记录。单核得分为 958多核得分为 11149。
这很奇怪,我的 18 核服务器多核得分为 8650而 Altra Max 2800 MHz (96 核) 只有 11149。我猜 Geekbench 6 网站上的 [Altra Max 2800 MHz (96 核)](https://browser.geekbench.com/v6/cpu/1590435) 记录性能表现得并不好,因为它是 ADLINK Ampere Altra 开发平台。它可能没有调教到最佳性能。

View File

@@ -0,0 +1,370 @@
---
title: 使用 sing-box 配置高级功能的 VLESS 协议
subtitle:
date: 2024-03-09T22:44:42-05:00
slug: vless-tcp-reality-xtls-utls-xudp
draft: false
author:
name: James
link: https://www.jamesflare.com
email:
avatar: /site-logo.avif
description: 本文提供了使用 sing-box 设置 VLESS + TCP + REALITY + XTLS + uTLS + XUDP 配置的详细步骤,包括服务器和客户端的设置、安装和运行 sing-box以实现一个安全高效的代理解决方案。
license:
comment: true
weight: 0
tags:
- sing-box
- 代理
- 安全
- 网络
categories:
- 教程
- 代理
hiddenFromHomePage: false
hiddenFromSearch: false
hiddenFromRss: false
hiddenFromRelated: false
summary: 本文提供了使用 sing-box 设置 VLESS + TCP + REALITY + XTLS + uTLS + XUDP 配置的详细步骤,包括服务器和客户端的设置、安装和运行 sing-box以实现一个安全高效的代理解决方案。
resources:
- name: featured-image
src: featured-image.jpg
- name: featured-image-preview
src: featured-image-preview.jpg
toc: true
math: false
lightgallery: false
password:
message:
repost:
enable: true
url:
# 查看详细的前言字段https://fixit.lruihao.cn/documentation/content-management/introduction/#front-matter
---
<!--more-->
## 简介
VLESS + TCP + REALITY + XTLS + uTLS + XUDP 是一个非常优秀的组合。[XUDP](https://github.com/XTLS/Xray-core/discussions/252) 可以让 VLESS 支持全锥型 NAT。使用 [REALITY](https://github.com/XTLS/REALITY#vless-xtls-utls-reality-example-for-xray-core-%E4%B8%AD%E6%96%87) 代替 TLS 可以消除服务器端 TLS 指纹特征,同时仍然提供前向保密并使证书链攻击无效,其安全性超过了传统的 TLS。它可以指向其他网站而无需购买域名或配置 TLS 服务器,使用起来更加方便。它实现了具有指定 SNI 的端到端真正 TLS 呈现给中间人。
## 获取 sing-box
## sing-box 基础知识
sing-box 使用 JSON 格式的配置文件。
```json
// 结构
{
"log": {},
"dns": {},
"ntp": {},
"inbounds": [],
"outbounds": [],
"route": {},
"experimental": {}
}
```
你可以在[这里](https://sing-box.sagernet.org/configuration)获取详细的文档。我不会详细介绍每一项配置。
## 服务器端配置
在开始之前,我们需要为 REALITY 生成一个 x25519 密钥对。在 sing-box 中可以通过运行以下命令来生成:
```bash
sing-box generate reality-keypair
```
你应该会得到类似这样的输出:
```text
PrivateKey: 0H5tYLhpDT_r675UC93iWAS2LqN6mPZoDcVDqsff018
PublicKey: SeIw41mp1LFEd6CEGArmnSoaIXzNlwnkIbduoEY-OXk
```
可选地,你还可以为 REALITY 生成一个短 ID。通过运行以下命令你应该会得到一个 8 位的十六进制数:
```bash
sing-box generate rand 8 --hex
```
输出大概是这样:
```text
26079ba8291ff0fc
```
最后,你还需要生成一个 UUID
```bash
sing-box generate uuid
```
输出类似这样:
```text
11391936-7544-4af5-ad02-e9f3970b1f64
```
现在,让我们将它们填写到正确的位置并完成配置。如果你想节省时间,不想深入研究细节,可以参考这个配置示例:
```json
{
"log":{
"level":"info"
},
"inbounds":[
{
"type":"vless",
"tag":"vless-in",
"listen":"0.0.0.0",
"listen_port":443,
"users":[
{
"name":"jamesflare",
"uuid":"11391936-7544-4af5-ad02-e9f3970b1f64",
"flow":"xtls-rprx-vision"
}
],
"tls":{
"enabled":true,
"server_name":"www.rpi.edu",
"reality":{
"enabled":true,
"handshake":{
"server":"www.rpi.edu",
"server_port":443
},
"private_key":"0H5tYLhpDT_r675UC93iWAS2LqN6mPZoDcVDqsff018",
"short_id":[
"26079ba8291ff0fc"
]
}
},
"multiplex":{
"enabled":false
}
}
],
"outbounds":[
{
"type":"direct",
"tag":"direct"
}
]
}
```
我强烈建议你根据自己的情况修改以下字段:
- `name`
- `uuid`
- `server_name`
- `server`
- `server_port`
- `private_key`
- `short_id`
## 客户端配置
我希望 sing-box 使用 `TUN` 作为入站,这样我们就可以实现全局代理。当然你也可以将其作为 http/socks 代理运行。无论如何,我将以 `TUN` 为例。
你需要将以下字段更改为你自己的值:
- `server`
- `server_port`
- `uuid`
- `server_name`
- `public_key`
- `short_id`
确保你的值与服务器端信息匹配。这里是一个配置示例:
```json
{
"log":{
"level":"info",
"timestamp":true
},
"dns":{
"servers":[
{
"tag":"cloudflare",
"address":"1.1.1.1"
}
],
"rules":[
{
"outbound":"any",
"server":"cloudflare"
}
],
"strategy":"ipv4_only"
},
"inbounds":[
{
"type":"tun",
"tag":"tun-in",
"interface_name":"tun0",
"inet4_address":"172.28.0.1/30",
"auto_route":true,
"strict_route":true,
"stack":"system",
"sniff":true
}
],
"outbounds":[
{
"type":"vless",
"tag":"vless-out",
"server":"your.server.ip.or.domain",
"server_port":443,
"uuid":"11391936-7544-4af5-ad02-e9f3970b1f64",
"flow":"xtls-rprx-vision",
"tls":{
"enabled":true,
"server_name":"www.rpi.edu",
"utls":{
"enabled":true,
"fingerprint":"chrome"
},
"reality":{
"enabled":true,
"public_key":"SeIw41mp1LFEd6CEGArmnSoaIXzNlwnkIbduoEY-OXk",
"short_id":"26079ba8291ff0fc"
}
},
"packet_encoding":"xudp",
"multiplex":{
"enabled":false
}
},
{
"type":"direct",
"tag":"direct"
},
{
"type":"dns",
"tag":"dns"
}
],
"route":{
"geoip":{
"download_url":"https://github.com/SagerNet/sing-geoip/releases/latest/download/geoip.db",
"download_detour":"vless-out"
},
"geosite":{
"download_url":"https://github.com/SagerNet/sing-geosite/releases/latest/download/geosite.db",
"download_detour":"vless-out"
},
"rules":[
{
"protocol":"dns",
"outbound":"dns"
},
{
"geoip":[
"private"
],
"outbound":"direct"
}
],
"auto_detect_interface":true
}
}
```
## 安装 sing-box
你可能会问"我如何使用上述配置运行 sing-box"。首先你需要安装 sing-box。你可以在[官方文档](https://sing-box.sagernet.org/installation/package-manager/)中找到更多安装信息。
### 在 Debian 12 中安装
我在 Linux 服务器上运行 sing-box 服务器端,操作系统是 Debian 12。在这种情况下我使用了 debian 的官方安装脚本:
```bash
bash <(curl -fsSL https://sing-box.app/deb-install.sh)
```
你可以通过运行以下命令检查是否安装成功:
```bash
sing-box help
```
它应该会返回类似以下内容:
```text
Usage:
sing-box [command]
Available Commands:
check Check configuration
completion Generate the autocompletion script for the specified shell
format Format configuration
generate Generate things
help Help about any command
merge Merge configurations
run Run service
tools Experimental tools
version Print current version of sing-box
Flags:
-c, --config stringArray set configuration file path
-C, --config-directory stringArray set configuration directory path
-D, --directory string set working directory
--disable-color disable color output
-h, --help help for sing-box
Use "sing-box [command] --help" for more information about a command.
```
对于使用 systemd 的 Linux 系统,通常安装已经包括了一个 sing-box 服务,你可以使用以下命令管理该服务:
### 在 Windows 11 中安装
我的客户端是 Windows 11我选择使用 [Chocolatey](https://chocolatey.org/install#individual) 进行托管安装。要安装 Chocolatey你需要使用以下命令运行管理员 PowerShell
```bash
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
```
如果你没有看到任何错误,就可以开始使用 Chocolatey 了!输入 `choco``choco -?` 检查是否安装成功。请记住,这只是一个非常简单的 Chocolatey 安装说明,还有许多其他安装方法和选项,请查看官网以获取更多信息。
现在,我们可以使用 Chocolatey 安装 sing-box
```bash
choco install sing-box
```
你可以通过运行以下命令检查是否安装成功:
```bash
sing-box help
```
## 运行 sing-box
服务器端和客户端的 sing-box 程序没有区别。唯一的区别在于配置文件。
在开始之前,你应该将配置保存到 JSON 文件中。我会将它们命名为:`client.json`、`server.json`。然后在命令中指定配置文件,例如:
```bash
sing-box run -c client.json
```
你需要在客户端和服务器端都运行 sing-box。输出应该类似于
```text
C:\Users\James\Desktop\Softwares\sing-box>sing-box run -c xray-ny-a-client.json
-0500 2023-12-27 23:23:32 INFO router: updated default interface Wi-Fi, index 18
-0500 2023-12-27 23:23:32 INFO inbound/tun[tun-in]: started at tun0
-0500 2023-12-27 23:23:32 INFO sing-box started (0.288s)
-0500 2023-12-27 23:23:32 INFO [832064929 0ms] inbound/tun[tun-in]: inbound packet connection from 172.28.0.1:55770
-0500 2023-12-27 23:23:32 INFO [1067986987 0ms] inbound/tun[tun-in]: inbound packet connection from 172.28.0.1:58423
-0500 2023-12-27 23:23:32 INFO [2253360887 0ms] inbound/tun[tun-in]: inbound connection from 172.28.0.1:60610
-0500 2023-12-27 23:23:32 INFO outbound/vless[vless-out]: outbound packet connection to 1.1.1.1:53
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

View File

@@ -0,0 +1,663 @@
---
title: Stable Diffusion 元素法典 Part 1.5
subtitle:
date: 2023-03-03T01:26:23+08:00
slug: code-quintessence-part-1-5
draft: false
author:
name: James
link: https://www.jamesflare.com
email:
avatar: /site-logo.avif
description: 这是《元素法典》(第壹點伍卷)的重写版本,主要是原版是一个在线文档,不够轻量和灵活。
keywords:
license:
comment: true
weight: 0
tags:
- Stable Diffusion
- 提示词
categories:
- Stable Diffusion
- 资源分享
hiddenFromHomePage: false
hiddenFromSearch: false
hiddenFromRss: false
hiddenFromRelated: false
summary: 这是《元素法典》(第壹點伍卷)的重写版本,主要是原版是一个在线文档,不够轻量和灵活。
resources:
- name: featured-image
src: featured-image.jpg
- name: featured-image-preview
src: featured-image-preview.jpg
toc: true
math: false
lightgallery: true
password:
message:
repost:
enable: true
url:
# See details front matter: https://fixit.lruihao.cn/documentation/content-management/introduction/#front-matter
---
<!--more-->
{{< admonition type=warning title="This is a Copy" open=true >}}
This Post is Rewrited from 《元素法典》.
{{< /admonition >}}
## 前言
本书是继第一卷后的、继续对特定风格的魔法进行收录的法典。
在第二卷推出之前,本卷将起承上启下的作用,衍生自 1.0 版本的内容,请期待第二卷!
这是一本免费、开源的法典,欢迎任何人向编纂者投稿记录自己的魔法。
由于魔法数量过多且包含图片,请妥善利用好目录功能以快速寻找到心仪的魔法。
如果你在里面找到了非英文分隔号、像是错拼的单词、奇怪的回车甚至任何不像是科学能解释的东西——请不用担心,那都是咒语的一部分。
如果你在寻找关于 Novel AI 的新手教程或 tag 解析,请左转:[元素同典 确实不完全科学的魔导书](https://docs.qq.com/doc/DWFdSTHJtQWRzYk9k)
或前往贴吧官方 QQ 答疑群/技术交流群。
本文中所有资料均可被自由引用。
最终解释权归 [元素法典制作委员会](https://space.bilibili.com/1981251194) 所有。
> 仅致敬署名者为让这幅图成为现实所体现出的探索精神与热情。
>
> 他们所付出的努力将为后人带来无法代替的影响。
>
> 对于生产出的图像,我们基于互联网精神与实际,将不保留任何权利。
相关链接:[元素同典 确实不完全科学的魔导书](https://docs.qq.com/doc/DWFdSTHJtQWRzYk9k)
相关链接:[元素法典 第一点五卷](https://docs.qq.com/doc/DWGh4QnZBVlJYRkly)
相关链接:[元素法典 第贰卷](https://docs.qq.com/doc/DWEpNdERNbnBRZWNL)
相关链接:[元素法典 第二点五卷](https://docs.qq.com/doc/DWHFOd2hDSFJaamFm)
相关链接:[NovelAI 信息并联计划](https://kdocs.cn/l/cre0TwbMkdx3)
相关链接:[元素法典制作委员会](https://space.bilibili.com/1981251194)
元素法典交流群681152172
感谢所有参与编纂和投稿魔法的魔法使们。
## 序
### 万物熔炉
{{< image src="fusePlusCode.avif" width="250px" caption="万物熔炉" >}}
作者antwominyQQ 863081130
“阴阳者,数之可十,离之可百,散之可千,推之可万,万之大不可胜数也,然其要一也。此为万物熔炉。”
注:此魔法原为阴阳法,但其可以几乎与所有其他魔法融合且效果良好,达成万物归一效果,故称其为万物熔炉。此外,可以将 TAG 中的 black 和 white 换为其他任意两种元素组合,以达成新的效果。
正面 tag
> masterpiece, (best quality), Amazing, beautiful detailed eyes, ((((1girl)))), finely detailed, Depth of field, extremely detailed CG unity 8k wallpaper, (((((full body))))), (((cute animal face))), (((a girl wears Clothes Black and white Taoist robes))), ((Extremely gorgeous magic style)), ((((gold and silver lace)))), (((flowing lace))), (((flowing ((black)) and white background))), (((((gorgeous detailed eyes))))), (((((((gorgeous detail face))))))), ((floating hair)), (((Pick and dye black hair in white hair))), (((flowing transparent black))), (((flowing transparent white))), (((((ink))))), ((((small breast)))), (((extremely detailed gorgeous tiara))), (((black and white hair))), ((black hair stick)), ((white hair ornament)), ((gold gorgeous necklace)), ((flowing hair)), (((The picture fills the canvas))), ((The character is in the center of the frame)), (((flowing))), ((bright pupils)), ((((melt)))), (((((black and white melt)))))
反面 tag
> (((ugly))), (((duplicate))), ((morbid)), ((mutilated)), (((tranny))), mutated hands, (((poorly drawn hands))), blurry, ((bad anatomy)), (((bad proportions))), extra limbs, cloned face, (((disfigured))), (((more than 2 nipples))), ((((missing arms)))), (((extra legs))), mutated hands, (((((fused fingers))))), (((((too many fingers))))), (((unclear eyes))), lowers, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, bad feet, text font ui, malformed hands, long neck, missing limb, (mutated hand and finger:1.5), (long body:1.3), (mutation poorly drawn:1.2), disfigured, malformed mutated, multiple breasts, futa, yaoi
参数:
> Steps: 39, Sampler: Euler, CFG scale: 7
### 暗鸦法
{{< image src="darkCrowCode.avif" width="450px" caption="暗鸦法" >}}
作者JMikuer♚楠
{{< center-quote >}}
'Vinctorus aut Mortis!'(胜利或死亡)
——第十九军团
{{< /center-quote >}}
正面 tag
> (((masterpiece))), best quality, extremely detailed CG unity 8k, illustration, contour deepening beautiful detailed glow, (beautiful detailed eyes), (1 girl:1.1), ((Bana)), large top sleeves, Floating black ashes, Beautiful and detailed black, red moon, ((The black clouds)), (black Wings), a black cloudy sky, burning, black dress, (beautiful detailed eyes), black expressionless, beautiful detailed white gloves, (crow), bat, (floating black cloud:1.5), white and black hair, disheveled hair, long bangs, hairs between eyes, black knee-highs, black ribbon, white bowties, midriff, {{{half closed eyes}}}, ((Black fog)), Red eyes, (black smoke), complex pattern, ((Black feathers floating in the air)), (((arms behind back)))
反面 tag
> (((ugly))), (((duplicate))), ((morbid)), ((mutilated)), (((tranny))), mutated hands, (((poorly drawn hands))), blurry, ((bad anatomy)), (((bad proportions))), extra limbs, cloned face, (((disfigured))), (((more than 2 nipples))), ((((missing arms)))), (((extra legs))), mutated hands, (((((fused fingers))))), (((((too many fingers))))), (((unclear eyes))), lowers, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, bad feet, text font ui, malformed hands, long neck, missing limb, (mutated hand and finger:1.5), (long body:1.3), (mutation poorly drawn:1.2), disfigured, malformed mutated, multiple breasts, futa, yaoi, extra limbs, (bad anatomy), gross proportions, (malformed limbs), ((missing arms)), ((missing legs)), (((extra arms))), (((extra legs))), mutated hands, (fused fingers), (too many fingers), (((long neck))), missing fingers, extra digit, fewer digits, bad feet
参数:
> Steps: 50, Sampler: Euler a, CFG scale: 4.5, Size: 1024x768, Model hash: e6e8e1fc, Clip skip: 2
### 花火法基础
{{< image src="fireworksCode.avif" width="450px" caption="花火法基础" >}}
作者PhoebeQQ 3101516445
{{< center-quote >}}
花了好久时间终于改进好了。
{{< /center-quote >}}
正面 tag
> ((extremely detailed CG unity 8k wallpaper)), (masterpiece), (best quality), (ultra-detailed), (best illustration), (best shadow), (an extremely delicate and beautiful), ((((1girl)))), dynamic angle, floating, finely detail, (bloom), (shine), glinting stars, ((((best detailed fireworks)))), ((((depth of field)))), (((hanabi))), Beautiful detailed girl, (((backlight))), extremely delicate and beautiful girls, ((summer long skirt)), (((solo))), best detailed hair, ((beautiful detailed water)), night sky, (((small breast))), beautiful detailed sky, beautiful detailed eyes, (((arms behind back))), long hair, (((dynamic angle))), long skirt
反面 tag
> Inverted mountain, low-quality, flowers, grass, distorted mountain, distorted light, low-quality light, low-quality mountain, low-quality illustration, low-quality background, nsfw, polar lowres, bad anatomy, bad hands, bad body, bad proportions, gross proportions, text, error, missing fingers, missing arms, missing legs, extra digit
参数:
> Steps: 50, Sampler: Euler a, CFG scale: 5.5, Size: 1024x768, Model hash: e6e8e1fc, Clip skip: 2
### 星之彩
{{< image src="bubbleGalaxyCode.avif" width="450px" caption="星之彩" >}}
作者:東雲
{{< center-quote >}}
当你 san 值出了点问题还作死敢看天空时~尤格!
{{< /center-quote >}}
正面 tag
> ((best quality)), ((masterpiece)), ((ultra-detailed)), (illustration), (detailed light), (an extremely delicate and beautiful), a girl, cute face, upper body, two legs, long dress, (beautiful detailed eyes), stars in the eyes, messy floating hair, colored inner hair, Starry sky adorns hair, (lots_of_big_colorful_Bubble), [pearl], [Galaxy], depth of field
反面 tag
> lowres, bad anatomy, text, bad face, error, extra digit, fewer digits, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, {blurry:1.1}, missing arms, missing legs, more than two legs, [[[small bubble]]]
参数:
> Steps: 25, Sampler: DDIM, CFG scale: 5, Size: 1024x640, Model hash: e6e8e1fc, Clip skip: 2
### 沉入星海
{{< image src="sunkGalaxyCode.avif" width="450px" caption="沉入星海" >}}
作者:東雲
{{< center-quote >}}
尤格索托斯拟人的半成品试跑,意志降临了。
{{< /center-quote >}}
正面 tag
> {{best quality}}, {{masterpiece}}, {{ultra-detailed}}, {illustration}, {detailed light}, {an extremely delicate and beautiful}, a girl, {beautiful detailed eyes}, stars in the eyes, messy floating hair, colored inner hair, Starry sky adorns hair, depth of field
反面 tag
> lowres, bad anatomy, text, error, extra digit, fewer digits, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, {blurry:1.1}, missing arms
参数:
> Steps: 25, Sampler: DDIM, CFG scale: 5, Size: 1024x640, Model hash: e6e8e1fc, Clip skip: 2
编者注:
> “与上面的有异曲同工之妙,拨开华丽的外表,在这之下是更纯粹的美。”(板)
>
> “你在凝望深渊时,深渊...啊,他好可爱啊。”(今宵鳩鳴)
### 百溺法
{{< image src="bloodPoolCode.avif" width="450px" caption="百溺法" >}}
作者:药隐
{{< center-quote >}}
百溺法随便哪种颜色都比血水古神率低,果然现在是熔炉百相的时代了!
{{< /center-quote >}}
正面 tag
> (watercolor), ((extremely detailed CG unity 8k wallpaper)), (game cg), ((masterpiece)), ((best quality)), ((ultra-detailed)), (1 girl), (solo), (best illustration), (extremely detailed illustration), ((disheveled hair)), ((beautiful detailed lighting)), (from above), ((an extremely delicate and beautiful)), cinematic lighting, dynamic angle, detailed wet clothes, blank stare, overexplosure, floating, (beautiful detailed eyes), side blunt bangs, small breasts, black long straight, red eyes, aqua eyes, gradient eyes, black hair, very long hair, blunt bangs, ((blood)), white dress, frills, bowties, ((expressionless)), extremely beautiful detailed water, ((lying on the lake)), ((hairs curling in the water)), (bloodred water:1.5), (red background:1.3), swirl
反面 tag
> long body, long face, lowres, bad anatomy, bad hands, missing fingers, pubic hair, extra digit, fewer digits, cropped, worst quality, low quality, extra legs, extra arms, fused arms, fused legs, extra feet, fused feet, abnormal legs, abnormal shoulders, poorly drawn shoulders, blurry, misplaced arms, misplaced legs, misplaced hands, abnormal hands, watermark, username, signature, jpeg artifacts, multiple heads, abnormal face, twisted head
参数:
> Sampler: Euler a, CFG scale: 4.5-5.5, Size: 768x512, Clip skip: 2
百溺法进阶:
删除 `blood` 或将其替换为 `(__ colored blood)__ long straight, __ eyes, __ hair, ___ dress, (___ water:1.5), (___ background:1.3)`,基本使用于任意二色,多色可能会让漩涡效果消失,`starry` 也可替换
编者注:
> “流血量超大啊!但是意境很不错而且也可以用进阶的百溺法变成沉到不同颜色的液体里去,拓展性很强。”(麦子)
### 辉煌阳光法
{{< image src="glowSunCode.avif" width="450px" caption="辉煌阳光法" >}}
作者千夜QQ1067134933
{{< center-quote >}}
(金毛 + 辉光,不会有人不喜欢叭)
{{< /center-quote >}}
正面 tag
> {masterpiece}, {best quality}, {1girl}, Amazing, beautiful detailed eyes, solo, finely detail, Depth of field, extremely detailed CG, original, extremely detailed wallpaper, {{highly detailed skin}}, {{messy_hair}}, {small_breasts}, {{longuette}}, {grassland}, {yellow eyes}, full body, incredibly_absurdres, {gold hair}.lace, floating hair, Large number of environments, the medieval, grace, A girl leaned her hands against the fence, ultra-detailed, illustration, birds, Altocumulus, 8kwallpaper, hair_hoop, long_hair, gem necklace, hair_ornament, prospect, water eyes, wind, breeze, god ray, lawn, Mountains and lakes in the distance, The skirt sways with the wind, The sun shines through the trees, A vast expanse of grassland, fence, Blue sky, bloom, smile, glow, The grass sways in the wind
反面 tag
> {lowres}, {{{{{{{{{{{blurry}}}}}}}}}}}, {{{{{{{{{bad hands}}}}}}}}}, {{{{{missing fingers}}}}}, {{{{{{{{{{{{{extra digit}}}}}}}}}}}}}, fewer digits, small hands, error, multiple limbs, bad feet, cropped, worst quality, low quality, normal quality, jpeg artifacts, bad anatomy, long nails, {{{{interlocked fingers}}}}, milf, ugly, duplicate, morbid, mutilated, tranny, trans, trannsexual, mutation, deformed, long neck, bad anatomy, bad proportions, extra arms, extra legs, disfigured, more than 2 nipples, malformed, mutated, hermaphrodite, out of frame, extra limbs, missing arms, missing legs, poorly drawn hands, poorty drawn face, mutation, poorly drawn, long body, multiple breasts, cloned face, gross proportions, mutated hands, bad hands, bad feet, long neck, missing limb, malformed limbs, malformed hands, fused fingers, too many fingers, extra fingers, missing fingers, extra digit, fewer digits, mutated hands and fingers, lowres, text, error, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, text font ui, futa, yaoi
参数:
> CFG 7 Euler Step40
编者注:
> “阳光!少女!意境和感觉都很不错,像是春天的感觉。”(麦子)
>
> “我愿面朝大海,春暖花开。”(海子)
### 星鬓法
{{< image src="hairGalaxyCode.avif" width="450px" caption="星鬓法" >}}
作者Gloaming QQ2762215011
{{< center-quote >}}
星空和水更配哦(调整好水咒语和星咒语的量)
{{< /center-quote >}}
正面 tag
> masterpiece, best quality, illustration, stars in the eyes, dishevelled hair, Starry sky adorns hair, 1 girl, sparkling anime eyes, beautiful detailed eyes, beautiful detailed stars, blighting stars, emerging dark purple across with white hair, multicolored hair, beautiful detailed eyes, beautiful detailed sky, beautiful detailed water, cinematic lighting, dramatic angle,
反面 tag
> lowres, bad anatomy, bad legs, bad hands, text, error, missing fngers, extra digt, fewer digits, cropped, wort quality, low quality, normal quality, jpeg, artifacts, signature, watermark, username, blurry, bad feet, artist name, bad anatomy, bad hands, bad body, bad proportions, worst quality, low quality, optical_illusion
参数:
> Steps30 CFG: scale:6 Euler a
编者注:
> “星星作为头发超级有梦幻感~” (麦子)
>
> “谁不向往星星呢?” mahiru
>
> “宇宙的历史如同画卷一般平铺在她的发髻之下,他从遥远的岁月中呼唤着她的名字。”(今宵鳩鳴)
>
> “她的眼中是星辰,也有未来”(半生为夏甗麦至冬)
### 森罗法
{{< image src="flowerForestCode.avif" width="250px" caption="森罗法" >}}
作者开狼QQ1540548912
{{< center-quote >}}
以枝叶繁花营造经典的主题画面,操作平台为官网。
{{< /center-quote >}}
正面 tag
> super fine illustration, masterpiece, best quality, {beautiful detailed eyes}, 1girl, finely detail, Depth of field, 4k wallpaper, bluesky, cumulus, wind, insanely detailed frills, extremely detailed lace, BLUE SKY, very long hair, Slightly open mouth, high ponytail, silver hair, small Breasts, cumulonimbus capillatus, slender waist, There are many scattered luminous petals, Hidden in the light yellow flowers, Depth of field, She bowed her head in frustration, Many flying drops of water, Upper body exposed, Many scattered leaves, branch, angle, contour deepening, cinematic angle, {{{Classic decorative border}}}
反面 tag
> 不需要
参数:
> Steps: 50 Sampler: DDIM scale:8 Size: 512x10241024x1024
### 星天使
{{< image src="angelCode.avif" width="450px" caption="星天使" >}}
作者:東雲
{{< center-quote >}}
别看这,看图!
{{< /center-quote >}}
正面 tag
> {{best quality}}, {{masterpiece}}, {{ultra-detailed}}, {illustration}, {detailed light}, {an extremely delicate and beautiful}, {beautiful detailed eyes}, {sunlight}, {{extremely light}}, {{extremely clothes}}, {{{Holy Light}}}, dynamic angle, a girl, {{angel}}, solo, {{{loli}}}, Light particle, very_long_hair, white_hair, yellow_eyes, {{glowing eyes}}, {{{expressionless}}}, [[light_smile]], [[[[white Tulle skirt]]]], {white silk}, looking_at_viewer, {{{{angel_wings}}}}, {{large_wings}}, multiple_wings, {angel_halo}, [[[starry sky]]], {{dusk_sky}}, {{Floating light spot}}, {{Lots of feathers}}
反面 tag
> lowres, bad anatomy, text, error, extra digit, fewer digits, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, missing arms, big breasts, head_wings, dutch angle, furrowed brow raised eyebrows, looking away, thin, petite, Skirt lift, {{smile}}
参数:
> Steps: 42, Sampler: Euler, CFG scale: 7 Size: 1024x576, Model hash: e6e8e1fc, Clip skip: 2
### 黄金律
{{< image src="goldPlusCode.avif" width="350px" caption="黄金律" >}}
作者DogeQQ 575565786
{{< center-quote >}}
金发!金瞳!金衣!金饰!金屋!金殿!反正金闪闪就是了!
{{< /center-quote >}}
正面 tag
> {{masterpiece}}, best quality, Amazing, {beautiful detailed eyes}, {1girl}, extremely detailed CG unity 8k wallpaper, highly detailed, official_art, highres, original, blonde hair, yellow eyes, white skin, slim legs, mature female, sunrise, golden sky, magnificent architecture, beautiful detailed sky, overexposure, detailed background, delicate gold metal decorations
反面 tag
> bad feet_hand_finger_leg_eye, missing fingers, worst low normal quality, bad face, blurry:1.1, Asymmetrical eyes, Simple background, mutation, poorly drawn, huge breasts, huge haunch, huge thighs, more than 2 nipples, huge calf, bad anatomy, liquid body, disfigured, malformed, mutated, anatomical nonsense, text font ui, error, malformed hands, long neck, blurred, lowers, lowres, bad proportions, bad shadow, uncoordinated body, unnatural body, text, ui, error, cropped, watermark, username, blurry, JPEG artifacts, signature, 3D, bad hairs, poorly drawn hairs, fused hairs, big muscles, ugly, bad face, fused face, poorly drawn face, cloned face, big face, long face, bad eyes, fused eyes poorly drawn eyes, extra eyes, malformed limbs
参数:
> Steps: 51, Sampler: Euler a, CFG scale: 6, Size: 1024x1024, Model hash: 925997e9
### 机凯姬 改
{{< image src="roboarmorCodeModB.avif" width="350px" caption="机凯姬 改" >}}
作者Gloaming QQ2762215011
竖版和横板生成的图有不少差别,竖着容易生成一人一萝卜,横着出机凯姬。出图低概率萝卜会把人吞了。
正面 tag
> masterpiece, best quality, illustration, beautiful detailed eyes, colorful background, mechanical prosthesis, mecha coverage, emerging dark purple across with white hair, pig tails, disheveled hair, fluorescent purple, cool movement, rose red eyes, beatiful detailed cyberpunk city, multicolored hair, beautiful detailed glow, 1 girl, expressionless, cold expression, insanity, long bangs, long hair, lace, dynamic composition, motion, ultra - detailed, incredibly detailed, a lot of details, amazing fine details and brush strokes, smooth, hd semirealistic anime cg concept art digital painting
反面 tag
> lowres, bad anatomy, bad legs, bad hands, text, error, missing fingers, extra digt, fewer digits, cropped, worst quality, low quality, normal quality, jpeg, artifacts, signature, watermark, username, blurry, bad feet, artist name, bad anatomy, bad hands, bad body, bad proportions, worst quality, low quality, optical_illusion
参数:
> Steps25 CFG: scale:4 euler a
### 人鱼法
{{< image src="fisherCode.avif" width="450px" caption="人鱼法" >}}
作者:岚心
{{< center-quote >}}
呜呜,人鱼尾巴好难跑。
{{< /center-quote >}}
正面 tag
> {long hair}, {revealing dress}, {elbow gloves }, {{{{beautiful mermaid}}}}, {smirk}, {nose blush }, stretch, Bare arms, Bare navel, (incredibly_absurdres), best quality, beautiful detailed eyes, blue_hair, (highly detailed beautiful fishtail:1.6), (((human hands))), (((masterpiece))), (blue_eyes), ((medium_breasts)), (the lower body is a fish:1.9), (no human thigh:1.2), seaweed, (full body), (white seashell), (curved and slender fish tail), (the lower body is bare:1.1), {beautiful tailfin}, ((underwater)), (illustration), detailed water, ((a extremely delicate and beautiful girl)), (underwater forest), ((sunlight)), ((fishes)), (floating), watercolor_(medium), ((an extremely delicate and beautiful)), ((coral)), floating hair, glowing eyes, (splash), (detailed glow), ((Tyndall effect)), (landscape), hair_ornament, (small whirlpool), ((The sensation of water flowing)), (detailed scales on a mermaid)
反面 tag
> lowres, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, artist name, (human thighs:1.5), hips, foot, the hand becomes a fishtail, thigh_gap, thighs, the lower body is human, (two legs:1.5), multiple breasts, (mutated hands and fingers:1.5), (long body:1.3), (mutation), (poorly drawn:1.2), bad shadow, ugly, (extra legs:1.5), (too long tail:1.5), one hand with more than 5 fingers, one hand with less than 5 fingers, one hand with more than 5 digit, one hand with less than 5 digit
参数:
> Steps: 80, Sampler: Euler a, CFG scale: 6
### 末日
{{< image src="ashCode.avif" width="450px" caption="末日" >}}
作者:某驾校校长
{{< center-quote >}}
混蛋..混蛋混蛋混蛋!!明明...明明说好要一起..一起活下去的啊...骗子..骗子!!
{{< /center-quote >}}
正面 tag
> full body, Blood Mist, background_Urban rooftop, 1 girl, despair, blood sakura, ((masterpiece)), (((best quality))), ((ultra-detailed)), ((illustration)), ((disheveled hair)), Blood Cherry Blossom, torn clothes, crying with eyes open, solo, Blood Rain, bandages, Gunpowder smoke, beautiful deatailed shadow, Splashing blood, dust, tyndall effect
反面 tag
> lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, missing fingers, bad hands, missing arms, long neck, Humpbacked
参数:
> Step 50, Sampler: 通用, CFG scale: 14, Size: 1408x960, Model hash: e6e8e1fc, Eta: 0.67, Clip skip: 2
### 碎梦
{{< image src="brokenDreamCode.avif" width="450px" caption="碎梦" >}}
作者:某驾校校长
{{< center-quote >}}
【滴!机体损耗百分之七十!】
可能..跟你见最后一面的时候到了...
【滴!机体损...损耗百分之八十!】
さらば my...daring...
【滴!机...机体损...损耗百分之......】
{{< /center-quote >}}
正面 tag
> (masterpiece), black hair, red eyes, 1girl, solo, ((delicate face)), ((an extremely delicate and beautiful)), strange, Space opera, Space port, robot arm, elbow_gloves, night, glisten, stare, cyberpunk, ((((citylight)))), ((masterpiece)), (((best quality))), (beautiful detailed eyes), ((ultra-detailed)), ((illustration)), ((disheveled hair)), science fiction, bodysuit, Mechanical armor headdress, (bare shoulders)
反面 tag
> lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, missing fingers, bad hands, missing arms, long neck, Humpbacked, long neck,
参数:
> Steps: 48, Sampler: LMS Karras, CFG scale: 15, Size: 1152x640, Model hash: e6e8e1fc, Clip skip: 2
### 幻碎梦
{{< image src="segDreamCode.avif" width="450px" caption="幻碎梦" >}}
作者离露QQ1123820886
{{< center-quote >}}
我曾有一个破碎的梦。梦里看不到光,旁人在高声说话,但我却听不清……
{{< /center-quote >}}
正面 tag
> 8k Wallpaper, grand, (((masterpiece))), (((best quality))), ((ultra-detailed)), (illustration), ((an extremely delicate and beautiful)), dynamic angle, rainbow hair, detailed cute anime face, ((loli)), (((masterpiece))), an extremely delicate and beautiful girl, flower, cry, water, corrugated, flowers tire, broken glass, (broken screen), atlantis, transparent glass
反面 tag
> lowres, bad anatomy, bad hands, text, error, missing fingers, extra digt, fewer digits, cropped, wort quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, bad feet, nsfw, Deformed body, spectacles, Deformed face, blue face
参数:
> Steps: 50, Sampler: Euler, CFG scale: 12, Size: 1024x512, Model hash: e6e8e1fc, Clip skip: 2
### 血法改
{{< image src="bloodCodeModB.avif" width="450px" caption="血法改" >}}
作者千秋夢QQ1798780261
{{< center-quote >}}
此法对分辨率和步数要求较高,慎重使用。
{{< /center-quote >}}
正面 tag
> ((solo)), best quality, Amazing, 1girl, extremely detailed CG unity 8k wallpaper, masterpiece, (loli), (white hair), (((red streaked hair))), red eyes, (((full body))), (red hair), (((((Hold a red sword))))), (angry face), (beautiful detailed eyes), ((Blood drop)), ((Blood fog)), light shafts, soft focus, character focus, disheveled hair, long bangs, hairs between eyes, looking at viewer, lowing hair, (((Splashing blood))), Long hair, ((Bloodstain)), Fighting stance, {{{{{watercolor_(medium)}}}}}, (((masterpiece))), ((white clock)), ((ultra-detailed)), ((Covered in blood)), flowing hair, Exquisite Flame, {{{{{{extremely beautiful detailed anime face}}}}}}, dynamic angle, floating, (shine), extremely delicate and beautiful girls, bright skin, (best illustration), (best shadow), finely detail, Depth of field (bloom), (painting), { very delicate light}, {perfect and delicate limbs}, beautiful detailed dress, Flying red petals, Holy lighting
反面 tag
> (mutated hands and fingers:1.5), (long body:1.3), (mutation), (poorly drawn:1.2), liquid body, text font ui, long neck, uncoordinated body, fused ears, huge breasts, ((((ugly))))
参数:
> Steps: 60, Sampler: Euler a, CFG scale: 7, Size: 1600x768
### 留影术
{{< image src="shadeCode.avif" width="450px" caption="留影术" >}}
作者:黄砂
{{< center-quote >}}
人人有功练?(不是)
{{< /center-quote >}}
把多余的词条都去掉的纯魔咒极简版,`{}` 强化 `comic` 词条可以做出更偏向二次元的画风,弱化 `comic` 加强质量词条可以得到更加写实的画风,可塑性强,出图质量较为稳定,在 75% 左右。加入 `floating hair` 词条会更灵动活泼。不建议加全身类的词条。
正面 tag
> 1male, solo, (Masterpiece), ((best quality)), beautifully painted, highly detailed, detailed clothes, detailed face, detailed eyes, {{intricate detail}}, detailed background, dramatic shadows, black and white, monochrome, {{comic}}, cross necklace, Cassock
反面 tag
> longbody, lowres, bad anatomy, bad hands, missing fingers, pubic hair, extra digit, fewer digits, cropped, worst quality, low quality, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, jpeg artifacts, signature, username, blurry, missing fingers, bad hands, missing arms, extra fingers, poorly drawn hands, poorly drawn face, malformed limbs, extra hands
参数:
> Steps: 100, Sampler: Euler a, CFG scale: 10.5
### 西幻术
{{< image src="dreamGuardenCode.avif" width="450px" caption="西幻术" >}}
作者:凌霜雪猫
油画风的厚涂角色,场景上很偏西幻,角色为伪厚涂风格。
出人不稳定,主要是这风景也太好了吧,可以根据《标准三段术式及绚丽术入门》一书讲解的权重规律,对人物和背景的权重进行调整。
正面 tag
> (extremely detailed CG unity 8k wallpaper), masterpiece, best quality, (ultra-detailed), (best illumination), best shadow, (an extremely delicate and beautiful), classic, (impasto), photorealistic, painting, realistic, sketch, (portrait), cinematic lighting, dynamic angle, floating, finely detail, (bloom), (shine), glinting stars, (1girl:1.75), (loli), ((an extremely delicate and beautiful girl)), ((extremely detailed cute anime face)), (((extremely detailed body))), (bare shoulder), small breast, ((sideboob)), Iridescence and rainbow sailor dress, (detailed wet clothes), (silk shawl:1), (5), bikini(Iridescence and rainbow eyes), big top sleeves, frills, floating hair, Mist encircles the mountains, dawn, (The castle stands out against the sky), Flowery meadow, feather, nature, (sunlight), river, forest
反面 tag
> Inverted mountain, low-quality, low-quality illustration, low-quality background, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, Missing limbs, three arms, bad feet, text font ui, signature, blurry, text font ui, malformed hands, long neck, limb, Sleeveles, bad anatomy disfigured malformed mutated, (mutated hands and fingers:1.5), (long body:1.3), (mutation), (poorly drawn:1.2), bad anatomy, disfigured, malformed, mutated, multiple breasts, futa, yaoi, three legs
参数:
> Euler a, CFG7, step30
### 星语术
{{< image src="planetaryCode.avif" width="450px" caption="星语术" >}}
作者橘貓001QQ2845651288
{{< center-quote >}}
感謝 steelplate 大佬教我的一些基礎 tag!
{{< /center-quote >}}
正面 tag
> ((masterpiece)), ((best quality)), ((illustration)), extremely detailed, style girl, long shot, small breast, light grey very_long_hair, scifi hair ornaments, beautiful detailed deep eyes, beautiful detailed sky, beautifuldetailed water, cinematic lighting, dramatic angle, (very long sleeves), frills, formal, close to viewer, (an extremely delicate and beautiful), best quality, highres, official art, extremely detailed CG unity 8k wallpaper, ((starry sky)), star river, array stars, Holy, noble, ((oil painting)), ((wallpaper 8k CG)), (realistic), Concept Art, vary blue and red and orange and pink hard light, intricate light, dynamic hair, haircut, dynamic fuzziness, beautiful and aesthetic, intricate light, manga and anime
反面 tag
> nsfw, owres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, missing fingers, bad hands, missing arms, long neck, Humpbacked
参数:
> Steps: 50, Sampler: Euler a, CFG: 5-16, Clip skip: 2
### 金石法
{{< image src="goldCystalCode.avif" width="350px" caption="金石法" >}}
作者明月珰QQ1816153515
华丽丽的法术融合了金属与宝石的绚烂。此法术可以生成背景可以生成人物。需要手动调整Tag数目可能有点小多各位魔法学徒可以截取部分使用。
正面 tag
> Hide hands, (Magic circle), Principal, ((Gem)), elegant, (holy), extremely detailed 8k wallpaper, (painting), (((ink))), (depth of field), ((best quality)), ((masterpiece)), (highres), (((ink))), (illustration), cinematic lighting, ((ultra detailed)), (watercolor), detailed shadow, (((1girl))), (detailed flooding feet), (((((long top sleeves past fingers))))), ((motion)), beautiful detailed fullbody, (leg up), (((sapphire frills))), (((yokozuwari in the golden cage))), gold cage, (birdcage), {{{very long dress cover feet}}}, (translucent fluttering dress with lace}), {{detailed skin}}, (((long Bright wavy hair))), Juliet_sleeve, (((hands hide in puffy sleeves))), ((bare shoulders)), flat_chst, ((Crystal shoes)), ((((arms behind back)))), (((extremely detailed cute anime face))), Jewelry decoration, ((expressionless)), (Iridescent Gem Headwear), (Beautiful detailed gemological eyes), ((melting silver and gold)), looking_at_viewer, {detailed bare foot}, Obsidian bracelet, gold arm ring, (Precious refraction), {splash}, {{optical phenomena}}, detailed glow, (lightroom), (shine), chains, reflective, Gemological ornaments, Cosmic background of nebula, ((silver thorns)), (huge golden clock core above), gear, falling petals, Window pane, beautiful water, Colored crystal, mirror, Silver frame, canopy, detailed Diamonds, (Columnar crystal), (Columnar crystal), Latin Cross Budded, (Sputtered broken glass from inside to outside), (flow), dark
反面 tag
> lowres, highres, worst quality, low quality, normal quality, artbook, game_cg, duplicate, grossproportions, deformed, out of frame, 60s, 70s, 80s, 90s, 00s, ugly, morbid, mutation, death, kaijuu, mutation, no hunmans.monster girl, arthropod girl, arthropod limbs, tentacles, blood, size difference, sketch, blurry, blurry face, blurry background, blurry foreground, disfigured, extra, extra_arms, extra_ears, extra_breasts, extra_legs, extra_penises, extra_mouth, multiple_arms, multiple_legs, mutilated, tranny, trans, trannsexual, out of frame, poorly drawnhands, extra fingers, mutated hands, poorly drawn face, bad anatomy, bad proportions, extralimbs, more than 2 nipples, extra limbs, bad anatomy, malformed limbs, missing arms, miss finglegs, mutated hands, fused fingers, too many fingers, long neck, bad finglegs, cropped, bad feet, bad anatomy disfigured, malformed mutated, missing limb, malformed hands
参数:
> Step 随意(但别太低) Cfg随意 DDIM
### 飘花法
{{< image src="floatFlowerCode.avif" width="450px" caption="飘花法" >}}
作者低吟浅唱27
{{< center-quote >}}
只要不跑全身,怎么都好看。
{{< /center-quote >}}
正面 tag
> ((ink)), (water color), bloom effect, ((best quality)), ((world masterpiece)), ((illustration)), (white_hair), (gold_eye), (((1girl))), (beautiful detailed girl), golden_eye, ((extremely_detailed_eyes_and_face)), long_hair, detailed, detailed_beautiful_grassland_with_petal, flower, butterfly, necklace, smile, petal, (silver_bracelet), (((surrounded_by_heavy_floating_petal_flow)))
反面 tag
> lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, artist name, bad feet, nude, skeleton_girl
参数:
> Steps: 50, Sampler: Euler a, CFG scale: 4
### 冰霜龙息
{{< image src="forzenDargonCode.avif" width="450px" caption="冰霜龙息" >}}
作者:東雲
不会有人不喜欢龙娘吧?不会有人不喜欢冰龙吧?那冰龙娘人见人爱没问题吧?
这次提供了两个版本,第一个是基于“沉入星海”修改的高上限版,出图上限极其离谱,缺点是有时丢掉龙的元素。
所以我又(负)优化制作了稳定版,画风更立体细腻,稍微牺牲了一点上限但是换来了更稳定的画面元素构成和高得多的下限。
PS. 两个版本的良品率都很高。
还有可以自行修改稳定版的 tag删改元素后会破坏稳定性但是有小概率抽到超级 UR可以当抽卡模拟器玩。
正面 tag
> 上限版:((best quality)), ((masterpiece)), ((ultra-detailed)), (illustration), (detailed light), (an extremely delicate and beautiful), a girl, solo, (beautiful detailed eyes), blue dragon eyes, (((Vertical pupil))), two-tone hair:blue and white, shiny hair, colored inner hair, (blue Dragonwings), blue_hair ornament, ice adorns hair, [dragon horn], depth of field
>
> 稳定版:((best quality)), ((masterpiece)), ((ultra-detailed)), extremely detailed CG, (illustration), ((detailed light)), (an extremely delicate and beautiful), a girl, solo, ((upper body)), (), ((cute face)), expressionless, (beautiful detailed eyes), blue dragon eyes, (Vertical pupil:1.2), white hair, shiny hair, colored inner hair, (Dragonwings:1.4), [Armor_dress], blue wings, blue_hair ornament, ice adorns hair, [dragon horn], depth of field, [ice crystal], (snowflake), [loli], [[[[[Jokul]]]]]
反面 tag
> 上限版owres, bad anatomy, text, error, extra digit, fewer digits, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, (blurry:1.1), missing arms, two girls
>
> 稳定版owres, bad anatomy, text, error, extra digit, fewer digits, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, (blurry:1.1), missing arms, two girls, feather, ((simple background)), squinting
参数:
> 上限版Steps: 25, Sampler: DDIM, CFG scale: 5, Size: 1280x448, Model hash: e6e8e1fc, Clip skip: 2
>
> 稳定版Steps: 55, Sampler: Euler, CFG scale: 5, Size: 1024x640, Model hash: e6e8e1fc, Clip skip: 2
## 第二卷预告
谢谢各位看第一点五卷啦!本卷的目标是对第一卷的衍生和扩展,现在我们策划组已经收到了很多很厉害的大佬投稿!所以请期待新的第二卷,对比于第一卷和第一点五卷是属于画风上的超进化!!!
下面是目前第二卷收录的一些大佬的效果图,真的是太好看惹 (¯﹃¯) (麦子)
某不愿透露姓名的钢板注:这种海报既视感是怎么回事。
某驾校校长注:做出来中二程度拉满的海报太棒啦!
某 antwon 注:中二感还能再强一点!
某 mahiru 注:欸嘿
老年痴呆的疾风法师注:话说真的还有必要在名字前加一个某吗?(生草海报)
校长注:可是咱就叫某驾校校长欸!!!
{{< image src="p2Preview.avif" width="100%" caption="生草海报" >}}

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Some files were not shown because too many files have changed in this diff Show More